Re: count(*) index - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: count(*) index
Date
Msg-id 20050107194541.GA15048@wolff.to
Whole thread Raw
In response to count(*) index  (Tomka Gergely <tomka@zeus.gau.hu>)
List pgsql-novice
On Fri, Jan 07, 2005 at 19:22:56 +0100,
  Tomka Gergely <tomka@zeus.gau.hu> wrote:
> Hi!
>
> Yes, i know, mvcc, and can't use indexes. And i know the workaround for
> max() and min(). Is there some workaround for count()?
>
> select count(*) from table where field=1;
>
> and field has a nice index. And this is slooooow.

If there are few records where field=1 then an index will be used.

You may get better performance maintaining a count table using triggers.
This may not work well of there are lots of concurrent updates.

pgsql-novice by date:

Previous
From: "Julie Cottin"
Date:
Subject: Driver Information Please
Next
From: Jeffrey Melloy
Date:
Subject: Re: Duplicating A Row