4 ms·
I write one of these for every large project during the optimization stage (beta testing with real data and use). I could not possibly recommend it more - not
by enobrev 15y ago
I write one of these for every large project during the optimization stage (beta testing with real data and use). I could not possibly recommend it more - not only for SQL tuning but also for tuning the cache.
I haven't looked at the source just yet, but in my own implementations, I usually keep a hash of the results as well so I can see how often the results change. If they rarely change, you have a prime candidate for heavy caching.
Another solid metric to follow are queries that are run often per request. So if I have the same query firing 5 times in a single request (even a light one) with the same returned data, I'll find a way to make sure it only runs once per request (or less).
- colinhowe 15y agoThis gave me two awesome ideas - thank you! 1. Hash the results as you say to try and find queries that could benefit from being cached 2. Graph the change in a queries performance over time - useful for spotting queries that were fast due to a small table and are now becoming troublesome I'll start looking at these in the next few nights :)