Whats the best way to get total # of records in a mysql table with php?

后端 未结 10 529
后悔当初
后悔当初 2021-01-12 05:51

Whats the most efficient way of selecting total number of records from a large table? Currently, Im simply doing

$result = mysql_query(\"SELECT id FROM table         


        
10条回答
  •  不知归路
    2021-01-12 06:01

    Just wanted to note that SHOW TABLE STATUS returns a Rows column, though I can't speak to its efficiency. Some light Googling turns up reports of slowness in MySQL 4 over two years ago. Might make for interesting time trials.

    Also note the InnoDB caveat regarding inaccurate counts.

提交回复
热议问题