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

From: Culley Harrelson <harrelson(at)gmail(dot)com>
To: Tino Wildenhain <tino(at)wildenhain(dot)de>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: does "select count(*) from mytable" always do a seq scan?
Date: 2005-01-07 17:09:49
Message-ID: 529825a30501070909256d76cd@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 07 Jan 2005 16:17:16 +0100, Tino Wildenhain <tino(at)wildenhain(dot)de> wrote:
>
> How do you think an index would help if you do an unconditional
> count(*)?

I really don't know <grin>. I don't know the inner workings of
database internals but I would guess that there would be some
optimized way of counting the nodes in an index tree that would be
faster than sequentially going through a table.... I suppose there is
no free lunch.

One row, two rows, three rows, four rows, five rows.... <snore>

culley

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-01-07 17:21:29 Re: Transaction size
Previous Message Alban Hertroys 2005-01-07 17:06:34 Transaction size