Re: So, is COUNT(*) fast now?

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: So, is COUNT(*) fast now?
Дата
Msg-id CA+TgmoZd2dBR=qMqJoghSfHud45mZifw-ynRhxOEP0y-L16nVQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: So, is COUNT(*) fast now?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: So, is COUNT(*) fast now?
Re: So, is COUNT(*) fast now?
Re: So, is COUNT(*) fast now?
Список pgsql-hackers
On Fri, Oct 21, 2011 at 2:08 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>> On Fri, Oct 21, 2011 at 1:18 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> I don't know why you'd imagine that touching an index is free, or even
>>> cheap, CPU-wise.  The whole point of the index-only optimization is to
>>> avoid I/O.  When you try it on a case where there's no I/O to be saved,
>>> *and* no shared-buffers contention to be avoided, there's no way it's
>>> going to be a win.
>
>> Well, call me naive, but I would have thought touching six times less
>> data would make the operation run faster, not slower.
>
> It's not "touching six times less data".  It's touching the exact same
> number of tuples either way, just index tuples in one case and heap
> tuples in the other.

Yeah, but it works out to fewer pages.

> You've arranged the test case so that all these
> tuples are in shared buffers already, so there's no data movement to be
> avoided.  What this test case proves is that btree's overhead per index
> tuple touched is significantly more than the cost of the fastest path
> through HeapTupleSatisfiesMVCC, which I don't find surprising
> considering how much sweat has been expended on that code path over the
> years.

I think HeapTupleSatisfiesMVCC is probably being skipped anyway in
this case, since all the heap pages should be PD_ALL_VISIBLE.

> (It may well be that it's not even btree at fault but the per-tuple
> visits to the visibility map ... did you do any oprofiling yet?)

No, but I think that might be a good idea.  Maybe I'll go do that.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Synchronized snapshots versus multiple databases
Следующее
От: Andrew Dunstan
Дата:
Сообщение: psql command for bytea output