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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -