Thursday, July 15, 2010

Quick MySQL tip: add comments to query (binary log)

Quick MySQL tip: add comments to query (binary log)

MySQL allows comments to be added with the standard /* */ syntax. If your application is getting more complex, it can become more difficult to figure out where certain queries originate from.

By simply adding a comment in front of your query, it will be very easy to spot the origin of some of your queries.

/* recent blogposts */ SELECT id, title, time FROM blogposts ORDER BY time DESC limit 10

The comment will show up as the first thing in SHOW [FULL] PROCESSLIST, MySQL administrator and your log/slow-log files.

No comments: