Re: count * performance issue

Поиск
Список
Период
Сортировка
От Greg Smith
Тема Re: count * performance issue
Дата
Msg-id Pine.GSO.4.64.0803072348050.4777@westnet.com
обсуждение исходный текст
Ответ на Re: count * performance issue  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: count * performance issue
Список pgsql-performance
On Fri, 7 Mar 2008, Tom Lane wrote:

> Well, scanning an index to get a count might be significantly faster
> than scanning the main table, but it's hardly "instantaneous".  It's
> still going to take time proportional to the table size.

If this is something that's happening regularly, you'd have to hope that
most of the index is already buffered in memory somewhere though, so now
you're talking a buffer/OS cache scan that doesn't touch disk much.
Should be easier for that to be true because the index is smaller than the
table, right?

I know when I'm playing with pgbench the primary key index on the big
accounts table is 1/7 the size of the table, and when using that table
heavily shared_buffers ends up being mostly filled with that index. The
usage counts are so high on the index blocks relative to any section of
the table itself that they're very sticky in memory.  And that's toy data;
on some of the webapps people want these accurate counts for the ratio of
index size to table data is even more exaggerated (think web forum).

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

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

Предыдущее
От: "petchimuthu lingam"
Дата:
Сообщение: Re: Confirmação de envio / Sending confirmation (captchaid:13266b402f09)
Следующее
От: Mark Mielke
Дата:
Сообщение: Re: count * performance issue