Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The EXPLAIN report may say "Using filesort" but that's misleading. It doesn't mean it's writing to a file, it only means it's sorting without the benefit of an index.</p> <p>The EXPLAIN report may say "Using temporary" but this doesn't mean it's using a temporary table on disk. It can make a small temp table in memory. The table must fit within the <em>lesser</em> of <a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_heap_table_size" rel="noreferrer">max_heap_table_size</a> and <a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_tmp_table_size" rel="noreferrer">tmp_table_size</a>. If you increase tmp_table_size, you should also increase max_heap_table_size to match. </p> <p>See also <a href="http://dev.mysql.com/doc/refman/5.1/en/internal-temporary-tables.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.1/en/internal-temporary-tables.html</a> for more info on temporary table management.</p> <p>But 4 gigs for that value is very high! Consider that this memory can potentially be used <em>per connection</em>. The default is 16 megs, so you've increased it by a factor of 256.</p> <p>So we want to find which queries caused the temp disk tables.</p> <p>If you run MySQL 5.1 or later, you can <a href="http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_long_query_time" rel="noreferrer">SET GLOBAL long_query_time=0</a> to make <em>all</em> queries output to the slow query log. Be sure to do this only temporarily and set it back to a nonzero value when you're done! :-)</p> <p>If you run <a href="http://www.percona.com/software/percona-server/" rel="noreferrer">Percona Server</a>, the <a href="http://www.percona.com/docs/wiki/percona-server%3afeatures%3aslow_extended_51" rel="noreferrer">slow query log is extended</a> with additional information and configurability, including whether the query caused a temp table or a temp disk table. You can even filter the slow-query log to include only queries that cause a temp table or temp disk table (the the docs I link to).</p> <p>You can also process Percona Server's slow-query log with <a href="http://www.maatkit.org/doc/mk-query-digest.html" rel="noreferrer">mk-query-digest</a> and filter for queries that cause a temp disk table.</p> <pre><code>mk-query-digest /path/to/slow.log --no-report --print \ --filter '($event-&gt;{Disk_tmp_table }||"") eq "Yes"' </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload