views:

64

answers:

1

I wanna be able to add a little note, at the beginning of each query, so when I see it in the processlist, or "mytop", I can tell where its running.

Is something like this possible?

A: 

Not sure this would work, but worth trying.

Simply add "/* some comment or tag */ " before whatever SQL query is sent normally.

It is possible that mySQL server will remove this comment as part of its query analysis/preparation, but it may just leave it as well, so it shows as such in logs and other monitoring tools.

In case the comments get stripped away, and assuming SELECT queries, a slight variation on the above would be to add a calculated column as the first thing after SELECT, something like

SELECT IF('some comment/tag' = '', 1, 0) AS BogusMarker, here-start-the-original-select-list
-- or
SELECT 'some [short] comment/tag' AS QueryID, here-start-the-original-select-list

This approach has the drawback of introducing an extra column value, with each of the results row. The latter form, actually use the "comment/tag" value as this value, which may be helpful for debugging purposes.

mjv