Re: Can this be indexed?

From: Brent Wood <b(dot)wood(at)niwa(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Can this be indexed?
Date: 2004-11-07 20:30:17
Message-ID: 20041108092555.M64803@storm-user.niwa.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> >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;
> >
> >Indexes cannot be used for retrieving results...

I'm not sure if it would improve performance at all, given the entire
table needs to be scanned anyway, but add a where clause "where id > 0"
should allow an index on id to be used.

Possibly a bit like speeding up "select max(id) from ..."

Someone who knows more about the internals of Postgis can prob comment on
the validity/idiocy of this suggestion :-)

Brent Wood

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gary L. Burnore 2004-11-07 20:37:44 Re: RFD: comp.databases.postgresql.general
Previous Message Greg Stark 2004-11-07 20:16:58 Re: SQL question