<?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; behavior</title>
	<atom:link href="http://maisonbisson.com/blog/post/tag/behavior/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 + Invalid URLs = Extra Database Queries</title>
		<link>http://maisonbisson.com/blog/post/12035/wordpress-invalid-urls-extra-database-queries/</link>
		<comments>http://maisonbisson.com/blog/post/12035/wordpress-invalid-urls-extra-database-queries/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 13:38:13 +0000</pubDate>
		<dc:creator>Casey Bisson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[permalinks]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://maisonbisson.com/blog/post/12035/wordpress-invalid-urls-extra-database-queries</guid>
		<description><![CDATA[
After reporting weirdness last week I finally sat down with a completely clean and virgin install of WordPress 2.3.2 and traced what happens when you make a permalink request for a non-existent URL.
Here are two sets of URLs to use as examples and context:

These are valid URLs:

http://site.org/archives/101
http://site.org/page-name


These are _not_ valid URLs:

http://site.org/archivezorz/101
http://site.org/favicon.ico



Valid URLs get parsed, the [...]]]></description>
			<content:encoded><![CDATA[<abbr class="unapi-id" title="maisonbisson-12035"><!-- &nbsp; --></abbr>
<p>After <a href="http://comox.textdrive.com/pipermail/wp-hackers/2008-January/017144.html">reporting weirdness last week</a> I finally sat down with a completely clean and virgin install of WordPress 2.3.2 and traced what happens when you make a permalink request for a non-existent URL.</p>
<p>Here are two sets of URLs to use as examples and context:</p>
<ul>
<li>These are valid URLs:
<ul>
<li>http://site.org/archives/101</li>
<li>http://site.org/page-name</li>
</ul>
</li>
<li>These are _not_ valid URLs:
<ul>
<li>http://site.org/archivezorz/101</li>
<li>http://site.org/favicon.ico</li>
</ul>
</li>
</ul>
<p>Valid URLs get parsed, the expected MySQL queries get executed, and the results are processed and returned to the browser. Normal. The problem is that invalid URLs that get sent through WordPress still result in a query like the following being executed on the database. What?</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">SELECT</span> <span style="color: #990099; font-weight: bold;">SQL_CALC_FOUND_ROWS</span>  test_posts.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">FROM</span> test_posts  <span style="color: #990099; font-weight: bold;">WHERE</span> <span style="color: #008080;">1</span><span style="color: #CC0099;">=</span><span style="color: #008080;">1</span>  <span style="color: #CC0099; font-weight: bold;">AND</span> post_type <span style="color: #CC0099;">=</span> <span style="color: #008000;">'post'</span> <span style="color: #CC0099; font-weight: bold;">AND</span> <span style="color: #FF00FF;">&#40;</span>post_status <span style="color: #CC0099;">=</span> <span style="color: #008000;">'pub
lish'</span> <span style="color: #CC0099; font-weight: bold;">OR</span> post_status <span style="color: #CC0099;">=</span> <span style="color: #008000;">'private'</span><span style="color: #FF00FF;">&#41;</span>  <span style="color: #990099; font-weight: bold;">ORDER BY</span> post_date <span style="color: #990099; font-weight: bold;">DESC</span> <span style="color: #990099; font-weight: bold;">LIMIT</span> <span style="color: #008080;">0</span><span style="color: #000033;">,</span> <span style="color: #008080;">10</span></pre></div></div>

<p>That is, even after a URL is sent through <code>WP->parse_request()</code> and found to be invalid/404, WordPress marches on to <code>WP->query_posts()</code> and hits the database with a generic request for the X most recent posts. And because this is executed for every 404, it actually results in a lot of database activity.</p>
<p>In most cases MySQL has cached the result, and so it poses a minimal load on the server. And even if the cache is stale, for most sites it&#8217;s not a particularly resource intensive query.</p>
<p>But, if you&#8217;ve got <a href="http://library.plymouth.edu/browse/?subj=20th+century">350,000 rows in the posts table</a>, it&#8217;s incredibly resource intensive to order all those posts on the <code>post_date</code> (<code>datetime</code>) column. I&#8217;ve seen hundreds of them pile up and take <em>forever</em> to complete after writes to the table. It&#8217;s sufferable if write activity on the posts table is very low, but that&#8217;s not something I want to hope for.</p>
<p>So <a href="http://comox.textdrive.com/pipermail/wp-hackers/2008-January/017264.html">my question to the wp-hackers community</a> is: Do we actually want to execute that query for every 404 under normal circumstances? If not, is the following (or something like it) the stupidest solution?</p>
<p>In <a href="http://svn.automattic.com/wordpress/tags/2.3.2/wp-includes/classes.php">wp-includes/classes.php</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">function</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_the_query</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">build_query_string</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// return if the request URI is a 404</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">did_permalink</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'error'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'404'</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$wp_the_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query_vars</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The above works, but there&#8217;s probably a better way to write it.</p>
]]></content:encoded>
			<wfw:commentRss>http://maisonbisson.com/blog/post/12035/wordpress-invalid-urls-extra-database-queries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Bathroom Reader</title>
		<link>http://maisonbisson.com/blog/post/11008/bathroom-technology/</link>
		<comments>http://maisonbisson.com/blog/post/11008/bathroom-technology/#comments</comments>
		<pubDate>Sat, 10 Dec 2005 17:44:20 +0000</pubDate>
		<dc:creator>Casey Bisson</dc:creator>
				<category><![CDATA[Libraries & Networked Information]]></category>
		<category><![CDATA[Questionable...funny. Pointless.]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[bathroom]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[Center for the Digital Future]]></category>
		<category><![CDATA[computer use]]></category>
		<category><![CDATA[in the bathroom]]></category>
		<category><![CDATA[in the can]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[newspaper]]></category>
		<category><![CDATA[on the throne]]></category>
		<category><![CDATA[report]]></category>
		<category><![CDATA[research]]></category>
		<category><![CDATA[restroom]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://maisonbisson.com/blog/?p=11008</guid>
		<description><![CDATA[
Somebody at Gizmodo found this Agence France-Presse story about the intersection of American surfing and bathroom habits in The Hindustan Times. It&#8217;s based on a report by the USC Annenberg School&#8217;s Center for the Digital Future. For five years running now, the center has tracked internet use (and non-use) in a 2,000 household representative sample [...]]]></description>
			<content:encoded><![CDATA[<abbr class="unapi-id" title="maisonbisson-11008"><!-- &nbsp; --></abbr>
<p>Somebody at <a href="http://us.gizmodo.com/gadgets/home-entertainment/get-unwired-and-unload-141254.php" title="Get Unwired and Unload - Gizmodo">Gizmodo</a> found this <a href="http://www.afp.com/english/afp/">Agence France-Presse</a> story about the intersection of American surfing and bathroom habits in <a href="http://www.hindustantimes.com/news/181_1564921,00030010.htm" title="Net follows Americans everywhere! : HindustanTimes.com">The Hindustan Times</a>. It&#8217;s based on <a href="http://www.digitalcenter.org/pages/current_report.asp?intGlobalId=19">a report</a> by the <a href="http://ascweb.usc.edu/home.php">USC Annenberg School</a>&#8217;s <a href="http://www.digitalcenter.org/">Center for the Digital Future</a>. For five years running now, the center has <a href="http://www.digitalcenter.org/pages/site_content.asp?intGlobalId=22">tracked internet use</a> (and non-use) in a 2,000 household representative sample of America (choosing a new sample each year).</p>
<p>This year, <a href="http://www.hindustantimes.com/news/181_1564921,00030010.htm">researchers found</a>: <strong>&#8220;Over half of those who used Wi-fi had used it in the bathroom.&#8221;</strong></p>
<p>Gizmodo is going a little farther than I&#8217;d initially care to by asking readers to comment on their behavior, but I found <a href="http://us.gizmodo.com/gadgets/home-entertainment/get-unwired-and-unload-141254.php#c21341">this gem</a> that reminds us that this may just reflect the evolution of our media: <strong>&#8220;The laptop in the john is the new newspaper for the millennium.&#8221;</strong></p>
<p>I apparently have too many neatnik issues to go down that path, but rather than devolve the discussion, I&#8217;d like to point out that this <a href="http://www.digitalcenter.org/pages/site_content.asp?intGlobalId=22">Center for the Digital Future report</a> appears to be a good complement to <a href="http://maisonbisson.com/blog/post/10979/" title="OCLC Report: Libraries vs. Search Engines">OCLC&#8217;s latest report</a> and the regular <a href="http://maisonbisson.com/blog/search/pew%20internet%20project">stream of reports</a> from the <a href="http://www.pewinternet.org/">Pew Internet Project</a>.</p>
<p>Now back to the funny: <a href="http://www.djspyhunter.com/teapot/uploaded_images/rsstroom_reader_restroom-761230.jpg">RSStroom Reader</a>.</p>
<p><tags>restroom, bathroom, rss, media, newspaper, report, Center for the Digital Future, wifi, in the bathroom, technology, computer use, behavior, research, on the throne, in the can</tags></p>
]]></content:encoded>
			<wfw:commentRss>http://maisonbisson.com/blog/post/11008/bathroom-technology/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
	</channel>
</rss>