var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Record count
What is the most efficient way to find the record count of a large table?
Here are the two way's i've did it, would just like opinions on which one is better and more efficient. I'm coding PHP which shouldn't make a difference I'm just wondering about the SQL syntax.
select count(*) as myCount from myTable
in the above after selecting all I use the mysql_num_rows function.
select * from myTable
The first returns only a single row (and column)
The second returns the entire data from the table.
Now think about which is more efficient...
That's what I figured but I also figured it had to go through the whole table to get the count.
no, it doesn't always do that -- myisam tables store the count, so getting the count is lightning fast
Originally Posted by RandyRiegel
but even if the database has to count all the rows, that's still a lot faster than exporting all the rows to let you count them