<?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>MaisonBisson.com &#187; fixed</title>
	<atom:link href="http://maisonbisson.com/blog/post/tag/fixed/feed/" rel="self" type="application/rss+xml" />
	<link>http://maisonbisson.com</link>
	<description>A bunch of stuff I would have emailed you about.</description>
	<lastBuildDate>Sat, 14 Nov 2009 20:14:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress to_ping Query Optimization</title>
		<link>http://maisonbisson.com/blog/post/12034/wordpress-to_ping-query-optimization/</link>
		<comments>http://maisonbisson.com/blog/post/12034/wordpress-to_ping-query-optimization/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 17:34:26 +0000</pubDate>
		<dc:creator>Casey Bisson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[query optimization]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://maisonbisson.com/blog/post/12034/wordpress-to_ping-query-optimization-2</guid>
		<description><![CDATA[
The WordPress team has taken up the issue of performance optimization pretty seriously, and I look forward to the fruits of their efforts, but I&#8217;m also casting a critical eye on my own code. Thanks to caching and a hugely optimized query architecture, Scriblio is now performing better than ever, and I&#8217;m now looking at [...]]]></description>
			<content:encoded><![CDATA[<abbr class="unapi-id" title="maisonbisson-12034"><!-- &nbsp; --></abbr>
<p>The WordPress team has taken up the issue of <a href="http://boren.nu/archives/2007/11/13/wordpress-24-performance-profiling/">performance optimization</a> pretty seriously, and I look forward to the fruits of their efforts, but I&#8217;m also casting a critical eye on my own code. Thanks to caching and a hugely optimized query architecture, Scriblio is now performing better than ever, and I&#8217;m now looking at the next tier of problems.</p>
<p>First among them is a WordPress query that runs to find which posts have pingbacks or trackbacks waiting to be processed. As it was originally written, it looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$trackbacks</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
	 SELECT ID 
	 FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> 
	 WHERE CHAR_LENGTH(TRIM(to_ping)) &gt; 7 
	 AND post_status = 'publish'
	&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The problem is that the query requires a full table scan, and it can&#8217;t be optimized simply by creating an index on <code>to_ping</code> because <code>CHAR_LENGTH(TRIM(to_ping)) > 7</code> requires inspecting every row and applying the functions before the result can be tested. As written, the query could take as long as 15 minutes to execute on a busy table of 350,000 rows.</p>
<p>Once I read through the code and determined that it&#8217;s very unlikely that cruft would be left in <code>to_ping</code>, or that any that was there would get removed once processed through the ping functions, I decided to try the query below. (Hat tip also to <a href="http://andy.wordpress.com/" title="Andy Skelton">Andy Skelton</a> for sanity checking my reading of the code.)</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$trackbacks</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
	 SELECT ID 
	 FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span> 
	 WHERE to_ping &lt;&gt; '' 
	 AND post_status = 'publish'
	&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A <a href="http://trac.wordpress.org/ticket/5649" title="#5649 (to_ping query optimization) - WordPress Trac - Trac">trac ticket</a> has been created and <a href="http://trac.wordpress.org/attachment/ticket/5649/comment_to_ping.diff" title="#5649: comment_to_ping.diff - WordPress Trac - Trac">patch added</a>, but despite the optimized query, a table as large as I&#8217;m working with probably needs an index to keep things running smoothly. So here&#8217;s what I&#8217;ve got:</p>
<p><code>KEY ping_status ( to_ping(1), post_status )</code></p>
<p>I&#8217;ve not yet confirmed that this is the most optimal index, but queries now take a fraction of a second to complete.</p>
]]></content:encoded>
			<wfw:commentRss>http://maisonbisson.com/blog/post/12034/wordpress-to_ping-query-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5&#8217;s SimpleXML Now Passes CDATA Content</title>
		<link>http://maisonbisson.com/blog/post/11257/php5s-simplexml-now-passes-cdata-content/</link>
		<comments>http://maisonbisson.com/blog/post/11257/php5s-simplexml-now-passes-cdata-content/#comments</comments>
		<pubDate>Wed, 12 Apr 2006 16:03:09 +0000</pubDate>
		<dc:creator>Casey Bisson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[cdata]]></category>
		<category><![CDATA[cdata in php]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[parsing rss]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[simplexml]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://maisonbisson.com/blog/post/11257/</guid>
		<description><![CDATA[
I didn&#8217;t hear big announcement of it, but deep in the docs (? PHP 5.1.0) you&#8217;ll find a note about additional Libxml parameters. In there you&#8217;ll learn about “LIBXML_NOCDATA,” and it works like this:
simplexml_load_string($xmlraw,&#160;'SimpleXMLElement',&#160;LIBXML_NOCDATA);
Without that option (and with all previous versions of PHP/SimpleXML), SimpleXML just ignores any < ![CDATA[...]]&#62; &#8216;escaped&#8217; content, such as you&#8217;ll find [...]]]></description>
			<content:encoded><![CDATA[<abbr class="unapi-id" title="maisonbisson-11257"><!-- &nbsp; --></abbr>
<p>I didn&#8217;t hear big announcement of it, but <a href="http://us3.php.net/manual/en/function.simplexml-load-string.php">deep in the docs</a> (? PHP 5.1.0) you&#8217;ll find a note about <a href="http://us3.php.net/manual/en/ref.libxml.php#libxml.constants" title="additional Libxml parameters">additional Libxml parameters</a>. In there you&#8217;ll learn about “LIBXML_NOCDATA,” and it works like this:</p>
<blockquote><p><code style="display: block; text-align: left; overflow: scroll;">simplexml_load_string($xmlraw,&nbsp;'SimpleXMLElement',&nbsp;LIBXML_NOCDATA);</code></p></blockquote>
<p>Without that option (and with all previous versions of PHP/SimpleXML), SimpleXML just ignores any < ![CDATA[...]]&gt; &#8216;escaped&#8217; content, such as you&#8217;ll find in most every blog feed.</p>
<p><tags>cdata, cdata in php, fixed, parsing rss, php, php5, rss, simplexml, xml</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://maisonbisson.com/blog/post/11257/php5s-simplexml-now-passes-cdata-content/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>