3 ms·
count(*) is optimized by mysql http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/ http://www.mysqlperformanceblog.com/2007/04/10/count-vs-coun..
by there 18y ago
count(*) is optimized by mysql
http://www.mysqlperformanceblog.com/2007/04/10/count-vs-countcol/ http://www.mysqlperformanceblog.com/2007/04/10/count-vs-coun...
- jey 18y agoGood, because that would be really pathetic to not perform the simplest dead code elimination.
- amarcus 18y agoOnly for MyISAM tables...its a different story with Innodb: http://www.mysqlperformanceblog.com/2006/12/01/count-for-innodb-tables/ http://www.mysqlperformanceblog.com/2006/12/01/count-for-inn...
- neilc 18y agoNot AFAICS; count( * ) and count( 1 ) are trivially equivalent, and this doesn't depend on the storage engine being used. It is true that count( * ) without a WHERE clause is much faster in MyISAM than in Innodb (or Postgres), but that is a different optimization (count( * ) => metadata lookup, not count( 1 ) => count( * )).