<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Medians, ROW_NUMBERs, and performance</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/12/18/medians-row-numbers-and-performance.aspx</link><description>A couple of days ago, Aaron Bertrand posted about a method for calculating medians in SQL Server 2005 using the ROW_NUMBER function in conjunction with the COUNT aggregate. This method (credited to Itzik Ben-Gan) is interesting, but I discovered an even</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Medians, ROW_NUMBERs, and performance</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/12/18/medians-row-numbers-and-performance.aspx#440</link><pubDate>Mon, 18 Dec 2006 21:46:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:440</guid><dc:creator>Adam Machanic</dc:creator><description>Paul Nielsen asked me for clarification on the final paragraph and why Ben-Gan's &amp;quot;should&amp;quot; perform better. &amp;nbsp;Here's my response:&lt;br&gt;&lt;br&gt;Ben-Gan's -should- perform better, because the QP shouldn't have to do a table spool to get the row count at the same time it does the row number. &amp;nbsp;Row numbering is essentially the same operation as row counting (a walk over the rows that satisfy a given predicate, except that row numbering has to be ordered/sequential), so I would expect a shortcut by the QP in that case -- but the SQL Server team has obviously not implemented anything along those lines. &amp;nbsp;If the&lt;br&gt;QP did behave that way, Ben-Gan's query would be much better than Celko's because it wouldn't have to do an intermediate sort (assuming a supporting index existed).</description></item><item><title>Medians, Actual Query Cost, and Statistics</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/12/18/medians-row-numbers-and-performance.aspx#451</link><pubDate>Wed, 20 Dec 2006 11:18:57 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:451</guid><dc:creator>Peter DeBetta's SQL Programming Blog</dc:creator><description>I was going to comment on Adam's post &amp;amp;quot;Medians, ROW_NUMBERs, and performance&amp;amp;quot; (which&amp;amp;amp;nbsp;was a follow-up&amp;amp;amp;nbsp;to...</description></item><item><title>Medians, Actual Query Cost, and Statistics</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/12/18/medians-row-numbers-and-performance.aspx#495</link><pubDate>Tue, 02 Jan 2007 21:12:11 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:495</guid><dc:creator>Peter DeBetta's SQL Programming Blog</dc:creator><description>&lt;p&gt;I was going to comment on Adam's post &amp;quot; Medians, ROW_NUMBERs, and performance &amp;quot; (which was a follow-up&lt;/p&gt;
</description></item><item><title>re: Medians, ROW_NUMBERs, and performance</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/12/18/medians-row-numbers-and-performance.aspx#34194</link><pubDate>Wed, 16 Mar 2011 15:48:19 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:34194</guid><dc:creator>Michelle Ufford</dc:creator><description>&lt;p&gt;Thank you for this post, Adam! &amp;nbsp;:)&lt;/p&gt;
</description></item><item><title>re: Medians, ROW_NUMBERs, and performance</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/12/18/medians-row-numbers-and-performance.aspx#38018</link><pubDate>Tue, 23 Aug 2011 14:50:17 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:38018</guid><dc:creator>Mike L</dc:creator><description>&lt;p&gt;This is a very, very cool solution. :) &amp;nbsp;Thanks for sharing it.&lt;/p&gt;
</description></item><item><title>re: Medians, ROW_NUMBERs, and performance</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/12/18/medians-row-numbers-and-performance.aspx#43343</link><pubDate>Mon, 14 May 2012 17:56:48 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:43343</guid><dc:creator>Fkoffee</dc:creator><description>&lt;p&gt;thanks a ton!!! &lt;/p&gt;
</description></item></channel></rss>