I would like to find what is better approach, primary in matter of performance in my databse. Wildcard LIKE, or a range search?
Lets have this table:
| id INT | created DATE | some other columns ... |
If I want to select entries that was created in some month, I can think out two options. One is a pair of comparisons to search in a range:
SELECT * FROM my_table WHERE created >= '2014-09-01' AND created < '2014-10-1'
The second is a wildcard LIKE:
... WHERE created LIKE '2014-09-%'
I have created a dummy table with few hundreds entries, divided between three months. When I run a select with both conditions (with disabled caching and index created on the column), the time was roughly the same - once was faster the first one, another time the second one. The times were between 4.0 and 5.0 ms on an old Atom CPU.
It seems to me that from performance view, it is not much important which one I will use. Is it correct? Or there will appears differences with many thousands of rows?
Thanks