4 ms·
MySQL does not scan any rows for SELECT COUNT(*) FROM table — the number of records is stored in table metadata. (Mind you, it only works for this kind of query
by rimantas 17y ago
MySQL does not scan any rows for SELECT COUNT(*) FROM table — the number of records is stored in table metadata. (Mind you, it only works for this kind of query, as soon as you add WHERE the story changes).
On the other hand, MyISAM only has table level locks, not row level.
I guess it is time for you to analyze what your app does with DB and how it can affect locking…
- jfarmer 17y agoSort of true -- for the InnoDB engine SELECT COUNT(*) FROM table is more complicated because each transaction has its own view of the table. So unlike MyISAM (which uses one big table-level lock to guarantee consistency), it can't store a row count on a per-table basis.