<?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: 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>Everything about MySQL Performance</description>
	<pubDate>Tue, 02 Dec 2008 16:11:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/02/16/using-index-for-order-by-vs-restricting-number-of-rows/#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'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'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 - 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-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've always wondered why don't DB developers implement something like "partial sort" algorithm, which doesn't sort the whole set, but instead picks top N values. I think such algorithm is O(N) and also it doesn'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-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-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'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-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'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>
