<?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: Things SQL needs: sargability of monotonic functions</title>
	<atom:link href="http://explainextended.com/2010/02/19/things-sql-needs-sargability-of-monotonic-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://explainextended.com/2010/02/19/things-sql-needs-sargability-of-monotonic-functions/</link>
	<description>How to create fast database queries</description>
	<lastBuildDate>Wed, 01 Sep 2010 07:54:21 +0400</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Quassnoi</title>
		<link>http://explainextended.com/2010/02/19/things-sql-needs-sargability-of-monotonic-functions/comment-page-1/#comment-113</link>
		<dc:creator>Quassnoi</dc:creator>
		<pubDate>Fri, 19 Mar 2010 12:17:08 +0000</pubDate>
		<guid isPermaLink="false">http://explainextended.com/?p=4149#comment-113</guid>
		<description>@Shlomi: great minds think alike!</description>
		<content:encoded><![CDATA[<p>@Shlomi: great minds think alike!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shlomi Noach</title>
		<link>http://explainextended.com/2010/02/19/things-sql-needs-sargability-of-monotonic-functions/comment-page-1/#comment-112</link>
		<dc:creator>Shlomi Noach</dc:creator>
		<pubDate>Fri, 19 Mar 2010 11:52:41 +0000</pubDate>
		<guid isPermaLink="false">http://explainextended.com/?p=4149#comment-112</guid>
		<description>Hi,

Very good write!
I also wrote a bit earlier on monotonic functions: on how to utilize the fact we have a monotonic function, to cover for a missing index:

&lt;a href=&quot;http://code.openark.org/blog/mysql/monotonic-functions-sql-and-mysql&quot; rel=&quot;nofollow&quot;&gt;Monotonic functions, SQL and MySQL&lt;/a&gt;

Regards</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Very good write!<br />
I also wrote a bit earlier on monotonic functions: on how to utilize the fact we have a monotonic function, to cover for a missing index:</p>
<p><a href="http://code.openark.org/blog/mysql/monotonic-functions-sql-and-mysql" rel="nofollow">Monotonic functions, SQL and MySQL</a></p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://explainextended.com/2010/02/19/things-sql-needs-sargability-of-monotonic-functions/comment-page-1/#comment-103</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Sat, 20 Feb 2010 16:04:01 +0000</pubDate>
		<guid isPermaLink="false">http://explainextended.com/?p=4149#comment-103</guid>
		<description>Absolutely agree with you Quassnoi :)</description>
		<content:encoded><![CDATA[<p>Absolutely agree with you Quassnoi :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Quassnoi</title>
		<link>http://explainextended.com/2010/02/19/things-sql-needs-sargability-of-monotonic-functions/comment-page-1/#comment-102</link>
		<dc:creator>Quassnoi</dc:creator>
		<pubDate>Sat, 20 Feb 2010 07:07:05 +0000</pubDate>
		<guid isPermaLink="false">http://explainextended.com/?p=4149#comment-102</guid>
		<description>@Jay: with a function monotonic over all its domain, it&#039;s easy to rewrite the condition.

However, the point of SQL (as we have been told for the decades) is that &lt;q&gt;you give the idea, we handle the details&lt;/q&gt;, and this proposal is to make this statement more true.

Rewriting the conditions, though, may be not easy as it seems. Say, &lt;code&gt;col1 / y  = z&lt;/code&gt; is not the same as &lt;code&gt;col1 = z * y&lt;/code&gt; (due to the rounding errors). This requires extra handling too.

And what about functions that are piecewise monotonic? Like &lt;q&gt;get all records of Jan 1st of any year&lt;/q&gt;? This is not so easy to rewrite as a sargable condition.

So having these things handled automatically in Drizzle would be very nice :)</description>
		<content:encoded><![CDATA[<p>@Jay: with a function monotonic over all its domain, it&#8217;s easy to rewrite the condition.</p>
<p>However, the point of SQL (as we have been told for the decades) is that <q>you give the idea, we handle the details</q>, and this proposal is to make this statement more true.</p>
<p>Rewriting the conditions, though, may be not easy as it seems. Say, <code>col1 / y  = z</code> is not the same as <code>col1 = z * y</code> (due to the rounding errors). This requires extra handling too.</p>
<p>And what about functions that are piecewise monotonic? Like <q>get all records of Jan 1st of any year</q>? This is not so easy to rewrite as a sargable condition.</p>
<p>So having these things handled automatically in Drizzle would be very nice :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jay Pipes</title>
		<link>http://explainextended.com/2010/02/19/things-sql-needs-sargability-of-monotonic-functions/comment-page-1/#comment-101</link>
		<dc:creator>Jay Pipes</dc:creator>
		<pubDate>Sat, 20 Feb 2010 02:51:55 +0000</pubDate>
		<guid isPermaLink="false">http://explainextended.com/?p=4149#comment-101</guid>
		<description>First, this was an excellent article.  Second, I&#039;ll be reviewing what parts of your suggestions I can easily introduce into the Drizzle optimizer.

Finally, I&#039;d just say that perhaps the reason that many RDBMS have yet to implement such optimizations is because in many (all?) cases where a monotonic function might be inlined within the optimizer into a sargable parameter, the SQL statement can be rewritten in such a way as to manually perform the translation.

Simple example would be rewriting this MySQLish SQL SELECT statement (assume an index on t1(date_col)):

SELECT * FROM t1 WHERE TO_DAYS(date_col) &gt; TO_DAYS(NOW()) - 8;

to 

SELECT * FROM t1 WHERE date_col &gt; NOW() - INTERVAL 8 DAY;

Cheers, and nice blog! :)

-jay</description>
		<content:encoded><![CDATA[<p>First, this was an excellent article.  Second, I&#8217;ll be reviewing what parts of your suggestions I can easily introduce into the Drizzle optimizer.</p>
<p>Finally, I&#8217;d just say that perhaps the reason that many RDBMS have yet to implement such optimizations is because in many (all?) cases where a monotonic function might be inlined within the optimizer into a sargable parameter, the SQL statement can be rewritten in such a way as to manually perform the translation.</p>
<p>Simple example would be rewriting this MySQLish SQL SELECT statement (assume an index on t1(date_col)):</p>
<p>SELECT * FROM t1 WHERE TO_DAYS(date_col) &gt; TO_DAYS(NOW()) &#8211; 8;</p>
<p>to </p>
<p>SELECT * FROM t1 WHERE date_col &gt; NOW() &#8211; INTERVAL 8 DAY;</p>
<p>Cheers, and nice blog! :)</p>
<p>-jay</p>
]]></content:encoded>
	</item>
</channel>
</rss>
