select count(*) from table,MyISAM只要简单的读出保存好的行数,注意的是,当count(*)语句包含 where条件时,两种表的操作是一样的
InnoDB 中不保存表的具体行数,也就是说,执行select count(*) from table时,InnoDB要扫描一遍整个表来计算有多少行
希望能够更深入的了解,请问MyISAM是如何保存这个行数的?保存在什么地方?存储方式?如何查询?希望知道的高手赐教!谢谢!
InnoDB 中不保存表的具体行数,也就是说,执行select count(*) from table时,InnoDB要扫描一遍整个表来计算有多少行
希望能够更深入的了解,请问MyISAM是如何保存这个行数的?保存在什么地方?存储方式?如何查询?希望知道的高手赐教!谢谢!
If you are using MyISAM or HEAP tables it reads the information directly from the table information which is lightning fast and is actually the information that show table status displays.
But for InnoDB tables it actually has to perform an index scan on the primary index which can take a while depending on size of table, innodb_buffer_size, hardware etc.
Mysql参考手册都有这样的记录,难道是我看的有问题?
《高性能MYSQL》里面的“MYISAM的COUNT(*)迷思”一节有详细论述。