Jump to content

Count number of rows


The Little Guy

Recommended Posts

Is there a faster way to count the number of rows in a database other than mysql_num_rows? If there are over 10,000 reccords, wont mysql_num_rows be slower since you had to query all those rows first? I want to show how may records there are total in two different tables, one for number of users, and one for number of files(1 file = 1 row). So basically this will be on the home page, and will be ran many times, that seems like there will be too many connections to the database, if there are many page loads of the home page, then there are also many loads in the users section as well. Any other way to do this?

$sql = mysql_query("SELECT * FROM `files`");
$sql2 = mysql_query("SELECT * FROM `users`");
$rows_return = mysql_num_rows($sql);
$rows_return2 = mysql_num_rows($sql2);
echo $rows_return;
echo $rows_return2;
Link to comment
https://forums.phpfreaks.com/topic/35741-count-number-of-rows/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.