<?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: COUNT(*) vs COUNT(col)</title>
	<atom:link href="http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/</link>
	<description>Everything about MySQL Performance</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:23:57 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: dalin</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-672497</link>
		<dc:creator>dalin</dc:creator>
		<pubDate>Tue, 03 Nov 2009 01:55:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-672497</guid>
		<description>And to correct my own typo I meant
SELECT 1 FROM foo WHERE bar=”baz” LIMIT 1

the limit being very important</description>
		<content:encoded><![CDATA[<p>And to correct my own typo I meant<br />
SELECT 1 FROM foo WHERE bar=”baz” LIMIT 1</p>
<p>the limit being very important</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dalin</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-672496</link>
		<dc:creator>dalin</dc:creator>
		<pubDate>Tue, 03 Nov 2009 01:54:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-672496</guid>
		<description>It should be noted that often when people use COUNT they really just want to know if there&#039;s anything there and aren&#039;t particularly interested in a accurate count.  In this case a far more performant approach is
SELECT 1 FROM foo WHERE bar=&quot;baz&quot;
The query completes as soon as the first row is found where bar=&quot;baz&quot;.</description>
		<content:encoded><![CDATA[<p>It should be noted that often when people use COUNT they really just want to know if there&#8217;s anything there and aren&#8217;t particularly interested in a accurate count.  In this case a far more performant approach is<br />
SELECT 1 FROM foo WHERE bar=&#8221;baz&#8221;<br />
The query completes as soon as the first row is found where bar=&#8221;baz&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simple Pagination - CodeCall Programming Forum</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-660714</link>
		<dc:creator>Simple Pagination - CodeCall Programming Forum</dc:creator>
		<pubDate>Thu, 01 Oct 2009 12:47:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-660714</guid>
		<description>[...] from table&quot; -&quot;select count(*) from table&quot;    Check this out: COUNT(*) vs COUNT(col) &#124; MySQL Performance Blog  Good performance information there.     __________________ CodeCall Blog &#124; CodeCall Wiki &#124; Write a [...]</description>
		<content:encoded><![CDATA[<p>[...] from table&quot; -&quot;select count(*) from table&quot;    Check this out: COUNT(*) vs COUNT(col) | MySQL Performance Blog  Good performance information there.     __________________ CodeCall Blog | CodeCall Wiki | Write a [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 关于 count(*) 和 count(col) 的种种 - Pro Evolution Swine</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-552496</link>
		<dc:creator>关于 count(*) 和 count(col) 的种种 - Pro Evolution Swine</dc:creator>
		<pubDate>Thu, 30 Apr 2009 08:24:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-552496</guid>
		<description>[...] MysqlPerformance的原文 [...]</description>
		<content:encoded><![CDATA[<p>[...] MysqlPerformance的原文 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: لدى حلين لمعرفة عدد السجلات اى الحلول تنصحوتى - سوالف سوفت</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-354572</link>
		<dc:creator>لدى حلين لمعرفة عدد السجلات اى الحلول تنصحوتى - سوالف سوفت</dc:creator>
		<pubDate>Fri, 12 Sep 2008 11:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-354572</guid>
		<description>[...] هذا الموضوع بالنسبة ل count أنصح بمتابعة هذه المدونه COUNT(*) vs COUNT(col) &#124; MySQL Performance Blog    __________________ I Love PHP (d4d@hotmail.com) [...]</description>
		<content:encoded><![CDATA[<p>[...] هذا الموضوع بالنسبة ل count أنصح بمتابعة هذه المدونه COUNT(*) vs COUNT(col) | MySQL Performance Blog    __________________ I Love PHP (d4d@hotmail.com) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: howard</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-138586</link>
		<dc:creator>howard</dc:creator>
		<pubDate>Sat, 23 Jun 2007 10:33:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-138586</guid>
		<description>hello, can i say: 

the rule of thumb is...

1. use count(primary_key) 
2. use count(indexed_field_and_not_null)
3. use count(indexed_field)
4. use count(*)

how abt the length of the index, does it matter?

thanks.</description>
		<content:encoded><![CDATA[<p>hello, can i say: </p>
<p>the rule of thumb is&#8230;</p>
<p>1. use count(primary_key)<br />
2. use count(indexed_field_and_not_null)<br />
3. use count(indexed_field)<br />
4. use count(*)</p>
<p>how abt the length of the index, does it matter?</p>
<p>thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: &#187; Easy MySQL Performance Tips</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-132964</link>
		<dc:creator>&#187; Easy MySQL Performance Tips</dc:creator>
		<pubDate>Wed, 06 Jun 2007 12:12:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-132964</guid>
		<description>[...] Never do a COUNT(*) (or anything *, says Zach). Instead, replace the * with the name of the column you&#8217;re searching against (and is hopefully indexed). That way some queries can execute entirely in the keycache (while * forces MySQL to read every matching row from the table). [...]</description>
		<content:encoded><![CDATA[<p>[...] Never do a COUNT(*) (or anything *, says Zach). Instead, replace the * with the name of the column you&#8217;re searching against (and is hopefully indexed). That way some queries can execute entirely in the keycache (while * forces MySQL to read every matching row from the table). [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-115916</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Mon, 30 Apr 2007 02:05:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-115916</guid>
		<description>Pavel,

For primary key it should be the same as primary key can&#039;t have null values.
It is same as count(val2) in my example.</description>
		<content:encoded><![CDATA[<p>Pavel,</p>
<p>For primary key it should be the same as primary key can&#8217;t have null values.<br />
It is same as count(val2) in my example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavel</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-115405</link>
		<dc:creator>Pavel</dc:creator>
		<pubDate>Sat, 28 Apr 2007 23:02:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-115405</guid>
		<description>What about count(id) (id is primary key)?
Is count(id) slower than count(*)?

Using innodb + where and myisam + where;</description>
		<content:encoded><![CDATA[<p>What about count(id) (id is primary key)?<br />
Is count(id) slower than count(*)?</p>
<p>Using innodb + where and myisam + where;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peter</title>
		<link>http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/comment-page-1/#comment-114472</link>
		<dc:creator>peter</dc:creator>
		<pubDate>Thu, 26 Apr 2007 16:34:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/#comment-114472</guid>
		<description>Raj,

Good point. It looks like a bug to me as Innodb automatically picks up &quot;shorter&quot; indexes while in practice even first index you tried is shorter. 

The other interesting point I should note - smaller index may not be faster for huge tables, because if you insert data in order primary key tree is often sequential while secondary indexes may be scattered having few sequential pages.</description>
		<content:encoded><![CDATA[<p>Raj,</p>
<p>Good point. It looks like a bug to me as Innodb automatically picks up &#8220;shorter&#8221; indexes while in practice even first index you tried is shorter. </p>
<p>The other interesting point I should note &#8211; smaller index may not be faster for huge tables, because if you insert data in order primary key tree is often sequential while secondary indexes may be scattered having few sequential pages.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
