Re: Can this be indexed?

From: "Ed L(dot)" <pgsql(at)bluepolka(dot)net>
To: "Net Virtual Mailing Lists" <mailinglists(at)net-virtual(dot)com>, "Pgsql General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Can this be indexed?
Date: 2004-11-06 16:30:30
Message-ID: 200411060930.30859.pgsql@bluepolka.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Saturday November 6 2004 7:34, Net Virtual Mailing Lists wrote:
> Is there a way to create an index that would make this query be efficient
> and not perform a sequential scan?
>
> SELECT count(*) AS count,id FROM sometable GROUP BY id;
>
> .. I've considered creating a rule on this table which would put the
> results of this into another table anytime it is updated, but I thought
> there might be an easier way.

Since you have no "WHERE" clause and you want to group by id, I believe
pgsql has to scan all id values. Those id values are only fully stored in
the table, so I don't think so.

Ed

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2004-11-06 16:42:20 superuser equality
Previous Message Net Virtual Mailing Lists 2004-11-06 15:49:04 Re: Can this be indexed?