pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shawn Chisholm <schisholm@sandvine.com>
To: pgsql-performance@postgresql.org
Subject: Performance tradeoff
Date: Wed, 2 Mar 2005 12:52:10 -0500
Message-ID: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com> (raw)

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




view thread (2+ messages)  latest in thread

Message-ID: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com>
Permalink:  ../71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com/
Also on:    postgresql.org/message-id/71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: schisholm@sandvine.com
  Subject: Re: Performance tradeoff
  In-Reply-To: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com>
  References: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox