mysql - Optimizing a SQL query to avoid full table scan -
consider following query:
select * transactions day(stamp - interval 3 hour) = 1;
the stamp column in transactions table timestamp , there index on it. how change query avoids full table scans? (that is, using stamp outside of day() function)
thanks!
this how it:
add fields: year, month, day or hour, minute depending on traffic expect. build trigger populate fields, maybe subtracting 3 hour interval in advance. build index on fields.
Comments
Post a Comment