Not the answer you need?
Register and ask your own question!
Many Forum changes were implemented on Tue 22 Sep. Read about new Ranks, Scoring, and Reactions.
Email [email protected] for any comments or concerns.

cout(*) a Perf Killer?

RHATRHAT EntrantInactive User Role Beginner
Hi I just want to aks whether you all can
confirm, that count(*)s from big tables are performance killers?!

I think so because a simple access by primary key takes virtually no time, while a count(*) takes 300ms.



  • jrabbitjrabbit Contributor Inactive User Role Beginner
    They are instant on myiasm tables, but slower on innodb. tml
  • sterinsterin Mentor Inactive User Role Contributor
    Most count(*) performs a range scan on an index.

    The only specific case when this is not done is the MyISAM special case when you select count(*) of the entire table. And that is because MyISAM keeps the total nr of rows in the table as meta data for the table.

    Best way to keep the time short is to make sure that you have enough RAM and allowing enough memory for caching. That way this index range scan will be performed entirely in RAM which usually is fast enough for most needs.
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.