How to profile MySQL

Dan picture Dan · Jun 18, 2009 · Viewed 31.4k times · Source

How do I profile a MySQL database. I want to see all the SQL being run against a database.

I know you can do this:

  • set profiling=1;
  • Run your slow query (eg SELECT * FROM messages WHERE fromaddress='xxx';
  • SHOW PROFILES;

But this seem to only apply to stuff run on the command line, I want to see the results from running a website.

Answer

Tom Ritter picture Tom Ritter · Jun 18, 2009

You want the query log - but obviously doing this on a heavy production server could be... unwise.