MySQL get the number of rows in an innodb table

前端 未结 4 977
星月不相逢
星月不相逢 2021-02-08 14:33

I have a table using innodb. I know the table has roughly 89 million rows. Using

SELECT COUNT(*) FROM table;

takes about five minutes to run. I

4条回答
  •  情书的邮戳
    2021-02-08 15:14

    If you are ok with approximate number of records, you can use output of "explain".

    Simplified verion of the code is

    $result = mysql_query('explain SELECT count(*) from TABLE_NAME');
    $row = mysql_fetch_assoc($result);
    echo $row['rows'];
    

提交回复
热议问题