Reputation: 110123
In mysql, is there any benefit to adding an index to a DATE
column? I will be using the column for comparisons such as:
SELECT * FROM birthdays WHERE date > today + 3 days;
Would indexing the date
column improve performance here?
Upvotes: 2
Views: 3261
Reputation: 21004
Yes, it will avoid some full scan by eliminating some rows in condition.
Check out this thread, it's well explained :
Is it a good idea to index datetime field in mysql?
Upvotes: 1
Reputation: 24146
Index will improve performance.
Without index mysql will have to scan all rows.
With index - it will create sorted "array", so it will be able to use binary search to find where today+3
starts and just scan all further rows of this array instead of full scan.
Upvotes: 0
Reputation: 21184
Yes, it can use it to do a range scan in the query you suggested.
Upvotes: 0