As a MySQL DBA I already know the data changes that happen on my system. I have logs for that.
However, it’s a common problem that several years into the life of an application, the current developers won’t know where in the codebase queries come from. It’s often hard for them to find the location in the code if queries are formed dynamically; the pattern I show them to optimize doesn’t match anything in the code.
I stumbled on a trick a couple years ago that has been invaluable in tracking down these problematic queries: query comments.
Here’s an example:
When a query generally shows up in a slow query …[Read more...]