Mysql – Super simple thesql query taking too long

MySQLperformancequery-performance

I have the following:

SELECT * FROM autorepair
WHERE zip_code IN (91316,91356,91416,91426,91436)
AND specialty = 'transmission'
ORDER BY ABS(91316 - `zip_code`)
LIMIT 0,10

Indexes:

-zip_code
-specialty

How can I improve the performance on queries like these?

BTW, I'm running this on XAMPP.

Best Answer

Create a compound index as follows:

ALTER TABLE autorepair ADD INDEX specialty_zipcode_ndx (specialty,zipcode);

and drop the single column specialty index

ALTER TABLE autorepair DROP INDEX specialty;