<?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: Performance Impact of Using SELECT COUNT(*) In Queries</title>
	<atom:link href="http://www.sql-server-performance.com/2013/performance-select-count-queries/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sql-server-performance.com/2013/performance-select-count-queries/</link>
	<description>SQL Server Performance Tuning</description>
	<lastBuildDate>Fri, 17 May 2013 13:31:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Mark Freeman</title>
		<link>http://www.sql-server-performance.com/2013/performance-select-count-queries/#comment-3365</link>
		<dc:creator>Mark Freeman</dc:creator>
		<pubDate>Thu, 11 Apr 2013 15:05:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?p=3545#comment-3365</guid>
		<description><![CDATA[This is the most efficient way that I have found, although it is obviously a little more time consuming to type. :-)
SELECT	i.rows
  FROM	sys.tables t
	INNER JOIN sys.sysindexes i ON t.object_id = i.id AND i.indid &lt; 2
 WHERE	t.schema_id = SCHEMA_ID(&#039;&#039;) AND t.name = &#039;&#039;;
If you compare it to any flavor of SELECT COUNT() FROM ., it us the clear winner regardless of what is in the cache or not.]]></description>
		<content:encoded><![CDATA[<p>This is the most efficient way that I have found, although it is obviously a little more time consuming to type. <img src='http://www.sql-server-performance.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>SELECT	i.rows<br />
  FROM	sys.tables t<br />
	INNER JOIN sys.sysindexes i ON t.object_id = i.id AND i.indid &lt; 2<br />
 WHERE	t.schema_id = SCHEMA_ID(&#039;&#8217;) AND t.name = &#8221;;</p>
<p>If you compare it to any flavor of SELECT COUNT() FROM ., it us the clear winner regardless of what is in the cache or not.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Freeman</title>
		<link>http://www.sql-server-performance.com/2013/performance-select-count-queries/#comment-3364</link>
		<dc:creator>Mark Freeman</dc:creator>
		<pubDate>Thu, 11 Apr 2013 14:55:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?p=3545#comment-3364</guid>
		<description><![CDATA[I use COUNT(1) as a holdover from my Oracle days, where it made a significant difference. I just tried SELECT(1), SELECT(*), and SELECT() on a table with 1.3M rows, and the explain plan showed 33% for each, so it may not make a difference to SQL Server.]]></description>
		<content:encoded><![CDATA[<p>I use COUNT(1) as a holdover from my Oracle days, where it made a significant difference. I just tried SELECT(1), SELECT(*), and SELECT() on a table with 1.3M rows, and the explain plan showed 33% for each, so it may not make a difference to SQL Server.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jack</title>
		<link>http://www.sql-server-performance.com/2013/performance-select-count-queries/#comment-3129</link>
		<dc:creator>jack</dc:creator>
		<pubDate>Mon, 18 Feb 2013 20:14:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?p=3545#comment-3129</guid>
		<description><![CDATA[You can use sp_spaceused to get a row count, too. It can report incorrect values for rows and space used, but a pretty lightweight way to find a row count.
USE AdventureWorks2008R2;
GO
EXEC sp_spaceused N&#039;Purchasing.Vendor&#039;;
GO
More info: http://msdn.microsoft.com/en-us/library/ms188776(SQL.105).aspx]]></description>
		<content:encoded><![CDATA[<p>You can use sp_spaceused to get a row count, too. It can report incorrect values for rows and space used, but a pretty lightweight way to find a row count.   </p>
<p>USE AdventureWorks2008R2;<br />
GO<br />
EXEC sp_spaceused N&#8217;Purchasing.Vendor&#8217;;<br />
GO</p>
<p>More info: <a href="http://msdn.microsoft.com/en-us/library/ms188776(SQL.105)" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms188776(SQL.105)</a>.aspx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ville Vainio</title>
		<link>http://www.sql-server-performance.com/2013/performance-select-count-queries/#comment-2993</link>
		<dc:creator>Ville Vainio</dc:creator>
		<pubDate>Thu, 24 Jan 2013 08:20:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?p=3545#comment-2993</guid>
		<description><![CDATA[Ed, I think that if you&#039;re just counting all the rows in a table, you could just look it up at sys.sysindexes. Join it with sys.tables. Take a look here: http://geekswithblogs.net/TakeNote/archive/2007/09/22/115537.aspx
But in real world, i usually want to count customers by territory, or some other group. I don&#039;t know of an alternative to that. Or if I&#039;m actually interested in the total row count of a table, I can suffer the one-off impact of an index scan (as it would take more time to write a better query).]]></description>
		<content:encoded><![CDATA[<p>Ed, I think that if you&#8217;re just counting all the rows in a table, you could just look it up at sys.sysindexes. Join it with sys.tables. Take a look here: <a href="http://geekswithblogs.net/TakeNote/archive/2007/09/22/115537.aspx" rel="nofollow">http://geekswithblogs.net/TakeNote/archive/2007/09/22/115537.aspx</a></p>
<p>But in real world, i usually want to count customers by territory, or some other group. I don&#8217;t know of an alternative to that. Or if I&#8217;m actually interested in the total row count of a table, I can suffer the one-off impact of an index scan (as it would take more time to write a better query).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastiaan Halsema</title>
		<link>http://www.sql-server-performance.com/2013/performance-select-count-queries/#comment-2992</link>
		<dc:creator>Sebastiaan Halsema</dc:creator>
		<pubDate>Wed, 23 Jan 2013 19:29:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?p=3545#comment-2992</guid>
		<description><![CDATA[Whenever I need to know the number of records  in a table or query I always use
Select Count(1) From ...
Not sure though if it really makes any difference in the used plan, never tested it either. But you won&#039;t have to know the name of any column that way and the result will be the same of course (each row will be counted)]]></description>
		<content:encoded><![CDATA[<p>Whenever I need to know the number of records  in a table or query I always use </p>
<p>Select Count(1) From &#8230;</p>
<p>Not sure though if it really makes any difference in the used plan, never tested it either. But you won&#8217;t have to know the name of any column that way and the result will be the same of course (each row will be counted)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed Miller</title>
		<link>http://www.sql-server-performance.com/2013/performance-select-count-queries/#comment-2991</link>
		<dc:creator>Ed Miller</dc:creator>
		<pubDate>Wed, 23 Jan 2013 14:15:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?p=3545#comment-2991</guid>
		<description><![CDATA[Okay, good info. So what&#039;s the solution? Would COUNT(Customer_ID) be better?]]></description>
		<content:encoded><![CDATA[<p>Okay, good info. So what&#8217;s the solution? Would COUNT(Customer_ID) be better?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
