MySQL not using index on DATE when used with '<' or '>' operators?

Posted by Haroldo on Stack Overflow See other posts from Stack Overflow or by Haroldo
Published on 2010-06-18T10:53:22Z Indexed on 2010/06/18 11:43 UTC
Read the original article Hit count: 203

Filed under:

I'm using explain to test these queries. The col type is DATE

this uses index:

explain SELECT events.* FROM events WHERE events.date = '2010-06-11' 

this doesnt

explain SELECT events.* FROM events WHERE events.date >= '2010-06-11' 

index as follows (phpmyadmin)

Action  Keyname Type    Unique  Packed  Field   Cardinality Collation   Null    Comment
Edit    Drop    PRIMARY BTREE   Yes No  event_id    18  A       
Edit    Drop    date    BTREE   No  No  date    0   A       

i notice cardinality is 0, though there are some rows with the same date..

© Stack Overflow or respective owner

Related posts about mysql