Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two things you can do to lessen the impact by this</p> <p><strong>OPTION #1 : Increase the variables <a href="http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_tmp_table_size" rel="noreferrer">tmp_table_size</a> and/or <a href="http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_max_heap_table_size" rel="noreferrer">max_heap_table_size</a></strong></p> <p>These options will govern how large an in-memory temp table can be before it is deemed too large and then pages to disk as a temporary MyISAM table. The larger these values are, the less likely you will get 'copying to tmp table on disk'. Please, make sure your server has enough RAM and <a href="http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_max_connections" rel="noreferrer"><strong>max_connections</strong></a> is moderately configured should a single DB connection need a lot of RAM for its own temp tables.</p> <p><strong>OPTION #2 : Use a RAM disk for tmp tables</strong></p> <p>You should be able to configure a RAM disk in Linux and then set the <a href="http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_tmpdir" rel="noreferrer"><strong>tmpdir</strong></a> in mysql to be the folder that has the RAM disk mounted.</p> <p>For starters, configure a RAM disk in the OS</p> <p>Create a folder in the Linux called /var/tmpfs</p> <pre><code>mkdir /var/tmpfs </code></pre> <p>Next, add this line to /etc/fstab (for example, if you want a 16GB RAM disk)</p> <pre><code>none /var/tmpfs tmpfs defaults,size=16g 1 2 </code></pre> <p>and reboot the server.</p> <p>Note : It is possible to make a RAM disk without rebooting. Just remember to still add the aforementioned line to /etc/fstab to have the RAM disk after a server reboot.</p> <p>Now for MySQL:</p> <p>Add this line in /etc/my.cnf</p> <pre><code>[mysqld] tmpdir=/var/tmpfs </code></pre> <p>and restart mysql.</p> <p><strong>OPTION #3 : Get tmp table into the RAM Disk ASAP (assuming you apply OPTION #2 first)</strong></p> <p>You may want to force tmp tables into the RAM disk as quickly as possible so that MySQL does not spin its wheels migrating large in-memory tmp tables into a RAM disk. Just add this to /etc/my.cnf:</p> <pre><code>[mysqld] tmpdir=/var/tmpfs tmp_table_size=2K </code></pre> <p>and restart mysql. This will cause even the tiniest temp table to be brought into existence right in the RAM disk. You could periodically run <code>ls -l /var/tmpfs</code> to watch temp tables come and go.</p> <p>Give it a Try !!!</p> <p><strong>CAVEAT</strong></p> <p>If you see nothing but temp tables in /var/tmpfs 24/7, this could impact OS functionality/performance. To make sure /var/tmpfs does not get overpopulated, look into tuning your queries. Once you do, you should see less tmp tables materializing in /var/tmpfs.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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