Re: Group by more efficient than distinct?

From: Thomas Pundt <mlists(at)rp-online(dot)de>
To: pgsql-performance(at)postgresql(dot)org, Francisco Reyes <lists(at)stringsutils(dot)com>
Subject: Re: Group by more efficient than distinct?
Date: 2008-04-18 08:25:04
Message-ID: 200804181025.04277.mlists@rp-online.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Freitag, 18. April 2008, Francisco Reyes wrote:
| I am trying to get a distinct set of rows from 2 tables.
| After looking at someone else's query I noticed they were doing a group by
| to obtain the unique list.
|
| After comparing on multiple machines with several tables, it seems using
| group by to obtain a distinct list is substantially faster than using
| select distinct.
|
| Is there any dissadvantage of using "group by" to obtain a unique list?

Searching the archives suggests that the code related to "group by" is much
newer than the one related to "distinct" and thus might benefit from more
optimization paths.

Ciao,
Thomas

--
Thomas Pundt <thomas(dot)pundt(at)rp-online(dot)de> ---- http://rp-online.de/ ----

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Gregory Stark 2008-04-18 09:36:02 Re: Group by more efficient than distinct?
Previous Message Greg Smith 2008-04-18 06:47:22 Re: Strange behavior: pgbench and new Linux kernels