Re: Performance tradeoff - Mailing list pgsql-performance

From Josh Berkus
Subject Re: Performance tradeoff
Date
Msg-id 200503022131.01658.josh@agliodbs.com
Whole thread Raw
In response to Performance tradeoff  ("Shawn Chisholm" <schisholm@sandvine.com>)
List pgsql-performance
Shawn,

> I can also change the schema to a certain extent, so would it be worthwhile
> to put indices on the queried tables (or refactor them) hoping the distinct
> does an index scan instead of sort...  would the query planner take
> advantage of that?

Use the GROUP BY, with an index on the grouped columns and lots of work_mem
(sort_mem in 7.4).   This will give the planner the option of a hashaggregate
which could be significantly faster than the other methods.

--
Josh Berkus
Aglio Database Solutions
San Francisco

pgsql-performance by date:

Previous
From: John A Meinel
Date:
Subject: Re: Help with tuning this query (more musings)
Next
From: Josh Berkus
Date:
Subject: Re: Help with tuning this query