Whilst working with a client recently I noticed a large number of temporary tables being created on disk.
12345 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.
12345 mysqladmin ext -ri60| Created_tmp_disk_tables | 74 || Created_tmp_files | 3 || Created_tmp_tables | 357 |
The microslow patch adds a very useful feature, the ability to log queries by execution plan.
<span style="color: #38acec;">log_slow_filter=name</span>
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.
1 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.
1 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 https://www.percona.com/percona-lab.html
Percona’s widely read Percona Data Performance blog highlights our expertise in enterprise-class software, support, consulting and managed services solutions for both MySQL® and MongoDB® across traditional and cloud-based platforms. The decades of experience represented by our consultants is found daily in numerous and relevant blog posts.
Besides specific database help, the blog also provides notices on upcoming events and webinars.
Want to get weekly updates listing the latest blog posts? Subscribe to our blog now! Submit your email address below.