Faster way to know the total number of rows in MySQL database?

Posted by Starx on Stack Overflow See other posts from Stack Overflow or by Starx
Published on 2010-05-26T16:56:20Z Indexed on 2010/05/26 21:51 UTC
Read the original article Hit count: 228

Filed under:
|
|

If I need to know the total number of rows in a table of database I do something like this:

$query = "SELECT * FROM tablename WHERE link='1';";
$result = mysql_query($query);
$rows = mysql_fetch_array($result);
$count = count($rows);

So you see the total number of data is recovered scanning through the entire database.

Is there a better way?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql