Django SQL Sampling
colinhowe.co.uk
colinhowe.co.uk
For Postgres: http://pgfouine.projects.postgresql.org/ Sample: http://pgfouine.projects.postgresql.org/reports/sample_defau...
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).
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 :)
The idea is to help you find your trouble spots - DjDT is amazing once you know where they are :)