WILLIEWANKA
Technical User
I have a date column that is indexed, and I want to query a range of dates.
Which will use the index and which will use a full table scan?
1. select * from table where column_date between '2004-06-01' and '2004-06-30';
2. select * from table where substr(column_date,1,7) = substr(date,1,7);
I think the first will use the index because it matches the entire column, whereas the second only uses part of it.
Any ideas? I've done explains on both, and can't see much difference (aside from expected rows returned)
Which will use the index and which will use a full table scan?
1. select * from table where column_date between '2004-06-01' and '2004-06-30';
2. select * from table where substr(column_date,1,7) = substr(date,1,7);
I think the first will use the index because it matches the entire column, whereas the second only uses part of it.
Any ideas? I've done explains on both, and can't see much difference (aside from expected rows returned)