<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="http://www.saigonist.com/taxonomy/term/10/all" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>yalla</title>
    <link>http://www.saigonist.com/taxonomy/term/10/all</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Pligg long running queries</title>
    <link>http://www.saigonist.com/content/pligg-long-running-queries</link>
    <description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;For awhile I&amp;#39;ve been plagued with these long running queries on my Pligg site that were running up CPU:&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;SELECT DISTIN&lt;/code&gt;&lt;/span&gt;CT pv_user_id, pv_type, pv_page_id FROM mypligg_pageviews GROUP BY pv_type, pv_page_id, pv&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;And so I was running the mkill Perl script to kill any queries taking longer than a minute to complete.&lt;/div&gt;
&lt;div&gt;But recently even that stopped working, leaving queries in the Killed state but still running up CPU. &amp;nbsp;They were all stuck in &amp;quot;converting&amp;nbsp;HEAP&amp;nbsp;to&amp;nbsp;MyISAM&amp;quot;. &amp;nbsp;Did some diagnostics:&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;mysql&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;gt&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; SHOW GLOBAL STATUS LIKE &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;#&lt;span style=&quot;color: #CC0000;&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;Created_tmp_tables&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;#&lt;span style=&quot;color: #CC0000;&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+--------------------+-------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; Variable_name &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;|&lt;/span&gt; Value &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+--------------------+-------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; Created_tmp_tables &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;196&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+--------------------+-------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;1&lt;/span&gt; row &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;set&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0.01&lt;/span&gt; sec&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;mysql&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;gt&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; SHOW GLOBAL STATUS LIKE &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;#&lt;span style=&quot;color: #CC0000;&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;Created_tmp_disk_tables&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;#&lt;span style=&quot;color: #CC0000;&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+-------------------------+-------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; Variable_name &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; Value &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+-------------------------+-------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; Created_tmp_disk_tables &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;159&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+-------------------------+-------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;1&lt;/span&gt; row &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;set&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0.01&lt;/span&gt; sec&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;mysql&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;gt&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; show variables like &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;#&lt;span style=&quot;color: #CC0000;&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;tmp_table_size&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;#&lt;span style=&quot;color: #CC0000;&quot;&gt;39&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+----------------+----------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; Variable_name &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;|&lt;/span&gt; Value &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;|&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+----------------+----------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; tmp_table_size &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;33554432&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;|&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #339933;&quot;&gt;+----------------+----------+&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;1&lt;/span&gt; row &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;set&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0.01&lt;/span&gt; sec&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;So it seemed there wasn&amp;#39;t enough memory to perform the conversion without going to disk which is not what we want. &amp;nbsp;So I set&amp;nbsp;tmp_table_size&amp;nbsp;and&amp;nbsp;max_heap_table_size to larger values,&amp;nbsp;max_heap_table_size too because MySQL uses the lesser of the two.&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;mysql&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;gt&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;set&lt;/span&gt; tmp_table_size&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;100000000&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;Query OK&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt; rows affected &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0.00&lt;/span&gt; sec&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;mysql&lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;gt&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight: bold;&quot;&gt;set&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt;nbsp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;max_heap_table_size&lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;100000000&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span class=&quot;geshifilter&quot;&gt;&lt;code class=&quot;javascript geshifilter-javascript&quot;&gt;Query OK&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #CC0000;&quot;&gt;0&lt;/span&gt; rows affected &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #CC0000;&quot;&gt;0.01&lt;/span&gt; sec&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;p&gt;And now we&amp;#39;re golden, CPU back down to normal levels and queries finishing.&lt;/p&gt;
</description>
     <comments>http://www.saigonist.com/content/pligg-long-running-queries#comments</comments>
 <category domain="http://www.saigonist.com/category/type/tech">Tech</category>
 <category domain="http://www.saigonist.com/category/tags/mysql">mysql</category>
 <category domain="http://www.saigonist.com/category/tags/pligg">pligg</category>
 <category domain="http://www.saigonist.com/category/tags/yalla">yalla</category>
 <pubDate>Mon, 06 Sep 2010 19:20:55 +0000</pubDate>
 <dc:creator>tomo</dc:creator>
 <guid isPermaLink="false">4 at http://www.saigonist.com</guid>
  </item>
  </channel>
</rss>