<?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"
	>
<channel>
	<title>Comments on: SQL functions in WHERE clauses are evil</title>
	<atom:link href="http://blog.codevader.com/2008/12/10/sql-functions-in-where-clauses-are-evil/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codevader.com/2008/12/10/sql-functions-in-where-clauses-are-evil/</link>
	<description>Thoughts from the nice people at Codevader :)</description>
	<pubDate>Sat, 19 May 2012 20:21:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: Mark</title>
		<link>http://blog.codevader.com/2008/12/10/sql-functions-in-where-clauses-are-evil/#comment-736</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Mon, 15 Dec 2008 17:24:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codevader.com/?p=67#comment-736</guid>
		<description>I was thinking exactly the same thing as Rich: why no index on the DAYOFMONTH function? That's clearly the cleanest solution. I never thought that MySQL wouldn't support it, reminding us all about what a toy database it really is.</description>
		<content:encoded><![CDATA[<p>I was thinking exactly the same thing as Rich: why no index on the DAYOFMONTH function? That&#8217;s clearly the cleanest solution. I never thought that MySQL wouldn&#8217;t support it, reminding us all about what a toy database it really is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maurício Linhares</title>
		<link>http://blog.codevader.com/2008/12/10/sql-functions-in-where-clauses-are-evil/#comment-734</link>
		<dc:creator>Maurício Linhares</dc:creator>
		<pubDate>Wed, 10 Dec 2008 18:06:51 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codevader.com/?p=67#comment-734</guid>
		<description>Hey Rich,

This is a new one for me, didn't knew that other databases supported this kind of feature, thanks for the tip :)</description>
		<content:encoded><![CDATA[<p>Hey Rich,</p>
<p>This is a new one for me, didn&#8217;t knew that other databases supported this kind of feature, thanks for the tip <img src='http://blog.codevader.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich Cavanaugh</title>
		<link>http://blog.codevader.com/2008/12/10/sql-functions-in-where-clauses-are-evil/#comment-733</link>
		<dc:creator>Rich Cavanaugh</dc:creator>
		<pubDate>Wed, 10 Dec 2008 15:46:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codevader.com/?p=67#comment-733</guid>
		<description>A better mantra may be "SQL functions in where clauses are evil when using toy database software."

On PostgreSQL you're able to define an index based on an SQL function. I've used it to deal with a case almost identical to your example.

You can see some example code here http://pastie.textmate.org/private/y8cfsxezf2f8x2tvrishq There's explain output at the bottom of that pastie. Note specifically the "Bitmap Index Scan" and "Index Cond" lines.

It's worth noting that Drizzle has this feature in a round about way via a feature called virtual columns.</description>
		<content:encoded><![CDATA[<p>A better mantra may be &#8220;SQL functions in where clauses are evil when using toy database software.&#8221;</p>
<p>On PostgreSQL you&#8217;re able to define an index based on an SQL function. I&#8217;ve used it to deal with a case almost identical to your example.</p>
<p>You can see some example code here <a href="http://pastie.textmate.org/private/y8cfsxezf2f8x2tvrishq" rel="nofollow">http://pastie.textmate.org/private/y8cfsxezf2f8&#215;2tvrishq</a> There&#8217;s explain output at the bottom of that pastie. Note specifically the &#8220;Bitmap Index Scan&#8221; and &#8220;Index Cond&#8221; lines.</p>
<p>It&#8217;s worth noting that Drizzle has this feature in a round about way via a feature called virtual columns.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nick</title>
		<link>http://blog.codevader.com/2008/12/10/sql-functions-in-where-clauses-are-evil/#comment-732</link>
		<dc:creator>nick</dc:creator>
		<pubDate>Wed, 10 Dec 2008 06:56:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codevader.com/?p=67#comment-732</guid>
		<description>How much of an issue is this really? If I run your example query against a table with 180,000 records, it still only takes around 0.3 seconds - hardly a huge wait.

If the query was getting run thousands of times a day, then by all means, let's optimise. But if, as in your example, we're doing this once a day to send birthday wishes, then our optimising time is better spent elsewhere.</description>
		<content:encoded><![CDATA[<p>How much of an issue is this really? If I run your example query against a table with 180,000 records, it still only takes around 0.3 seconds - hardly a huge wait.</p>
<p>If the query was getting run thousands of times a day, then by all means, let&#8217;s optimise. But if, as in your example, we&#8217;re doing this once a day to send birthday wishes, then our optimising time is better spent elsewhere.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marcelo</title>
		<link>http://blog.codevader.com/2008/12/10/sql-functions-in-where-clauses-are-evil/#comment-731</link>
		<dc:creator>Marcelo</dc:creator>
		<pubDate>Wed, 10 Dec 2008 01:41:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codevader.com/?p=67#comment-731</guid>
		<description>Great! Thanks for the tip.</description>
		<content:encoded><![CDATA[<p>Great! Thanks for the tip.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

