[thelist] How to best index this table?

Howard Cheng howcheng at ix.netcom.com
Wed Mar 12 19:05:10 CST 2003


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



More information about the thelist mailing list