<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Downtime</title>
	<atom:link href="http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/</link>
	<description>Random samplings from a universe of ideas.</description>
	<lastBuildDate>Mon, 13 Feb 2012 20:29:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Bob Munck</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28837</link>
		<dc:creator>Bob Munck</dc:creator>
		<pubDate>Tue, 12 Jun 2007 01:48:01 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28837</guid>
		<description>Ignore all these suggestions!  I&#039;ve been in the field for forty years, and you had it exactly right at the beginning:&lt;blockquote&gt;&lt;strong&gt;Maybe it will fix itself.&lt;/strong&gt;&lt;/blockquote&gt;That has always worked for me, though some of the worse FORTRAN II bugs didn&#039;t fix themselves until all the hardware had become obsolete.</description>
		<content:encoded><![CDATA[<p>Ignore all these suggestions!  I&#8217;ve been in the field for forty years, and you had it exactly right at the beginning:<br />
<blockquote><strong>Maybe it will fix itself.</strong></p></blockquote>
<p>That has always worked for me, though some of the worse FORTRAN II bugs didn&#8217;t fix themselves until all the hardware had become obsolete.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dylan</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28840</link>
		<dc:creator>Dylan</dc:creator>
		<pubDate>Mon, 11 Jun 2007 23:34:37 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28840</guid>
		<description>Check your usage, in terms of number of pageviews - i found (and have started reading) this blog due to an article on slashdot, which commands a hefty readership. I can&#039;t recall if you were directly linked but I still found you - others would have too.

It may be you&#039;re just another victim of your own popularity and you need to host your blog somewhere that allows you to use some more resources - although i must say that optimisation can often stave off such moves for some time, a well thought out database can use a fraction of the resources.

I did see a good blog article on this from a bloke running a large south-african web application, but buggered if I can find it again :(</description>
		<content:encoded><![CDATA[<p>Check your usage, in terms of number of pageviews &#8211; i found (and have started reading) this blog due to an article on slashdot, which commands a hefty readership. I can&#8217;t recall if you were directly linked but I still found you &#8211; others would have too.</p>
<p>It may be you&#8217;re just another victim of your own popularity and you need to host your blog somewhere that allows you to use some more resources &#8211; although i must say that optimisation can often stave off such moves for some time, a well thought out database can use a fraction of the resources.</p>
<p>I did see a good blog article on this from a bloke running a large south-african web application, but buggered if I can find it again <img src='http://blogs.discovermagazine.com/cosmicvariance/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xantox</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28839</link>
		<dc:creator>xantox</dc:creator>
		<pubDate>Mon, 11 Jun 2007 20:15:29 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28839</guid>
		<description>To optimize, you may also try some of the following:

â€¢ if possible, upgrade to the latest WP version or at least 2.1;
â€¢ if your host allows, enable the &lt;a href=&quot;http://www.techiecorner.com/45/turn-on-mysql-query-cache-to-speed-up-mysql-query-performance/&quot; rel=&quot;nofollow&quot;&gt;mySQL query cache&lt;/a&gt; (and possibly also use &lt;a href=&quot;http://txfx.net/files/wordpress/post-query-accelerator.phps &quot; rel=&quot;nofollow&quot;&gt;this plugin&lt;/a&gt;)
â€¢ enable the Wordpress caching system by adding this line to wp-config.php:
  define( &#039;ENABLE_CACHE&#039;, true );
(and make sure that wp-content/cache is writable or has 777 permission).
â€¢ For a stronger cache, try &lt;a href=&quot;http://mnm.uib.es/gallir/wp-cache-2/&quot; rel=&quot;nofollow&quot;&gt;wp-cache2&lt;/a&gt; which staticizes the whole site.</description>
		<content:encoded><![CDATA[<p>To optimize, you may also try some of the following:</p>
<p>â€¢ if possible, upgrade to the latest WP version or at least 2.1;<br />
â€¢ if your host allows, enable the <a href="http://www.techiecorner.com/45/turn-on-mysql-query-cache-to-speed-up-mysql-query-performance/" rel="nofollow">mySQL query cache</a> (and possibly also use <a href="http://txfx.net/files/wordpress/post-query-accelerator.phps " rel="nofollow">this plugin</a>)<br />
â€¢ enable the WordPress caching system by adding this line to wp-config.php:<br />
  define( &#8216;ENABLE_CACHE&#8217;, true );<br />
(and make sure that wp-content/cache is writable or has 777 permission).<br />
â€¢ For a stronger cache, try <a href="http://mnm.uib.es/gallir/wp-cache-2/" rel="nofollow">wp-cache2</a> which staticizes the whole site.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cosmic Variance account is suspended on Bluehost.com &#171; Bob Dudesky</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28838</link>
		<dc:creator>Cosmic Variance account is suspended on Bluehost.com &#171; Bob Dudesky</dc:creator>
		<pubDate>Mon, 11 Jun 2007 16:30:09 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28838</guid>
		<description>[...] like some of the comments to Downtime might be [...]</description>
		<content:encoded><![CDATA[<p>[...] like some of the comments to Downtime might be [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xantox</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28836</link>
		<dc:creator>xantox</dc:creator>
		<pubDate>Mon, 11 Jun 2007 12:36:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28836</guid>
		<description>I believe that you just have a lot of visitors and that your host has a strict quota requirement, better suited to simpler or low-traffic sites. The solution is probably to ask them increase the quota, or change host.</description>
		<content:encoded><![CDATA[<p>I believe that you just have a lot of visitors and that your host has a strict quota requirement, better suited to simpler or low-traffic sites. The solution is probably to ask them increase the quota, or change host.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Nichols</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28835</link>
		<dc:creator>Alex Nichols</dc:creator>
		<pubDate>Mon, 11 Jun 2007 05:59:44 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28835</guid>
		<description>Compacting the database would normally improve its efficiency a lot.
I wonder if the software you use permanently deletes unapproved comments, or simply leaves them in there flagged?

The Query is checking the flag &#039;comment_approved&#039;  as part of a boolean evaluation with 3 conditions.  This is a very CPU intensive operation.

If for example you are receiving lots of unwanted comments and these remain in the database it might slow it down to the point where it exceeds the providers quota.  Possibly something that could be exploited in denial of service attacks.</description>
		<content:encoded><![CDATA[<p>Compacting the database would normally improve its efficiency a lot.<br />
I wonder if the software you use permanently deletes unapproved comments, or simply leaves them in there flagged?</p>
<p>The Query is checking the flag &#8216;comment_approved&#8217;  as part of a boolean evaluation with 3 conditions.  This is a very CPU intensive operation.</p>
<p>If for example you are receiving lots of unwanted comments and these remain in the database it might slow it down to the point where it exceeds the providers quota.  Possibly something that could be exploited in denial of service attacks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28834</link>
		<dc:creator>Tim</dc:creator>
		<pubDate>Sun, 10 Jun 2007 22:42:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28834</guid>
		<description>Perhaps your hosting service would be willing to look at some of the SQL queries for you and check if the right fields are indexed in the database? After all, it is their server time that you are using if the database isn&#039;t structured well.</description>
		<content:encoded><![CDATA[<p>Perhaps your hosting service would be willing to look at some of the SQL queries for you and check if the right fields are indexed in the database? After all, it is their server time that you are using if the database isn&#8217;t structured well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28833</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Sun, 10 Jun 2007 22:09:57 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28833</guid>
		<description>Updating the &quot;latest comments&quot; plugin (which led to the above error) doesn&#039;t seem to have helped, nor has disabling it entirely.  I&#039;ve even optimized the databases, for what it&#039;s worth.  But the problem persists.</description>
		<content:encoded><![CDATA[<p>Updating the &#8220;latest comments&#8221; plugin (which led to the above error) doesn&#8217;t seem to have helped, nor has disabling it entirely.  I&#8217;ve even optimized the databases, for what it&#8217;s worth.  But the problem persists.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrea</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28832</link>
		<dc:creator>Andrea</dc:creator>
		<pubDate>Sun, 10 Jun 2007 21:52:54 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28832</guid>
		<description>One more thing that could be slowing this down is the lack of any date restriction; it&#039;s retrieving all non-pingback, non-trackback comments since the beginning of time.   Given the location as you describe it (to generate the &quot;lastest sidebar&quot; list), if you have any control over the query you may want to tweak that.    Then again I may be biased by working in an environment where all queries are required to have a closed daterange due to the extreme volume of data, so that may actually not help all that much here.</description>
		<content:encoded><![CDATA[<p>One more thing that could be slowing this down is the lack of any date restriction; it&#8217;s retrieving all non-pingback, non-trackback comments since the beginning of time.   Given the location as you describe it (to generate the &#8220;lastest sidebar&#8221; list), if you have any control over the query you may want to tweak that.    Then again I may be biased by working in an environment where all queries are required to have a closed daterange due to the extreme volume of data, so that may actually not help all that much here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Knop</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28831</link>
		<dc:creator>Rob Knop</dc:creator>
		<pubDate>Sun, 10 Jun 2007 14:18:31 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28831</guid>
		<description>When I was actively using wordpress, I think it did keep all of the messages that got blocked as spam.  I think you can configure it not to do this.  One thing that does happen is that your comment tables will get *huge* with spam.  That not only uses up disk space, but will start to slow down queries like this one.

I would hesitate to give you any actual sql to do anything about this here, but you might be able to check your wordpress config to see if you can do anything about it there.

What I did myself was go in every so often and delete all the spam; it&#039;s a quick SQL command, and I *am* a database manager in addition to all those other things....

-Rob</description>
		<content:encoded><![CDATA[<p>When I was actively using wordpress, I think it did keep all of the messages that got blocked as spam.  I think you can configure it not to do this.  One thing that does happen is that your comment tables will get *huge* with spam.  That not only uses up disk space, but will start to slow down queries like this one.</p>
<p>I would hesitate to give you any actual sql to do anything about this here, but you might be able to check your wordpress config to see if you can do anything about it there.</p>
<p>What I did myself was go in every so often and delete all the spam; it&#8217;s a quick SQL command, and I *am* a database manager in addition to all those other things&#8230;.</p>
<p>-Rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arun</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28830</link>
		<dc:creator>Arun</dc:creator>
		<pubDate>Sun, 10 Jun 2007 04:14:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28830</guid>
		<description>A table is (an implementation of a set-theoretic) relation.
E.g. { (post1, comment1), (post1, comment2), (post2,comment3), (post1,comment4)}

Paging is how a computer manages data transfers between main memory and disk. To quote: &quot;The operating system copies a certain number of pages from your storage device to main memory. When a program needs a page that is not in main memory, the operating system copies the required page into memory and copies another page back to the disk. One says that the operating system pages the data. Each time a page is needed that is not currently in memory, a page fault occurs.&quot;

Each page fault greatly slows the program down.

A index is an implementation of a quick lookup in a database table, kind of like a book index.

A join is a Cartesian product of two relations, followed by some filtering condition.

E.g., given relations R1 = { (post#, comment#),...} and R2 = { ( comment#, author),....} a join would be used to find all posts with comments by a particular author, as the subset of R1 x R2 where R1.comment# = R2.comment# and
R2.author = .

I haven&#039;t found a good exposition of the relational algebra/relational calculus on the web, but for any physicist, about 20 minutes with that abstraction will permanently demystify relational databases.  The problem is that usually databases are taught to people who are less able to deal with abstraction and so the web presentations of the relational algebra are verbose.

Another 20 minutes on how engineers have dealt with the fact of the relative slowness of main storage relative main memory and slowness of main memory with respect to CPU will clear up the rest.</description>
		<content:encoded><![CDATA[<p>A table is (an implementation of a set-theoretic) relation.<br />
E.g. { (post1, comment1), (post1, comment2), (post2,comment3), (post1,comment4)}</p>
<p>Paging is how a computer manages data transfers between main memory and disk. To quote: &#8220;The operating system copies a certain number of pages from your storage device to main memory. When a program needs a page that is not in main memory, the operating system copies the required page into memory and copies another page back to the disk. One says that the operating system pages the data. Each time a page is needed that is not currently in memory, a page fault occurs.&#8221;</p>
<p>Each page fault greatly slows the program down.</p>
<p>A index is an implementation of a quick lookup in a database table, kind of like a book index.</p>
<p>A join is a Cartesian product of two relations, followed by some filtering condition.</p>
<p>E.g., given relations R1 = { (post#, comment#),&#8230;} and R2 = { ( comment#, author),&#8230;.} a join would be used to find all posts with comments by a particular author, as the subset of R1 x R2 where R1.comment# = R2.comment# and<br />
R2.author = .</p>
<p>I haven&#8217;t found a good exposition of the relational algebra/relational calculus on the web, but for any physicist, about 20 minutes with that abstraction will permanently demystify relational databases.  The problem is that usually databases are taught to people who are less able to deal with abstraction and so the web presentations of the relational algebra are verbose.</p>
<p>Another 20 minutes on how engineers have dealt with the fact of the relative slowness of main storage relative main memory and slowness of main memory with respect to CPU will clear up the rest.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quest &#187; Blog Archive &#187; Downtime</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28829</link>
		<dc:creator>Quest &#187; Blog Archive &#187; Downtime</dc:creator>
		<pubDate>Sun, 10 Jun 2007 03:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28829</guid>
		<description>[...] ÐžÑ€Ð¸Ð³Ð¸Ð½Ð°Ð» ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð¾Ñ‚ TPR  Ñ‚ÑƒÑ‚&#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] ÐžÑ€Ð¸Ð³Ð¸Ð½Ð°Ð» ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð¾Ñ‚ TPR  Ñ‚ÑƒÑ‚&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alberto</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28826</link>
		<dc:creator>Alberto</dc:creator>
		<pubDate>Sat, 09 Jun 2007 20:39:25 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28826</guid>
		<description>you are an astronomer. Doctors save people.... At most we bore them.</description>
		<content:encoded><![CDATA[<p>you are an astronomer. Doctors save people&#8230;. At most we bore them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jugalator</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28822</link>
		<dc:creator>Jugalator</dc:creator>
		<pubDate>Sat, 09 Jun 2007 20:38:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28822</guid>
		<description>... and actually, Brian&#039;s insights in SQL optimizations may have been a bit helpful for me too, building some SQL queries for a geographical database on a networked Oracle database. I.e. lots of unnecessary network traffic if the queries aren&#039;t optimized well enough. I&#039;ll especially keep his &quot;bit&quot; trick into mind, because I *do* have control over my queries.  :)</description>
		<content:encoded><![CDATA[<p>&#8230; and actually, Brian&#8217;s insights in SQL optimizations may have been a bit helpful for me too, building some SQL queries for a geographical database on a networked Oracle database. I.e. lots of unnecessary network traffic if the queries aren&#8217;t optimized well enough. I&#8217;ll especially keep his &#8220;bit&#8221; trick into mind, because I *do* have control over my queries.  <img src='http://blogs.discovermagazine.com/cosmicvariance/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jugalator</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28824</link>
		<dc:creator>Jugalator</dc:creator>
		<pubDate>Sat, 09 Jun 2007 20:34:22 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28824</guid>
		<description>Awesome! :) I hope it helped -- this blog is much more interesting than reading a CPU quota error. Yes, really! ;)</description>
		<content:encoded><![CDATA[<p>Awesome! <img src='http://blogs.discovermagazine.com/cosmicvariance/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I hope it helped &#8212; this blog is much more interesting than reading a CPU quota error. Yes, really! <img src='http://blogs.discovermagazine.com/cosmicvariance/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28823</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Sat, 09 Jun 2007 18:47:05 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28823</guid>
		<description>Brian, thanks, that was actually very helpful.  I tracked down where that line was coming from, and it was actually in the &quot;latest comments&quot; plugin that shows the recent comments up on the sidebar.  Then I went and looked for the most recent version of that plugin, and found that they had indeed changed that line to remove the wildcards.  So I&#039;ve installed the updated version; let&#039;s see if that makes a difference.</description>
		<content:encoded><![CDATA[<p>Brian, thanks, that was actually very helpful.  I tracked down where that line was coming from, and it was actually in the &#8220;latest comments&#8221; plugin that shows the recent comments up on the sidebar.  Then I went and looked for the most recent version of that plugin, and found that they had indeed changed that line to remove the wildcards.  So I&#8217;ve installed the updated version; let&#8217;s see if that makes a difference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Melancon</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28820</link>
		<dc:creator>Brian Melancon</dc:creator>
		<pubDate>Sat, 09 Jun 2007 18:27:15 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28820</guid>
		<description>This is the slow part:

&quot;comment_type NOT LIKE &#039;%pingback%&#039; AND comment_type NOT LIKE &#039;%trackback%&#039;&quot;

The % is a wild card.  It appears as if the comment type is embedded in a string of characters in one of the database field.  The query looks through all the &quot;comment_type&quot; fields, it then looks for the letters &quot;pingback&quot; anywhere in that field.  If it finds &quot;pingback&quot; it then looks for &quot;trackback&quot;.  If it also finds &quot;trackback&quot; then it excludes that row from the result set.

For what this query logic appears to be doing, this is a poor way to go about doing it for a couple of reasons.  First, the wild card searches are relatively slow.  Second, it&#039;s doing the wild card searches on items which will be excluded from the final results. This means it has to read the result row, then execute the pattern matching logic, then exclude the matches.

A better way is to do the search for what you want to return.  In other words, &quot;Give me only these results&quot; instead of &quot;Give me everything, then exclude the things that match &#039;this&#039; and &#039;that&#039;&quot;.

Another way to speed things up is to use some sort of flag to mark the different types of items you&#039;d be searching for regularly. If, for example, you had comments of type &quot;pingback&quot;, &quot;trackback&quot;, and &quot;regular&quot; and you assigned them the integers 1, 2, and 4 (I skipped three for a reason)  and placed those integers in the comment type field, you could then do a query like &quot;Give me everything where comment_type = 4&quot;.  This would be much, much faster.

Why did I skip three?  There is a neat little trick you can do when you use flags based on powers of two (1, 2, 4, 8, 16, 32, 64, etc...).  If you want all comment_types that are &quot;pingback&quot; OR &quot;regular&quot; ( 1 + 4 = 5 ) you can use some boolean algebra to do a quick query for those also. &quot;Give me everything where comment_type logically ANDed with 5 is TRUE&quot;

It looks like WordPress needs some redesign.  Depending on the core design, it may be a trivial fix or a complex overhaul. These sorts of things can turn into a string of dominoes. It also looks like you&#039;re not in a position to do anything about it.</description>
		<content:encoded><![CDATA[<p>This is the slow part:</p>
<p>&#8220;comment_type NOT LIKE &#8216;%pingback%&#8217; AND comment_type NOT LIKE &#8216;%trackback%&#8217;&#8221;</p>
<p>The % is a wild card.  It appears as if the comment type is embedded in a string of characters in one of the database field.  The query looks through all the &#8220;comment_type&#8221; fields, it then looks for the letters &#8220;pingback&#8221; anywhere in that field.  If it finds &#8220;pingback&#8221; it then looks for &#8220;trackback&#8221;.  If it also finds &#8220;trackback&#8221; then it excludes that row from the result set.</p>
<p>For what this query logic appears to be doing, this is a poor way to go about doing it for a couple of reasons.  First, the wild card searches are relatively slow.  Second, it&#8217;s doing the wild card searches on items which will be excluded from the final results. This means it has to read the result row, then execute the pattern matching logic, then exclude the matches.</p>
<p>A better way is to do the search for what you want to return.  In other words, &#8220;Give me only these results&#8221; instead of &#8220;Give me everything, then exclude the things that match &#8216;this&#8217; and &#8216;that&#8217;&#8221;.</p>
<p>Another way to speed things up is to use some sort of flag to mark the different types of items you&#8217;d be searching for regularly. If, for example, you had comments of type &#8220;pingback&#8221;, &#8220;trackback&#8221;, and &#8220;regular&#8221; and you assigned them the integers 1, 2, and 4 (I skipped three for a reason)  and placed those integers in the comment type field, you could then do a query like &#8220;Give me everything where comment_type = 4&#8243;.  This would be much, much faster.</p>
<p>Why did I skip three?  There is a neat little trick you can do when you use flags based on powers of two (1, 2, 4, 8, 16, 32, 64, etc&#8230;).  If you want all comment_types that are &#8220;pingback&#8221; OR &#8220;regular&#8221; ( 1 + 4 = 5 ) you can use some boolean algebra to do a quick query for those also. &#8220;Give me everything where comment_type logically ANDed with 5 is TRUE&#8221;</p>
<p>It looks like WordPress needs some redesign.  Depending on the core design, it may be a trivial fix or a complex overhaul. These sorts of things can turn into a string of dominoes. It also looks like you&#8217;re not in a position to do anything about it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28821</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sat, 09 Jun 2007 17:39:07 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28821</guid>
		<description>I&#039;m given to understand the new version of Wordpress is optimised somewhat. I don&#039;t know what version you&#039;re running, but getting the latest would seem sensible.

If CPU time is a problem, it might also be worth replacing Wordpess&#039; search box with a Google site search. It wouldn&#039;t look as in-keeping with the main site, but it&#039;d shift a large amount of CPU power from your servers to Google&#039;s, who don&#039;t seem to mind.

It probably wouldn&#039;t solve the problem, but it&#039;d certainly reduce it.</description>
		<content:encoded><![CDATA[<p>I&#8217;m given to understand the new version of WordPress is optimised somewhat. I don&#8217;t know what version you&#8217;re running, but getting the latest would seem sensible.</p>
<p>If CPU time is a problem, it might also be worth replacing Wordpess&#8217; search box with a Google site search. It wouldn&#8217;t look as in-keeping with the main site, but it&#8217;d shift a large amount of CPU power from your servers to Google&#8217;s, who don&#8217;t seem to mind.</p>
<p>It probably wouldn&#8217;t solve the problem, but it&#8217;d certainly reduce it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28825</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Sat, 09 Jun 2007 17:34:17 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28825</guid>
		<description>Thanks for the comments, but just to emphasize:  I have no idea what you are talking about.  I don&#039;t know what a table is, what paging is, what indexing is.  And I sort of don&#039;t want to know, although I do want this problem to go away.

Changing blogging software is very unlikely, as it would require a complete reconstruction of the site, exactly what we don&#039;t want to do.</description>
		<content:encoded><![CDATA[<p>Thanks for the comments, but just to emphasize:  I have no idea what you are talking about.  I don&#8217;t know what a table is, what paging is, what indexing is.  And I sort of don&#8217;t want to know, although I do want this problem to go away.</p>
<p>Changing blogging software is very unlikely, as it would require a complete reconstruction of the site, exactly what we don&#8217;t want to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken Egozi</title>
		<link>http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/comment-page-1/#comment-28827</link>
		<dc:creator>Ken Egozi</dc:creator>
		<pubDate>Sat, 09 Jun 2007 17:24:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.discovermagazine.com/cosmicvariance/2007/06/09/downtime/#comment-28827</guid>
		<description>@Guillermo, it seams that the query returns the post title, so the JOIN to posts table is needed.
Why do you need to retrieve all the posts? are you doing paging stuff in the blog app itself rather than in the DB?

Anyway, even if the query logic is indeed needed, there are more problems.
1. The comment_type field might not be indexed.
2. If applicable, I&#039;d loose the % on the search terms (if the comment_type field includes the types &#039;pingback&#039; and &#039;trackback&#039;).
3. Also verify that the field comment_approved is indexed.


If you cannot revise the application and/or the DB, then I suggest you switch to another blogging engine, rather than switching the host.</description>
		<content:encoded><![CDATA[<p>@Guillermo, it seams that the query returns the post title, so the JOIN to posts table is needed.<br />
Why do you need to retrieve all the posts? are you doing paging stuff in the blog app itself rather than in the DB?</p>
<p>Anyway, even if the query logic is indeed needed, there are more problems.<br />
1. The comment_type field might not be indexed.<br />
2. If applicable, I&#8217;d loose the % on the search terms (if the comment_type field includes the types &#8216;pingback&#8217; and &#8216;trackback&#8217;).<br />
3. Also verify that the field comment_approved is indexed.</p>
<p>If you cannot revise the application and/or the DB, then I suggest you switch to another blogging engine, rather than switching the host.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk

Served from: blogs.discovermagazine.com @ 2012-02-13 20:35:43 -->
