Re: Slow count(*) again...

Поиск
Список
Период
Сортировка
От Vitalii Tymchyshyn
Тема Re: Slow count(*) again...
Дата
Msg-id 4CB4149D.8030803@gmail.com
обсуждение исходный текст
Ответ на Re: Slow count(*) again...  (Craig James <craig_james@emolecules.com>)
Ответы Re: Slow count(*) again...
Список pgsql-performance
11.10.10 20:46, Craig James написав(ла):
>
> First of all, it's not true. There are plenty of applications that
> need an exact answer. Second, even if it is only 1%, that means it's
> 1% of the queries, not 1% of people. Sooner or later a large fraction
> of developers will run into this. It's probably been the most-asked
> question I've seen on this forum in the four years I've been here.
> It's a real problem, and it needs a real solution.
>
> I know it's a hard problem to solve, but can we stop hinting that
> those of us who have this problem are somehow being dense?
>
BTW: There is a lot of talk about MVCC, but is next solution possible:
1) Create a page information map that for each page in the table will
tell you how may rows are within and if any write (either successful or
not) were done to this page. This even can be two maps to make second
one really small (a bit per page) - so that it could be most time in-memory.
2) When you need to to count(*) or index check - first check if there
were no writes to the page. If not - you can use count information from
page info/index data without going to the page itself
3) Let vacuum clear the bit after frozing all the tuples in the page (am
I using terminology correctly?).

In this case all read-only (archive) data will be this bit off and
index/count(*) will be really fast.
Am I missing something?

Best regards, Vitalii Tymchyshyn.

В списке pgsql-performance по дате отправления:

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: Slow count(*) again...
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: Slow count(*) again...