Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 8B54D2E003D for ; Fri, 18 Apr 2008 05:54:56 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 79450-08 for ; Fri, 18 Apr 2008 05:54:53 -0300 (ADT) X-Greylist: delayed 00:32:00.937059 by SQLgrey-1.7.5 Received: from mail.rp-online.de (mail.rp-online.de [149.221.1.199]) by developer.postgresql.org (Postfix) with ESMTP id 7658F2E0037 for ; Fri, 18 Apr 2008 05:54:53 -0300 (ADT) Received: from idefix.d.rp-online.de (idefix.d.rp-online.de [149.221.100.194]) by mail.rp-online.de (Postfix) with ESMTP id 4594A307BA; Fri, 18 Apr 2008 10:22:49 +0200 (CEST) From: Thomas Pundt Reply-To: Thomas Pundt Organization: RP Online GmbH To: pgsql-performance@postgresql.org, Francisco Reyes Subject: Re: Group by more efficient than distinct? Date: Fri, 18 Apr 2008 09:25:04 +0100 User-Agent: KMail/1.9.9 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200804181025.04277.mlists@rp-online.de> X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.10/RELEASE, bases: 18042008 #639267, status: clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/264 X-Sequence-Number: 29757 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 ---- http://rp-online.de/ ----