The Little Guy Posted January 25, 2007 Share Posted January 25, 2007 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; Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 25, 2007 Share Posted January 25, 2007 "SELECT count(*) AS numRows FROM files" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.