mysql count performance
问题 select count(*) from mytable; select count(table_id) from mytable; //table_id is the primary_key both query were running slow on a table with 10 million rows. I am wondering why since wouldn't it easy for mysql to keep a counter that gets updated on all insert,update and delete? and is there a way to improve this query? I used explain but didn't help much. 回答1: As cherouvim pointed out in the comments, it depends on the storage engine. MyISAM does keep a count of the table rows, and can keep