Finding what Created_tmp_disk_tables with log_slow_filter
Whilst working with a client recently I noticed a large number of temporary tables being created on disk.
show global status like 'Created_tmp%'| Created_tmp_disk_tables | 91970 |
| Created_tmp_files | 19624 |
| Created_tmp_tables | 1617031 |
Looking at a 60 second sample showed there was a steady flow of queries creating disk based tables.
mysqladmin ext -ri60| Created_tmp_disk_tables | 74 |
| Created_tmp_files | 3 |
| Created_tmp_tables | 357 |
Luckily this client was running the Percona patched version of MySQL.
The microslow patch adds a very useful feature, the ability to log queries by execution plan.
log_slow_filter=name
Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]
So now all I had to do was set the filter to “tmp_table_on_disk,filesort_on_disk” and I would get only those which use on-disk temporary storage for intermediate results.
SET GLOBAL log_slow_filter:= “tmp_table_on_disk,filesort_on_disk”;
Wait a couple of minutes and then set the filter to an empty string to stop collection.
SET GLOBAL log_slow_filter:="";
Then it was just a question of examining the slow query log and fixing the queries.
More information about the patches is available here http://www.percona.com/percona-lab.html
3 Comments











del.icio.us
digg
Thanks Ewen,
Nice summary of this not so commonly used option. There is also an other way to do it - by simply logging queries with query plans and post filtering the log file.
Comment :: September 22, 2008 @ 10:21 am
Currently mysqlsla isn’t very er, intuitive for post-filtering
I took the same approach Ewen did and found it easier.
Comment :: September 22, 2008 @ 9:01 pm
Hi,
Have you guys done any benchmark on I/O performance with msl patch ?
I will be interesting to know the results if that is already done.
Hareesh
Comment :: September 22, 2008 @ 10:50 pm