Tracking SQL queries

Thursday, November 22, 2018

This is a very clever technique that allows you to add meta data (or "comments") to SQL queries from within your application or framework.

It allows you to track down where in your application it has been called and can give a lot more insight into someone troubleshooting slow queries.

[...] if this is a specific query you might know which URL or method is sending it, but what if someone not so familiar with the application needed to investigate it -- would they be able to find it?

One option is to add a comment to your query that contains some useful information such as class name, method name or even a request ID.

Source: Tracking SQL queries ยท Jacob Bednarz