(Using mysql 3.23.38 - commercial version) I have a table that has two indexes: one on just "creationTime" (iv_alert_creation_ix), and one on "(state, creationTime)" (iv_alert_state_ix).
When I issue this query: explain select uuid from iv_alert where state = 1 and creationTime >= '20020201000000' and creationTime <= '20020301000000' order by state, creationTime desc; mysql says (output munged to fit): table iv_alert type range possible_keys iv_alert_creation_ix, iv_alert_state_ix key iv_alert_creation_ix key_len 4 ref NULL rows 1 Extra where used; using filesort Why doesn't it use the iv_alert_state_ix key? Is there any way to make it do so? There can be lots of entries in that time range, but only a few with "state". Of course, I'm using a synthetic database to test the query, and it currently doesn't have that many rows - is the "explain" output influenced by the actual data present, or is it just using a fixed heuristic? Thanks, -- Shankar. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php