NYCPHP Meetup

[nycphp-talk] Re: MySQL doubt

Adam Fields fields at hedge.net
Fri Jan 14 00:43:10 EST 2005


On Fri, Jan 14, 2005 at 12:36:48AM -0500, Faber Fedor wrote:
> On 14/01/05 10:53 +0530, Sajith A wrote:
> > I'm not sure whether i should post this here. Correct me if i'm
> > wrong.. I would like to know
> > whether there is any performance difference between. "SELECT count(*)
> > FROM table" and "SELECT count(field) FROM table".
> 
> Depends on the table. Read http://dev.mysql.com/doc/mysql/en/EXPLAIN.html 
> then do
> 
> EXPLAIN SELECT count(*) FROM table;
> 
> EXPLAIN SELECT count(field) from table;
> 
> at the mysql prompt and let us know what you find.

This won't show anything different - there's no where clause, and the
row determination will be the same. That doesn't mean one isn't
faster because you're moving less data around.

I hope that it would optimize this to reading off an internal row
counter rather than fetching all of the rows and counting them. In the
former case, they should be the same. If it's doing the latter,
count(field) will be faster.

But I don't know for sure.

-- 
				- Adam

-----
** Internet users who enjoyed this email also clicked on
     this link to my weblog --> http://www.aquick.org/blog
[ http://www.adamfields.com ][ http://del.icio.us/fields ]
[ http://www.aquick.org/photoblog ]





More information about the talk mailing list