bimalpoudel — 2012-11-02T06:34:17-04:00 — #1
I would like to find out if someone can help me to optimize the date range calculation in the following query:
birthday BETWEEN DATE_SUB(CURRENT_DATE(), INTERVAL 100 YEAR) AND DATE_SUB(CURRENT_DATE(), INTERVAL 0 YEAR)
I want a speedy birthday comparison over huge users database.
kylewolfe — 2012-11-02T09:48:36-04:00 — #2
See here http://stackoverflow.com/questions/4382892/whats-mysqls-between-performance-over. I don't see anything that will help other than POSSIBLY allowing nulls in birthday and switching the default value to NULL so that you are searching for birthday is null rather than birthday = '0000-00-00'
r937 — 2012-11-02T09:55:15-04:00 — #3
make sure there's an index on birthday
i can think of a few ways to make your query easier to read, but that's not what you asked