Re: COUNT(*) very slowly in large InnoDB table
@Rick James: Give me a try if I got your explanations right :)
If I got him right, COUNT(*) will look for the smallest available index in the InnoDb table. If there is only the ID (as primary key index), a COUNT(id) will be performed. Therefore no significant difference in performance shall be observed between COUNT(*) and COUNT(id).
If there is another index for that table, a COUNT(theOtherIndex) may be faster, because secondary indices are stored out of the main data structure. Therefore less data must be scanned and there is an increase in performance for the SELECT operation.
Finally you may consider using a SHOW TABLE STATUS to get a rough approximation (up to 50% error) of the table's length. In my case this approximation is well enough in 9 of 10 cases.
Dominik
Subject
Views
Written By
Posted
31154
July 13, 2010 11:43AM
9746
July 14, 2010 11:04PM
7413
July 15, 2010 02:24AM
7206
July 15, 2010 08:51AM
3954
July 15, 2010 09:48AM
3744
July 15, 2010 09:09PM
3226
July 16, 2010 12:58AM
4132
July 19, 2010 12:18PM
Re: COUNT(*) very slowly in large InnoDB table
4665
July 19, 2010 12:45PM
3947
July 19, 2010 09:25PM
3274
July 20, 2010 10:38PM
2622
July 21, 2010 11:52AM
3762
July 21, 2010 12:11PM
3959
July 22, 2010 03:23AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.