optimization - Does an index < or > MySQL queries? -
if have query like,
delete table datetime_field < '2008-01-01 00:00:00'
does having datetime_field
column indexed help? i.e. index useful when using equality (or inequality) testing, or useful when doing ordered comparison well?
(suggestions better executing query, without recreating table, ok!)
maybe. in general, if there such index, use range scan on index if there no "better" index on query. however, if optimiser decides range end being big (i.e. include more than, 1/3 of rows), won't use index @ all, table scan faster.
use explain (on select; can't explain delete) determine decision in specific case. depend upon
- how many rows there in table
- what range you're specifying
- what else specified in clause. won't use range scan of 1 index if there index "looks better".
Comments
Post a Comment