logo       

Re: InnoDB - count() slow: msg#01124

db.mysql.general

Subject: Re: InnoDB - count() slow

In the last episode (Jun 29), Oleg said:
> Hello,
>
> The query SELECT COUNT(*) FROM table works very slow - for 50 millions
> of records it tooks around 5-10 minutes.
> Is it a bug or a feature?

"Feature". Innodb tables do not cache the rowcount like MyISAM tables
do, so mysql has to walk the entire table to get a count. If you have
a unique index, it should be able to scan that instead, which will be
faster.

--
Dan Nelson
dnelson@xxxxxxxxxxxxxxx

---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <mysql-thread113373@xxxxxxxxxxxxxxx>
To unsubscribe, e-mail
<mysql-unsubscribe-gcdmg-mysql=m.gmane.org@xxxxxxxxxxxxxxx>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise