Re: does "select count(*) from mytable" always do a seq - Mailing list pgsql-general

From Pierre-Frédéric Caillaud
Subject Re: does "select count(*) from mytable" always do a seq
Date
Msg-id opska7u2ixcq72hf@musicbox
Whole thread Raw
In response to Re: does "select count(*) from mytable" always do a seq  (Alex Turner <armtuk@gmail.com>)
List pgsql-general
> (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).

    postgres knows that count(*) is just "count the rows", you can use
count(1), it makes no difference...

>
> 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
>>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>



pgsql-general by date:

Previous
From: Pierre-Frédéric Caillaud
Date:
Subject: Re: PYTHON, ODBC
Next
From: Jeff Davis
Date:
Subject: general list