Re: count(*) slow on large tables

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: count(*) slow on large tables
Дата
Msg-id 200310041819.h94IJkV07596@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: count(*) slow on large tables  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: count(*) slow on large tables  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: count(*) slow on large tables  (Josh Berkus <josh@agliodbs.com>)
Re: count(*) slow on large tables  (Shridhar Daithankar <shridhar_daithankar@persistent.co.in>)
Список pgsql-performance
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> ... and it would give the wrong answers.  Unless the cache is somehow
> >> snapshot-aware, so that it can know which other transactions should be
> >> included in your count.
>
> > The cache is an ordinary table, with xid's on every row.  I meant it
> > would require no index/heap scans of the large table --- it would still
> > require a scan of the "count" table.
>
> Oh, that idea.  Yeah, I think we had concluded it might work.  You'd
> better make the TODO item link to that discussion, because there's sure
> been plenty of discussion of ideas that wouldn't work.

OK, I beefed up the TODO:

    * Use a fixed row count and a +/- count with MVCC visibility rules
      to allow fast COUNT(*) queries with no WHERE clause(?)

I can always give the details if someone asks.  It doesn't seem complex
enough for a separate TODO.detail item.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: count(*) slow on large tables
Следующее
От: Tom Lane
Дата:
Сообщение: Re: count(*) slow on large tables