Michael Gale wrote:

When I run the following:
`Select DISTINCT machine from syslog WHERE date1 > (NOW() - INTERVAL 1
hour);' it takes 9min to complete.


If I use "Explain" it says the query is using index "hostname", should
it not be using the index "hostdate" which contains fields "machine" and
"date1" since those are the fields I am using in my query ?

Your WHERE clause needs an index on date1, which means an index that *starts* with date1. Your index on (machine, date1) won't help in this case. You could use an index on just date1 or on (date1, machine). The second would allow MySQL to do that query from the index alone, without referring to the data file, so it should be much faster than what you're doing now.


--
Keith Ivey <[EMAIL PROTECTED]>
Smokefree DC
http://www.smokefreedc.org
Washington, DC

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to