sql - mysql count performance -


 select count(*) mytable; select count(table_id) mytable; //table_id primary_key 

both query running slow on table 10 million rows. wondering why since wouldn't easy mysql keep counter gets updated on insert,update , delete?
, there way improve query? used explain didn't much.

as cherouvim pointed out in comments, depends on storage engine.

myisam keep count of table rows, , can keep accurate since locks myisam supports table lock.

innodb supports transactions, , needs table scan count rows.

http://www.mysqlperformanceblog.com/2006/12/01/count-for-innodb-tables/


Comments

Popular posts from this blog

html - How can i make an element from a bottom stacking context stays in front of another higher stacking context? -

python - TypeError: start must be a integer -

html - href attribute breaking an element -