Fastest method for Counting rows

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

The difference isn't worth talking about. Either way it's fast. The stats will vary a fiar bit depending upon your hardware.

EDIT | Since we're on page 2 I'll point out that I was referring to 'select * ' and 'select colname ' as opposed to comparing mysql_num_rows() to count(*) ;)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Because MySQL is pretty fast with selects i don't think a second query will add that much overhead..
Btw, once you start using LIMIT in your select * clause, you can't use the mysql_num_rows anymore anyway..
Post Reply