I have a 42,000 row table of cities and zip codes and I'm running a query on it to select cities with more than X zip codes in them. The query is:

SELECT CONCAT(city, ' ', state) AS name, COUNT(*) AS mycount
FROM Cities
GROUP BY name
HAVING mycount > 60

This takes about 1.5 seconds to run. How can I best index this table to optimize results? The table columns are:

zip VARCHAR(5) PRIMARY KEY
latitude DECIMAL(20,18)
longitude DECIMAL(20,18)
city VARCHAR(100)
state CHAR(2)

Thanks in advance.


:::::::::::::::::::::::::::::::::: Howard Cheng http://www.howcheng.com/ howcheng at ix dot netcom dot com AIM: bennyphoebe ICQ: 47319315


____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] Send Your Posts To: [EMAIL PROTECTED]
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub


________________ http://www.wdvl.com _______________________

You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to