<?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>Building the Web</title>
	<atom:link href="http://www.filonov.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.filonov.com/blog</link>
	<description>Web development notes, tips, tricks, ideas, thoughts</description>
	<lastBuildDate>Sat, 07 Nov 2009 17:33:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Error 400: Size of a request header field exceeds server limit</title>
		<link>http://www.filonov.com/blog/2009/11/07/error-400-size-of-a-request-header-field-exceeds-server-limit/</link>
		<comments>http://www.filonov.com/blog/2009/11/07/error-400-size-of-a-request-header-field-exceeds-server-limit/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 17:33:33 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.filonov.com/blog/?p=50</guid>
		<description><![CDATA[If you get error like this one
Error 400
Your browser sent a request that this server could not understand.
Size of a request header field exceeds server limit.
That means that your browser is trying to send too much at once. Probably, it&#8217;s size of the cookies. The easy way to fix it &#8211; delete cookies. Of course, [...]]]></description>
			<content:encoded><![CDATA[<p>If you get error like this one</p>
<p><code>Error 400<br />
Your browser sent a request that this server could not understand.<br />
Size of a request header field exceeds server limit.</code></p>
<p>That means that your browser is trying to send too much at once. Probably, it&#8217;s size of the cookies. The easy way to fix it &#8211; delete cookies. Of course, you lose all info in the cookies, but at least you can access site again.</p>
<p>If you develop/manage web site and your customers complain of this error message &#8211; there are two things to do: </p>
<ul>
<li>Review cookies and limit the size of cookies your application stores in the browser. </li>
<li>Increase allowed request size in web server configuration</li>
</ul>
<p>To increase request size in Apache, add directive  LimitRequestFieldSize to the configuration file. Default value is 8190 bytes. To increase it 2 times add<br />
<code>LimitRequestFieldSize 16380</code><br />
Apache restart is required.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/11/07/error-400-size-of-a-request-header-field-exceeds-server-limit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse too slow and out of memory</title>
		<link>http://www.filonov.com/blog/2009/08/10/eclipse-too-slow-and-out-of-memory/</link>
		<comments>http://www.filonov.com/blog/2009/08/10/eclipse-too-slow-and-out-of-memory/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 18:16:32 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.filonov.com/blog/?p=47</guid>
		<description><![CDATA[Looks like Eclipse PDT was getting quite slow on me, it thinks sometimes 10-15 seconds when I switch between files or save one. My current project is not small one, but still&#8230; 
Looking around for a solutions I found quite easy tip at
http://www.eclipsezone.com/eclipse/forums/t61618.html
In short &#8211; I am now running
eclipse.exe -vmargs -Xms256m -Xmx256m -XX:PermSize=64m -XX:MaxPermSize=64m 
and [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like Eclipse PDT was getting quite slow on me, it thinks sometimes 10-15 seconds when I switch between files or save one. My current project is not small one, but still&#8230; </p>
<p>Looking around for a solutions I found quite easy tip at<br />
<a href="http://www.eclipsezone.com/eclipse/forums/t61618.html">http://www.eclipsezone.com/eclipse/forums/t61618.html</a></p>
<p>In short &#8211; I am now running<br />
<code>eclipse.exe -vmargs -Xms256m -Xmx256m -XX:PermSize=64m -XX:MaxPermSize=64m </code></p>
<p>and my Eclipse is way faster.</p>
<p>Thanks for the tip, Riyad Kalla!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/08/10/eclipse-too-slow-and-out-of-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLSTATE[HY000] [2003] Can&#8217;t connect to MySQL server on &#8216;xxx.xxx.xxx.xxx&#8217; (13)</title>
		<link>http://www.filonov.com/blog/2009/08/07/sqlstatehy000-2003-cant-connect-to-mysql-server-on-xxx-xxx-xxx-xxx-13/</link>
		<comments>http://www.filonov.com/blog/2009/08/07/sqlstatehy000-2003-cant-connect-to-mysql-server-on-xxx-xxx-xxx-xxx-13/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 14:34:44 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[selinux]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[troubleshooting]]></category>

		<guid isPermaLink="false">http://www.filonov.com/blog/?p=45</guid>
		<description><![CDATA[One of the things I wish I had found in Google faster when trying to figure out why PHP script refuses to connect to remote MySQL server issuing an error
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'xxx.xxxx.xxx.xxx' (13)
I am able to connect from local shell, so first thought was if something wrong with recent [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I wish I had found in Google faster when trying to figure out why PHP script refuses to connect to remote MySQL server issuing an error<br />
<code>SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'xxx.xxxx.xxx.xxx' (13)</code></p>
<p>I am able to connect from local shell, so first thought was if something wrong with recent Zend Framework upgrade, but after a while I figured out that answer is very simple &#8211; SELinux was blocking remote connections from PHP scripts executed by Apache web server. The error code (13) at the end of error message means &#8220;permission denied&#8221;, so that&#8217;s the indication to see if you have similar issue or not.</p>
<p>Anyway, login as root and do<br />
<code>setsebool -P httpd_can_network_connect=1</code><br />
to make it work.</p>
<p>Of course, think twice because you make web server a bit less secure, so don&#8217;t do that unless you are sure you need it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/08/07/sqlstatehy000-2003-cant-connect-to-mysql-server-on-xxx-xxx-xxx-xxx-13/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Joomla profiling log</title>
		<link>http://www.filonov.com/blog/2009/05/25/joomla-profiling-log/</link>
		<comments>http://www.filonov.com/blog/2009/05/25/joomla-profiling-log/#comments</comments>
		<pubDate>Mon, 25 May 2009 21:37:39 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://www.filonov.com/blog/?p=37</guid>
		<description><![CDATA[I am using Joomla for the content management, and it looks like my site is getting slow, no, not just slow, it&#8217;s SLOW.
Quick check in the MySQL database showed that there is no really big tables which could cause some delays if not indexed properly or getting locked. So, next step would be naturally looking [...]]]></description>
			<content:encoded><![CDATA[<p>I am using Joomla for the content management, and it looks like my site is getting slow, no, not just slow, it&#8217;s SLOW.</p>
<p>Quick check in the MySQL database showed that there is no really big tables which could cause some delays if not indexed properly or getting locked. So, next step would be naturally looking into the PHP code itself trying to identify bottlenecks.</p>
<p>First of all &#8211; copy everything to test site &#8211; I don&#8217;t really want to shut the site down or display some debug info to the visitors. My test site is actually a linux box which is pretty old one, so it probably will run slower comparing to production, but hopefully still allow me to find which areas of code are causing that.</p>
<p>Next step &#8211; tools. To profile PHP scripts I&#8217;ll use APD (http://pecl.php.net/package/apd). Best case scenario &#8211; you type<br />
<code>pecl install apd </code><br />
in the shell to install package from PECL.<br />
You may also need to add it to PHP configuration, I just created extra config file<br />
<code>/etc/php.d/apd.ini</code><br />
with content<br />
<code>[apd]<br />
zend_extension="/usr/lib/php/modules/apd.so"<br />
apd.dumpdir = /var/apd<br />
apd.statement_tracing = 0</code><br />
(make sure directory specified in dumpdir is created and writable for PHP)</p>
<p>Now we need to add<br />
<code>apd_set_pprof_trace();</code><br />
at the beginning of the index.php script and open the page we want to profile, front page would be a good place to start.</p>
<p>In the dump directory a file created after each page opening, something like<br />
<code>/var/apd/pprof.08711.0</code></p>
<p>Let&#8217;s see what consumes resources now, by running<br />
<code>/usr/bin/pprofp -R /var/apd/pprof.08711.0</code></p>
<p>Oh, that hurts:</p>
<p><code>Total Elapsed Time = 23.58<br />
Total System Time  = 0.65<br />
Total User Time    = 7.18</code></p>
<p>Log in to Joomla admin, go to Extensions->Module Manager, delete all modules I do not really use, but which came pre-setup with Joomla.</p>
<p><code>Total Elapsed Time = 19.51<br />
Total System Time  = 0.24<br />
Total User Time    = 2.48</code></p>
<p>Ok, I am starting to see results already <img src='http://www.filonov.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now let&#8217;s pay attention to the actual calls and time spent by script in functions.</p>
<p>14 seconds spent in JDocumentRendererModule->getFeed&#8230;<br />
Hm&#8230; I do have a feed from my blog, now I wonder what the cache settings for that block is. So, in admin Module Manager -> mod_feed, advanced settings, cache : use global, time 60 minutes (I think I am ok with blog posts delayed for 1 hour, but it&#8217;s your call, just make sure it won&#8217;t come on every page load). That slashed a lot from the page load &#8211; over 15 sec of wasted time (note &#8211; check why blog feed is so slow, there should be some reasons!!!)</p>
<p>JDocumentHTML->_parseTemplate &#8211; I reviewed template and got rid of calls for modules which are not required or not used (like user1, user2, user3 areas which came with template and similar) &#8211; that saved 1-2 seconds per call.</p>
<p>At this point I have</p>
<p><code>Total Elapsed Time = 2.82<br />
Total System Time  = 0.21<br />
Total User Time    = 2.48</code></p>
<p>Which is way better, but still makes me wonder if it can run faster. </p>
<p>There are other options to play with<br />
<code>/usr/bin/pprofp -u /var/apd/pprof.09573.15</code><br />
gives an idea what subroutines consumed most user time.</p>
<p>Last but not least: for the profiling purposes I turned off cache (Site->admin->global configuration). For life site it should be turned on with reasonable time to keep cached copy, that shaves off another 50% of execution time on subsequent calls of the same page.</p>
<p><code>Total Elapsed Time = 1.78<br />
Total System Time  = 0.17<br />
Total User Time    = 1.55</code></p>
<p>For now it&#8217;s as good as it gets on my old server, next thing to do would be profiling the script on the production server to see what it looks like there.</p>
<p>Another tip: if you profile a live site, restrict profiler calls to your own IP:<br />
<code>if($_SERVER['REMOTE_ADDR'] == "xxx.xxx.xxx.xxx") {<br />
apd_set_pprof_trace();<br />
}</code><br />
otherwise you may get buried in a number of trace logs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/05/25/joomla-profiling-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Typos and traffic</title>
		<link>http://www.filonov.com/blog/2009/05/18/typos-and-traffic/</link>
		<comments>http://www.filonov.com/blog/2009/05/18/typos-and-traffic/#comments</comments>
		<pubDate>Mon, 18 May 2009 18:21:22 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://filonov.com/blog/?p=35</guid>
		<description><![CDATA[I just discovered interesting thing &#8211; to my shame I misspelled word &#8220;developer&#8221; (as in web developer) on my web site and for a while I was advertising myself as &#8220;web developmer&#8220;. Bad for me I guess. But interesting thing, when checking statistics, I get better position in the search results as a developMer &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>I just discovered interesting thing &#8211; to my shame I misspelled word &#8220;developer&#8221; (as in web developer) on my web site and for a while I was advertising myself as &#8220;web <b>developmer</b>&#8220;. Bad for me I guess. But interesting thing, when checking statistics, I get better position in the search results as a developMer &#8211; just because there is not a lot of pages with same typo. Just to compare &#8211; when I  search for the web developer it returns over 56 millions of pages and for web developmer it&#8217;s only 4500. So, I guess if I add more words like this to my page saying that I do dtabase desing and php programing as well as software analitics, I have good chance to pop up higher in Google search results. The question is, however, do I really want people to see pages with those typos and if those people will be willing to hire guy with spelling like that and no attention to details. Well, I guess some people won&#8217;t notice, but probably I don&#8217;t really want to take a chance &#8211; so fixing the spelling and having a good laugh. At least I still have a blog entry with developmer in it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/05/18/typos-and-traffic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Application in PHP???</title>
		<link>http://www.filonov.com/blog/2009/05/14/windows-application-in-php/</link>
		<comments>http://www.filonov.com/blog/2009/05/14/windows-application-in-php/#comments</comments>
		<pubDate>Thu, 14 May 2009 17:46:51 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[php windows]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://filonov.com/blog/?p=33</guid>
		<description><![CDATA[Quite an interesting idea &#8211; to execute PHP scripts in Windows as regular exe. Behind the scenes it uses IE component, but there is no IE toolbars and you have a control on windows your application uses. Also you can create an installer, so it will look for user as a regular windows application.
These days [...]]]></description>
			<content:encoded><![CDATA[<p>Quite an interesting idea &#8211; to execute PHP scripts in Windows as regular exe. Behind the scenes it uses IE component, but there is no IE toolbars and you have a control on windows your application uses. Also you can create an installer, so it will look for user as a regular windows application.</p>
<p>These days a lot of applications are actually switching to web services, so you actually do not have to install software, you can just use it from your internet browser. But I can still see quite a few uses of this tool to create client site components for the application.</p>
<p>So, will keep this in mind and may be one day will use it not just to play.</p>
<p><a href="http://www.rawseo.com/news/2009/05/13/how-to-turn-a-php-script-to-an-exefor-free/">Here is the link</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/05/14/windows-application-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freelance PHP positions</title>
		<link>http://www.filonov.com/blog/2009/05/06/freelance-php-positions/</link>
		<comments>http://www.filonov.com/blog/2009/05/06/freelance-php-positions/#comments</comments>
		<pubDate>Wed, 06 May 2009 16:28:41 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[freelance]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://filonov.com/blog/2009/05/06/freelance-php-positions/</guid>
		<description><![CDATA[Do you know PHP and thinking about getting some freelance job? You are not alone for sure, freelancing is a good way to get an extra income, to get started building your portfolio or to stop coming to the office and work from home.
Here is a good list of freelance positions for PHP developers:
http://workfromhomephpjobs.blogspot.com/
]]></description>
			<content:encoded><![CDATA[<p>Do you know PHP and thinking about getting some freelance job? You are not alone for sure, freelancing is a good way to get an extra income, to get started building your portfolio or to stop coming to the office and work from home.</p>
<p>Here is a good list of freelance positions for PHP developers:<br />
<a href="http://workfromhomephpjobs.blogspot.com/">http://workfromhomephpjobs.blogspot.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/05/06/freelance-php-positions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Google webmaster tools now</title>
		<link>http://www.filonov.com/blog/2009/04/30/check-google-webmaster-tools-now/</link>
		<comments>http://www.filonov.com/blog/2009/04/30/check-google-webmaster-tools-now/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 23:13:51 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://filonov.com/blog/?p=27</guid>
		<description><![CDATA[The biggest traffic source for the web site is search engines traffic. There is a lot what can be written on search engine optimization (SEO). But I just realized that often web masters or web site owners missing quite important application from the Google itself
Google Webmaster Tools
That&#8217;s a valuable data on what Google &#8220;knows&#8221; about [...]]]></description>
			<content:encoded><![CDATA[<p>The biggest traffic source for the web site is search engines traffic. There is a lot what can be written on search engine optimization (SEO). But I just realized that often web masters or web site owners missing quite important application from the Google itself</p>
<p><a href="https://www.google.com/webmasters/tools/">Google Webmaster Tools</a></p>
<p>That&#8217;s a valuable data on what Google &#8220;knows&#8221; about your web site, definetely worth checking and should be a starting point of the search engines optimization.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/04/30/check-google-webmaster-tools-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to run IE 6, 7 and 8 on the same computer</title>
		<link>http://www.filonov.com/blog/2009/04/08/how-to-run-ie-6-7-and-8-on-the-same-computer/</link>
		<comments>http://www.filonov.com/blog/2009/04/08/how-to-run-ie-6-7-and-8-on-the-same-computer/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 21:12:28 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[IE 6]]></category>
		<category><![CDATA[IE 7]]></category>
		<category><![CDATA[IE 8]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://filonov.com/blog/2009/04/08/how-to-run-ie-6-7-and-8-on-the-same-computer/</guid>
		<description><![CDATA[If you are doing web development, then you know that you need to have all recent versions of the IE browser to troubleshoot your sites. Here is one way to have them all, thanks to Edskes Software collection &#8211; just download pack and install all versions you want.
http://finalbuilds.edskes.net/iecollection.htm
]]></description>
			<content:encoded><![CDATA[<p>If you are doing web development, then you know that you need to have all recent versions of the IE browser to troubleshoot your sites. Here is one way to have them all, thanks to Edskes Software collection &#8211; just download pack and install all versions you want.</p>
<p><a href="http://finalbuilds.edskes.net/iecollection.htm">http://finalbuilds.edskes.net/iecollection.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/04/08/how-to-run-ie-6-7-and-8-on-the-same-computer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FogBugz speed issue &#8211; an example of MySQL slow queries troubleshooting</title>
		<link>http://www.filonov.com/blog/2009/04/02/fogbugz-speed-issue-an-example-of-mysql-slow-queries-troubleshooting/</link>
		<comments>http://www.filonov.com/blog/2009/04/02/fogbugz-speed-issue-an-example-of-mysql-slow-queries-troubleshooting/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 21:15:06 +0000</pubDate>
		<dc:creator>Andrei Filonov</dc:creator>
				<category><![CDATA[Web development]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://filonov.com/blog/?p=13</guid>
		<description><![CDATA[We are using FogBugz application for the bugs and support requests tracking. And it&#8217;s configured to receive support@companyname.com emails (means tons of spam). Once the database size hit approximately 20,000 requests, we started really wonder: why so slow? It looks like there was another table BugEvent which size is around 200,000 records at that time.
It [...]]]></description>
			<content:encoded><![CDATA[<p>We are using FogBugz application for the bugs and support requests tracking. And it&#8217;s configured to receive support@companyname.com emails (means tons of spam). Once the database size hit approximately 20,000 requests, we started really wonder: why so slow? It looks like there was another table BugEvent which size is around 200,000 records at that time.</p>
<p>It could be some other application, could be your own code. Doesn&#8217;t matter &#8211; just it happens, one database size grows, performance of the application is degrading.</p>
<p>First step to troubleshoot &#8211; enable slow queries log in the MySQL config file (/etc/my.cnf is popular location). Open file in editor and add lines</p>
<pre><code>log_slow_queries        = /var/log/mysql-slow.log
long_query_time = 10</code></pre>
<p>(path for the log file is totally up to you, I use MySQL 5.0*, so in other versions syntax can be different)</p>
<p>Those lines tell mysql to log all queries lasted 10 seconds or more. Restart MySQL now and wait.</p>
<p>After a while run  mysqldumpslow as root. If there are any slow queries logged, you will see summary, here is mine:</p>
<pre><code>Reading mysql slow query log from /var/log/mysql/mysql-slow.log

<strong>Count:</strong> <strong>36  Time=549.81s</strong> (19793s)  Lock=0.00s (0s)  Rows=0.0 (0)
SELECT Bug.ixBug AS ix, Bug.ixBugEventLatest AS ixChild,
       Area.nTypeAs nAreaType
FROM (Bug INNER JOIN Area ON Bug.ixArea = Area.ixArea)
WHERE ixBugEventLatest  &lt;= N
       AND ixBugEventLatest &gt;= N AND Bug.ixBug IN
          (SELECT ix FROM IndexDelta WHERE sType = 'S'
           AND fDeleted = N)
       AND -N =  -N
ORDER BY ixBugEventLatest  DESC  
LIMIT N</code></pre>
<p>Query listed above appears to take around 10 minutes to execute. Now check the tables type in the MySQL<br />
<code>mysql&gt; show table status;</code><br />
In our scenario I found that all tables are MyISAM. That means, that while query is executed (10 minutes) tables used in it will be locked for writing. So, if someone tries to update bug, they have to wait up to 10 minutes.</p>
<p>Check what MySQL engines you have:</p>
<pre><code>mysql&amp;gt; show engines;

+---------+----------+---------------------------
| Engine  | Support  | Comment                  
+---------+----------+---------------------------
| MyISAM  | DEFAULT  | Default engine as of MySQL
| MEMORY  | YES      | Hash based, stored in memory
| InnoDB  | YES      | Supports transactions, row-
...</code></pre>
<p>If InnoDB is supported, then all what has to be done to speed up application is switching to InnoDB in this situation. This will not make query above run any faster, but, that will not lock the whole table for the time query is running. There are some benefits of MyISAM table type (well, it&#8217;s faster!), so you may don&#8217;t want to convert all tables to InnoDB at this point. But large tables with concurrent updates and reads will benefit.</p>
<p>If InnoDB is not supported, it can be turned on in MySQL configuration file, just comment out skip-innodb line.</p>
<p>In case of FogBugz I found the following tables to be worst offenders:<br />
Bug, BugEvent, BugRelation, SorterToken, TokenAssociation.</p>
<p>To convert those, use:<br />
<code>mysql&gt; alter table Bug engine=InnoDB;</code><br />
After conversion performance of the application increased immediately, as there are no more locks on popular tables.</p>
<p>There are additional benefits of InnoDB engine, such as foreign keys. Read more on InnoDB:</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/innodb.html">http://dev.mysql.com/doc/refman/5.0/en/innodb.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.filonov.com/blog/2009/04/02/fogbugz-speed-issue-an-example-of-mysql-slow-queries-troubleshooting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
