<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Interesting Observation about Order of Resultset without ORDER BY</title>
	<atom:link href="http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #004 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-379682</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #004 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 24 Nov 2012 01:31:23 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-379682</guid>
		<description><![CDATA[[...] Interesting Observation about Order of Resultset without ORDER BY In industry many developers avoid using ORDER BY clause to display the result in particular order thinking that Index is enforcing the order. In this interesting example, I demonstrate that without using ORDER BY, same table and similar query can return different results. Query optimizer always returns results using any method which is optimized for performance. The learning is There is no order unless ORDER BY is used. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Interesting Observation about Order of Resultset without ORDER BY In industry many developers avoid using ORDER BY clause to display the result in particular order thinking that Index is enforcing the order. In this interesting example, I demonstrate that without using ORDER BY, same table and similar query can return different results. Query optimizer always returns results using any method which is optimized for performance. The learning is There is no order unless ORDER BY is used. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashwani</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-269862</link>
		<dc:creator><![CDATA[Ashwani]]></dc:creator>
		<pubDate>Fri, 30 Mar 2012 18:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-269862</guid>
		<description><![CDATA[Hello Sir:
I have a question.
When Order by is used for a column and there are multiple rows having same value for the column, then what criteria SQL server follows to show the rows.
http://stackoverflow.com/questions/9944894/random-order-of-rows-when-sorting-is-done-on-a-column#comment12698118_9944894]]></description>
		<content:encoded><![CDATA[<p>Hello Sir:<br />
I have a question.<br />
When Order by is used for a column and there are multiple rows having same value for the column, then what criteria SQL server follows to show the rows.<br />
<a href="http://stackoverflow.com/questions/9944894/random-order-of-rows-when-sorting-is-done-on-a-column#comment12698118_9944894" rel="nofollow">http://stackoverflow.com/questions/9944894/random-order-of-rows-when-sorting-is-done-on-a-column#comment12698118_9944894</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44468</link>
		<dc:creator><![CDATA[Andrew]]></dc:creator>
		<pubDate>Mon, 01 Dec 2008 17:52:34 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44468</guid>
		<description><![CDATA[One reason why query optimizer use non-clustered index in this case is probably because the non-clustered index already have the data needed by the query and SQL server doesn&#039;t have to read the data page of the table.  That is a big performance gain.]]></description>
		<content:encoded><![CDATA[<p>One reason why query optimizer use non-clustered index in this case is probably because the non-clustered index already have the data needed by the query and SQL server doesn&#8217;t have to read the data page of the table.  That is a big performance gain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Interesting Observation - Use of Index and Execution Plan Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44444</link>
		<dc:creator><![CDATA[SQL SERVER - Interesting Observation - Use of Index and Execution Plan Journey to SQL Authority with Pinal Dave]]></dc:creator>
		<pubDate>Sun, 30 Nov 2008 01:30:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44444</guid>
		<description><![CDATA[[...] 30, 2008 by pinaldave    Previously I wrote article about SQL SERVER - Interesting Observation about Order of Resultset without ORDER BY and I have received tremendous response from my readers by emails and comments. Readers demanded [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 30, 2008 by pinaldave    Previously I wrote article about SQL SERVER &#8211; Interesting Observation about Order of Resultset without ORDER BY and I have received tremendous response from my readers by emails and comments. Readers demanded [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Travis Alltop</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44421</link>
		<dc:creator><![CDATA[Travis Alltop]]></dc:creator>
		<pubDate>Thu, 27 Nov 2008 18:39:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44421</guid>
		<description><![CDATA[&quot;I guess the answer to that is because non-clustered index’s leaf nodes contain the information that allows SQL Server to navigate to the data pages it needs, usually the clustered index keys (ContactID). The non-clustered index contains all the data it needs and no key lookup is required. But if we try something like: SELECT ContactID, _Another_Random_Column_ FROM Person.Contact then we are back of using the cluster index.&quot;

That is correct, that is exactly why it is faster but I&#039;m kind of surprised that people are just now finding this out. Maybe a little refresher in Data Structures 101 is what is needed.


&quot;There is no order unless ORDER BY is used.&quot;

Once again, kind of a no brainer. Sort order is never 100% guaranteed by the query optimzer without the ORDER BY clause, that is why it is included in the SELECT syntax. It is meant to be used.]]></description>
		<content:encoded><![CDATA[<p>&#8220;I guess the answer to that is because non-clustered index’s leaf nodes contain the information that allows SQL Server to navigate to the data pages it needs, usually the clustered index keys (ContactID). The non-clustered index contains all the data it needs and no key lookup is required. But if we try something like: SELECT ContactID, _Another_Random_Column_ FROM Person.Contact then we are back of using the cluster index.&#8221;</p>
<p>That is correct, that is exactly why it is faster but I&#8217;m kind of surprised that people are just now finding this out. Maybe a little refresher in Data Structures 101 is what is needed.</p>
<p>&#8220;There is no order unless ORDER BY is used.&#8221;</p>
<p>Once again, kind of a no brainer. Sort order is never 100% guaranteed by the query optimzer without the ORDER BY clause, that is why it is included in the SELECT syntax. It is meant to be used.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe The DBA</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44396</link>
		<dc:creator><![CDATA[Joe The DBA]]></dc:creator>
		<pubDate>Tue, 25 Nov 2008 22:12:19 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44396</guid>
		<description><![CDATA[The execution path is primarily determined by what percent of rows are expected to be returned from the query which is based off of the statistics generated on the table. There are cases where table or index scans are preferable to index seeks. This is why oracle stores the table in a heap style and then you add indexes (though oracle has index organized tables which are identical to sql server clustered indexes). 

The reason for this is random reads vs sequential reads. If you are going to access more than about 50% of the rows in a table then you are better off doing a table scan because that is a sequential read. That is likely to be faster than doing random seeks for 50% of the rows into the index. The oracle optimizer is years ahead of where the sql server optimizer is right now.]]></description>
		<content:encoded><![CDATA[<p>The execution path is primarily determined by what percent of rows are expected to be returned from the query which is based off of the statistics generated on the table. There are cases where table or index scans are preferable to index seeks. This is why oracle stores the table in a heap style and then you add indexes (though oracle has index organized tables which are identical to sql server clustered indexes). </p>
<p>The reason for this is random reads vs sequential reads. If you are going to access more than about 50% of the rows in a table then you are better off doing a table scan because that is a sequential read. That is likely to be faster than doing random seeks for 50% of the rows into the index. The oracle optimizer is years ahead of where the sql server optimizer is right now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jerry Hung</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44395</link>
		<dc:creator><![CDATA[Jerry Hung]]></dc:creator>
		<pubDate>Tue, 25 Nov 2008 21:27:27 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44395</guid>
		<description><![CDATA[Very interesting

I observe the same in AdventureWorks2008 on SQL 2008

SELECT TOP 10 * -- Clustered index scan
FROM person.Person

BusinessEntityID
1
2
3
4
5

SELECT TOP 10 businessentityid -- NonClustered
FROM person.Person

businessentityid
16496
12506
11390
10798
963]]></description>
		<content:encoded><![CDATA[<p>Very interesting</p>
<p>I observe the same in AdventureWorks2008 on SQL 2008</p>
<p>SELECT TOP 10 * &#8212; Clustered index scan<br />
FROM person.Person</p>
<p>BusinessEntityID<br />
1<br />
2<br />
3<br />
4<br />
5</p>
<p>SELECT TOP 10 businessentityid &#8212; NonClustered<br />
FROM person.Person</p>
<p>businessentityid<br />
16496<br />
12506<br />
11390<br />
10798<br />
963</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ponnu</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44388</link>
		<dc:creator><![CDATA[Ponnu]]></dc:creator>
		<pubDate>Tue, 25 Nov 2008 14:12:34 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44388</guid>
		<description><![CDATA[Nice to know, good one Dave.]]></description>
		<content:encoded><![CDATA[<p>Nice to know, good one Dave.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Kotev</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44387</link>
		<dc:creator><![CDATA[Ivan Kotev]]></dc:creator>
		<pubDate>Tue, 25 Nov 2008 12:54:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44387</guid>
		<description><![CDATA[I guess the answer to that is because non-clustered index&#039;s  leaf nodes contain the information that allows SQL Server to navigate to the data pages it needs, usually the clustered index keys (ContactID). The non-clustered index contains all the data it needs and no key lookup is required. But if we try something like: SELECT ContactID, _Another_Random_Column_ FROM Person.Contact then we are back of using the cluster index.]]></description>
		<content:encoded><![CDATA[<p>I guess the answer to that is because non-clustered index&#8217;s  leaf nodes contain the information that allows SQL Server to navigate to the data pages it needs, usually the clustered index keys (ContactID). The non-clustered index contains all the data it needs and no key lookup is required. But if we try something like: SELECT ContactID, _Another_Random_Column_ FROM Person.Contact then we are back of using the cluster index.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Praveen</title>
		<link>http://blog.sqlauthority.com/2008/11/24/sql-server-interesting-observation-about-order-of-resultset-without-order-by/#comment-44379</link>
		<dc:creator><![CDATA[Praveen]]></dc:creator>
		<pubDate>Tue, 25 Nov 2008 07:47:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1561#comment-44379</guid>
		<description><![CDATA[This is great. But one doubt here how non-clustered index wins over clustered? Any idea.]]></description>
		<content:encoded><![CDATA[<p>This is great. But one doubt here how non-clustered index wins over clustered? Any idea.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
