<?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: Using index for ORDER BY vs restricting number of rows.</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/</link>
	<description>Percona&#039;s MySQL &#38; InnoDB performance and scalability blog</description>
	<lastBuildDate>Sat, 11 Feb 2012 16:45:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Vlad Fratila</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/comment-page-1/#comment-770815</link>
		<dc:creator>Vlad Fratila</dc:creator>
		<pubDate>Fri, 06 Aug 2010 10:37:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#comment-770815</guid>
		<description>Hi!
I&#039;m also very interested in Rob&#039;s question about other RDBMSes.
Also, have the latest versions of MySQL improved on this issue at all?</description>
		<content:encoded><![CDATA[<p>Hi!<br />
I&#8217;m also very interested in Rob&#8217;s question about other RDBMSes.<br />
Also, have the latest versions of MySQL improved on this issue at all?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/comment-page-1/#comment-734833</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Thu, 11 Mar 2010 16:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#comment-734833</guid>
		<description>That you&#039;re aware of, are other RDMBS&#039;s better at selecting indexes when using ORDER BY queries or is this a universal limitation? How do the big players (Oracle, MSSQL) and competing open source products (Postgres) compare?</description>
		<content:encoded><![CDATA[<p>That you&#8217;re aware of, are other RDMBS&#8217;s better at selecting indexes when using ORDER BY queries or is this a universal limitation? How do the big players (Oracle, MSSQL) and competing open source products (Postgres) compare?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/comment-page-1/#comment-52959</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Fri, 16 Feb 2007 22:39:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#comment-52959</guid>
		<description>Alexey, 

This is just example I used.  Imagine real case with for example 10 different filters and  5 fields you may sort on...  you simply can&#039;t build indexes to cover all combinations and as soon as you skip something you start to get the problem. 

It may be with sorting by the date for example etc. 

You&#039;re right about sorting - priority queue (for example) based sort would be possible to use without changing semantics for many LIMIT queries.   It was even discussed for years by Optimizer team but was not done. 

This would not exactly help in this case though as even with partial sort you will need to scan full result set while with  scan in index order you can stop as soon as needed number of rows was delivered.</description>
		<content:encoded><![CDATA[<p>Alexey, </p>
<p>This is just example I used.  Imagine real case with for example 10 different filters and  5 fields you may sort on&#8230;  you simply can&#8217;t build indexes to cover all combinations and as soon as you skip something you start to get the problem. </p>
<p>It may be with sorting by the date for example etc. </p>
<p>You&#8217;re right about sorting &#8211; priority queue (for example) based sort would be possible to use without changing semantics for many LIMIT queries.   It was even discussed for years by Optimizer team but was not done. </p>
<p>This would not exactly help in this case though as even with partial sort you will need to scan full result set while with  scan in index order you can stop as soon as needed number of rows was delivered.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexey</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/comment-page-1/#comment-52941</link>
		<dc:creator>Alexey</dc:creator>
		<pubDate>Fri, 16 Feb 2007 22:10:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#comment-52941</guid>
		<description>Why not change `cat_id` index to include price also? like (`cat_id`,`seller_id`, `price`)?

Also, I&#039;ve always wondered why don&#039;t DB developers implement something like &quot;partial sort&quot; algorithm, which doesn&#039;t sort the whole set, but instead picks top N values. I think such algorithm is O(N) and also it doesn&#039;t any tempfiles, one simple scan.</description>
		<content:encoded><![CDATA[<p>Why not change `cat_id` index to include price also? like (`cat_id`,`seller_id`, `price`)?</p>
<p>Also, I&#8217;ve always wondered why don&#8217;t DB developers implement something like &#8220;partial sort&#8221; algorithm, which doesn&#8217;t sort the whole set, but instead picks top N values. I think such algorithm is O(N) and also it doesn&#8217;t any tempfiles, one simple scan.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitri Mikhailov</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/comment-page-1/#comment-52934</link>
		<dc:creator>Dmitri Mikhailov</dc:creator>
		<pubDate>Fri, 16 Feb 2007 21:35:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#comment-52934</guid>
		<description>Runtime optimization in OLTP systems has always been expensive; I always try to turn CBO off by all means available. There is nothing wrong about it if: a) the data distribution is well known and b) is not going to be changed and (c) the database design is solid.</description>
		<content:encoded><![CDATA[<p>Runtime optimization in OLTP systems has always been expensive; I always try to turn CBO off by all means available. There is nothing wrong about it if: a) the data distribution is well known and b) is not going to be changed and (c) the database design is solid.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/comment-page-1/#comment-52790</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Fri, 16 Feb 2007 16:24:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#comment-52790</guid>
		<description>Sheeri,

Yes that is the bummer with force index hint. It is helpful it you know it is best plan to run the query for all constants, if it is not you&#039;re in trouble.</description>
		<content:encoded><![CDATA[<p>Sheeri,</p>
<p>Yes that is the bummer with force index hint. It is helpful it you know it is best plan to run the query for all constants, if it is not you&#8217;re in trouble.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sheeri</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/comment-page-1/#comment-52789</link>
		<dc:creator>Sheeri</dc:creator>
		<pubDate>Fri, 16 Feb 2007 16:18:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#comment-52789</guid>
		<description>You have to make sure, when you&#039;re doing something like forcing an index due to the character of your data, that you check and make sure the character of the data does not change.</description>
		<content:encoded><![CDATA[<p>You have to make sure, when you&#8217;re doing something like forcing an index due to the character of your data, that you check and make sure the character of the data does not change.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

