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