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

后端 未结 10 530
后悔当初
后悔当初 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:00

    MyISAM tables already store the row count

    SELECT COUNT(*) FROM table
    

    on a MyISAM table simply reads that value. It doesn't scan the table or the index(es). So, it's just as fast or faster than reading the value from a different table.

提交回复
热议问题