I was trying to demonstrate to a client how to monitor queries that generate internal temporary tables. With an EXPLAIN plan you see ‘Creating temporary’. Within MySQL you can use the SHOW STATUS to look at queries that create temporary tables.
There is the issue that the act of monitoring impacts the results, SHOW STATUS actually creates a temporary table. You can see in this example.
mysql> select version(); +-----------------+ | version() | +-----------------+ | 5.1.31-1ubuntu2 | +-----------------+ 1 row in set (0.00 sec) mysql> show global status like 'created_tmp%'; +-------------------------+-------+ | Variable_name | Value | +-------------------------+-------+ | Created_tmp_disk_tables | 48 | | Created_tmp_files | 5 | | Created_tmp_tables | 155 | +-------------------------+-------+ 3 rows in set (0.00 sec) mysql> show global status like 'created_tmp%'; +-------------------------+-------+ | …[Read more]