Re: does "select count(*) from mytable" always do a seq

Поиск
Список
Период
Сортировка
От Alex Turner
Тема Re: does "select count(*) from mytable" always do a seq
Дата
Msg-id 33c6269f0501081108f134bcc@mail.gmail.com
обсуждение исходный текст
Ответ на Re: does "select count(*) from mytable" always do a seq  (Scott Ribe <scott_ribe@killerbytes.com>)
Ответы Re: does "select count(*) from mytable" always do a seq  (Scott Ribe <scott_ribe@killerbytes.com>)
Re: does "select count(*) from mytable" always do a seq  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
Список pgsql-general
No offense or anything, but that doesn't make any sense.  If you are
running count(*) against a table, it still has to worry about MVCC,
and which rows are visible to your transaction.  What difference does
it make, table or index, the system still has to figure out which rows
are visible in the current transaction, so why not use the index?

(The example is really count(pkey) because count(*) is always going to
do a seq scan I reckon - and could probably never use an index).

Alex Turner
NetEconomist


On Fri, 07 Jan 2005 11:17:32 -0700, Scott Ribe
<scott_ribe@killerbytes.com> wrote:
> > I guess what I"m really asking is why can't you run aggregates over an index?
>
> It's got to do with MVCC and transaction consistency. Running count(*) or an
> aggregate function on an index could include records that should not be
> visible to your current transaction.
>
> --
> Scott Ribe
> scott_ribe@killerbytes.com
> http://www.killerbytes.com/
> (303) 665-7007 voice
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

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

Предыдущее
От: Kris Jurka
Дата:
Сообщение: Re: J2SE 1.5 Cache Rowset(JSR 114 )
Следующее
От: Alex Turner
Дата:
Сообщение: Re: PostgreSQL users on webhosting