I have 1 MyISAM table with 620,000 rows. Im running XAMPP on a Dual Core Server with 2GB RAM. Apache is installed as a Windows Service, MySQL is controlled from the XAMPP control panel.
The query below is taking 30+ seconds to run.
select `id`,`product_name`,`search_price`,`field1`,`field2`,
`field3`,`field4`
from `all`
where MATCH (`product_name`) AGAINST ('searchterm')
AND `search_price` BETWEEN 0 AND 1000
ORDER BY `search_price` DESC
LIMIT 0, 30
I have a FULLTEXT index on product_name
, a BTREE on search_price
, auto increment on id
If I explain the above query the results are:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE all fulltext search_price,FULLTEXT_product_name FULLTEXT_product_name 0 NULL 1 Using where; Using filesort
How can I speed up this query? Should it be taking this long on a table of 620,000 rows?
Ive just noticed that this only happens when the database has not been queried for a while, so im guessing this is to do with the cache, the first query is taking 30+ seconds, then if I try a second time the query takes 1 second