<?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: My wishlist for SQL: the UNTIL clause</title>
	<atom:link href="http://www.xaprb.com/blog/2010/01/22/my-wishlist-for-sql-the-until-clause/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.xaprb.com/blog/2010/01/22/my-wishlist-for-sql-the-until-clause/</link>
	<description>Stay curious!</description>
	<lastBuildDate>Thu, 09 Feb 2012 09:56:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Claus</title>
		<link>http://www.xaprb.com/blog/2010/01/22/my-wishlist-for-sql-the-until-clause/#comment-18535</link>
		<dc:creator>Claus</dc:creator>
		<pubDate>Tue, 03 Aug 2010 16:57:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1592#comment-18535</guid>
		<description>Never mind, just realized that doesn&#039;t work for my use-case, as I&#039;m not having a linear order here, so I can&#039;t stop scanning even a sorted table when a certain condition is met.</description>
		<content:encoded><![CDATA[<p>Never mind, just realized that doesn&#8217;t work for my use-case, as I&#8217;m not having a linear order here, so I can&#8217;t stop scanning even a sorted table when a certain condition is met.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Claus</title>
		<link>http://www.xaprb.com/blog/2010/01/22/my-wishlist-for-sql-the-until-clause/#comment-18532</link>
		<dc:creator>Claus</dc:creator>
		<pubDate>Tue, 03 Aug 2010 15:30:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1592#comment-18532</guid>
		<description>I just stumbled across a problem where an UNTIL clause would probably indeed make sense:

I have a column containing strings, and I want to find those strings that are a prefix to a given string:

E.g. If the given string is &#039;Hello World&#039; then rows containing &#039;Hell&#039;, and &#039;Hello&#039; should match.

A query like
SELECT * FROM table t WHERE t.str &lt;= &#039;Hello World&#039; ORDER BY t.str DESC UNTIL (&#039;Hello World&#039; NOT_STARTS_WITH t.str)
would archive that.

(whatever SQL-function corresponds to the NOT_STARTS_WITH predicate)

So in my case I want to physically iterate over the b-tree index, until some condition is no longer satisfied.</description>
		<content:encoded><![CDATA[<p>I just stumbled across a problem where an UNTIL clause would probably indeed make sense:</p>
<p>I have a column containing strings, and I want to find those strings that are a prefix to a given string:</p>
<p>E.g. If the given string is &#8216;Hello World&#8217; then rows containing &#8216;Hell&#8217;, and &#8216;Hello&#8217; should match.</p>
<p>A query like<br />
SELECT * FROM table t WHERE t.str &lt;= &#039;Hello World&#039; ORDER BY t.str DESC UNTIL (&#039;Hello World&#039; NOT_STARTS_WITH t.str)<br />
would archive that.</p>
<p>(whatever SQL-function corresponds to the NOT_STARTS_WITH predicate)</p>
<p>So in my case I want to physically iterate over the b-tree index, until some condition is no longer satisfied.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Monotonic functions, SQL and MySQL &#124; code.openark.org</title>
		<link>http://www.xaprb.com/blog/2010/01/22/my-wishlist-for-sql-the-until-clause/#comment-17900</link>
		<dc:creator>Monotonic functions, SQL and MySQL &#124; code.openark.org</dc:creator>
		<pubDate>Wed, 24 Feb 2010 21:50:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1592#comment-17900</guid>
		<description>[...] Baron&#8217;s wishlist for SQL can also benefit from monotonic [...]</description>
		<content:encoded><![CDATA[<p>[...] Baron&#8217;s wishlist for SQL can also benefit from monotonic [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob W</title>
		<link>http://www.xaprb.com/blog/2010/01/22/my-wishlist-for-sql-the-until-clause/#comment-17765</link>
		<dc:creator>Rob W</dc:creator>
		<pubDate>Mon, 08 Feb 2010 23:48:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1592#comment-17765</guid>
		<description>To me, I don&#039;t think UNTIL is a very good idea:

1. The semantics of a &quot;result set&quot; is basically thrown out the window. A query is supposed to ask for data as if it were a set immediately available at the time of the query. Otherwise, you&#039;re just using *procedural code* (which UNTIL just seems like perverting query syntax for the sake of an implicit loop). In other words, what about the halting problem? If you forget a WHERE clause, the worst case is you retrieve too much data. If you don&#039;t make UNTIL have a sane terminating condition, then you can create an infinite loop. Depending on the database engine, this can cause a death spiral of locks, memory leaks, etc. The *semantics* of a query IS NOT a loop, so continuing a loop UNTIL some condition is non-sensical. You ask for the data, and based on the predicates the data either gets returned or they don&#039;t, as a single result.

2. The argument that subqueries are doing too much whereas &quot;one query&quot; of UNTIL is faster is a non-argument. There IS NO &quot;one query&quot; for UNTIL: it&#039;s semantically a loop of multiple queries (like you&#039;d do with a procedure anyway). At least subqueries can be optimized by the planner. How is the query planner supposed to plan for something when there may not even be a genuine terminating condition?

But maybe there are genuine reasons for this, maybe either I&#039;m not understanding or the concept isn&#039;t being explained clearly enough. But then again, maybe that&#039;s a sign that it&#039;s not a good idea (given the list of problems stated already)?</description>
		<content:encoded><![CDATA[<p>To me, I don&#8217;t think UNTIL is a very good idea:</p>
<p>1. The semantics of a &#8220;result set&#8221; is basically thrown out the window. A query is supposed to ask for data as if it were a set immediately available at the time of the query. Otherwise, you&#8217;re just using *procedural code* (which UNTIL just seems like perverting query syntax for the sake of an implicit loop). In other words, what about the halting problem? If you forget a WHERE clause, the worst case is you retrieve too much data. If you don&#8217;t make UNTIL have a sane terminating condition, then you can create an infinite loop. Depending on the database engine, this can cause a death spiral of locks, memory leaks, etc. The *semantics* of a query IS NOT a loop, so continuing a loop UNTIL some condition is non-sensical. You ask for the data, and based on the predicates the data either gets returned or they don&#8217;t, as a single result.</p>
<p>2. The argument that subqueries are doing too much whereas &#8220;one query&#8221; of UNTIL is faster is a non-argument. There IS NO &#8220;one query&#8221; for UNTIL: it&#8217;s semantically a loop of multiple queries (like you&#8217;d do with a procedure anyway). At least subqueries can be optimized by the planner. How is the query planner supposed to plan for something when there may not even be a genuine terminating condition?</p>
<p>But maybe there are genuine reasons for this, maybe either I&#8217;m not understanding or the concept isn&#8217;t being explained clearly enough. But then again, maybe that&#8217;s a sign that it&#8217;s not a good idea (given the list of problems stated already)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Log Buffer #176: a Carnival of the Vanities for DBAs &#124; The Pythian Blog</title>
		<link>http://www.xaprb.com/blog/2010/01/22/my-wishlist-for-sql-the-until-clause/#comment-17708</link>
		<dc:creator>Log Buffer #176: a Carnival of the Vanities for DBAs &#124; The Pythian Blog</dc:creator>
		<pubDate>Fri, 29 Jan 2010 19:03:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.xaprb.com/blog/?p=1592#comment-17708</guid>
		<description>[...] Schwartz inspires a lot of conversation with his post, My wishlist for SQL: the UNTIL clause. Baron says, &#8220;I’d like an UNTIL clause, please. I’d use it sort of like LIMIT in MySQL and [...]</description>
		<content:encoded><![CDATA[<p>[...] Schwartz inspires a lot of conversation with his post, My wishlist for SQL: the UNTIL clause. Baron says, &#8220;I’d like an UNTIL clause, please. I’d use it sort of like LIMIT in MySQL and [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

