pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
performance comparison: DISTINCT and GROUP BY
2+ messages / 2 participants
[nested] [flat]

* performance comparison: DISTINCT and GROUP BY
@ 2002-08-19 11:22 Devrim GUNDUZ <devrim@oper.metu.edu.tr>
  2002-08-19 12:26 ` Re: performance comparison: DISTINCT and GROUP BY Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  0 siblings, 1 reply; 2+ messages in thread

From: Devrim GUNDUZ @ 2002-08-19 11:22 UTC (permalink / raw)
  To: pgsql-sql


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
		-------------------------------------




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: performance comparison: DISTINCT and GROUP BY
  2002-08-19 11:22 performance comparison: DISTINCT and GROUP BY Devrim GUNDUZ <devrim@oper.metu.edu.tr>
@ 2002-08-19 12:26 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
  0 siblings, 0 replies; 2+ messages in thread

From: Christopher Kings-Lynne @ 2002-08-19 12:26 UTC (permalink / raw)
  To: Devrim GUNDUZ <devrim@oper.metu.edu.tr>; pgsql-sql

Hi Devrim,

You can use the EXPLAIN ANALYZE syntax to find out quite easily.

Chris

----- Original Message ----- 
From: "Devrim GUNDUZ" <devrim@oper.metu.edu.tr>
To: "PostgreSQL Mailing Lists-SQL" <pgsql-sql@postgresql.org>
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)
> 




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-08-19 12:26 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-08-19 11:22 performance comparison: DISTINCT and GROUP BY Devrim GUNDUZ <devrim@oper.metu.edu.tr>
2002-08-19 12:26 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>

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