Re: COUNT(*) on innodb
Posted by:
James Day
Date: November 24, 2005 08:00PM
One option you could try is to have an index on a small field or small part of a field and try counting with a use or force index option specifying that index. It would still be a full scan but of an amount of data which may more easily fit in RAM.
If you have an autoincrement field and deletes are uncommon, you could compare the minumum and maximum values of the indexed autoincrement column to get a reasonable count with only two index checks. If you need more accuracy, you could periodically store the counter and accurate record count and subtract that value from the current value.
If you know the timestamp of a saved count and have an index on a timestamp column you could relatively quickly count only the records with a timestamp greater than that using the index.
James Day
Support engineer, MySQL AB
Subject
Views
Written By
Posted
12649
November 24, 2005 09:15AM
4861
November 24, 2005 09:46AM
4593
November 24, 2005 11:53AM
4265
November 24, 2005 12:16PM
4224
November 24, 2005 12:39PM
3871
November 24, 2005 12:55PM
4387
November 24, 2005 01:03PM
3372
November 24, 2005 01:11PM
3319
November 24, 2005 01:32PM
3069
November 24, 2005 02:07PM
Re: COUNT(*) on innodb
3607
November 24, 2005 08:00PM
3074
November 24, 2005 08:38PM
2926
November 25, 2005 05:15PM
Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
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.