Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6AC174754A6 for ; Mon, 19 Aug 2002 08:26:50 -0400 (EDT) Received: from mail.iinet.net.au (mail-06.iinet.net.au [203.59.3.38]) by postgresql.org (Postfix) with SMTP id 288654754A3 for ; Mon, 19 Aug 2002 08:26:49 -0400 (EDT) Received: (qmail 9602 invoked from network); 19 Aug 2002 12:26:44 -0000 Received: from unknown (HELO SOL) (203.59.159.124) by mail.iinet.net.au with SMTP; 19 Aug 2002 12:26:44 -0000 Message-ID: <003501c2477b$a1114bd0$0200a8c0@SOL> From: "Christopher Kings-Lynne" To: "Devrim GUNDUZ" , "PostgreSQL Mailing Lists-SQL" References: Subject: Re: performance comparison: DISTINCT and GROUP BY Date: Mon, 19 Aug 2002 20:26:21 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200208/265 X-Sequence-Number: 9111 Hi Devrim, You can use the EXPLAIN ANALYZE syntax to find out quite easily. Chris ----- Original Message ----- From: "Devrim GUNDUZ" To: "PostgreSQL Mailing Lists-SQL" Sent: Monday, August 19, 2002 7:22 PM Subject: [SQL] performance comparison: DISTINCT and GROUP BY > > Hi, > > We have two different queries: > > SELECT name,surname FROM my_table GROUP BY name; > > and > > SELECT DISTINCT on(name) name,surname * FROM my_table; > > which gives us the same result. > > Do these queries differ by their performances? I mean, which one works > faster? DISTINCT or GROUP BY? > > Best regards. > > -- > > Devrim GUNDUZ > > devrim@oper.metu.edu.tr Tel : (312) 295 9318 > devrim.gunduz@linux.org.tr Faks : (312) 295 9494 > > Web : http://devrim.oper.metu.edu.tr > ------------------------------------- > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >