Re: [PERFORM] How to use indexes for GROUP BY

2011-01-24 Thread Dimi Paun
On Mon, 2011-01-24 at 12:33 -0700, Scott Marlowe wrote: > As another poster observed, you're running an ancient version of pgsql > from a performance perspective. Upgrading to 8.4 or 9.0 would make a > huge difference in overall performance, not just with one or two > queries. Thanks for the tri

Re: [PERFORM] How to use indexes for GROUP BY

2011-01-24 Thread hubert depesz lubaczewski
On Mon, Jan 24, 2011 at 01:29:01PM -0500, Dimi Paun wrote: > Hi folks, > > I have a table like so: > > create table tagRecord ( > uid varchar(60) primary key, > [bunch of other fields] > location varchar(32), > creationTStimestamp > ); > create index idx_tagda

Re: [PERFORM] How to use indexes for GROUP BY

2011-01-24 Thread Scott Marlowe
On Mon, Jan 24, 2011 at 11:29 AM, Dimi Paun wrote: Two very quick points: > tts_server_db=# explain analyze select location, max(creationTS) from > tagrecord group by location; >                                                       QUERY PLAN > -

Re: [PERFORM] How to use indexes for GROUP BY

2011-01-24 Thread Shaun Thomas
On 01/24/2011 12:29 PM, Dimi Paun wrote: I want to simply get the latest "creationTS" for each location, but that seems to result in a full table scan: tts_server_db=# explain analyze select location, max(creationTS) from tagrecord group by location; Try this, it *might* work: select DISTINC

[PERFORM] How to use indexes for GROUP BY

2011-01-24 Thread Dimi Paun
Hi folks, I have a table like so: create table tagRecord ( uid varchar(60) primary key, [bunch of other fields] location varchar(32), creationTStimestamp ); create index idx_tagdata_loc_creationTS on tagRecord(location, creationTS); The number of individual v