Performance tradeoff

From: "Shawn Chisholm" <schisholm(at)sandvine(dot)com>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Performance tradeoff
Date: 2005-03-02 17:52:10
Message-ID: 71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi All,

I am wondering about the relative performance of "insert into table1 select distinct a,b from ..." and "insert into table1 select a,b from ... group by a,b" when querying tables of different sizes (10K, 100K, 1s, 10s, 100s of millions of rows).

The distinct way tends to sort/unique and the group by tends to hash aggregate... any opinions on which is better?

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?

Thanks,

Shawn

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Ragnar Hafstað 2005-03-02 18:13:47 Re: Help with tuning this query
Previous Message John Arbash Meinel 2005-03-02 17:38:24 Re: Help with tuning this query