Skip site navigation (1) Skip section navigation (2)

performance comparison: DISTINCT and GROUP BY

From: Devrim GUNDUZ <devrim(at)oper(dot)metu(dot)edu(dot)tr>
To: PostgreSQL Mailing Lists-SQL <pgsql-sql(at)postgresql(dot)org>
Subject: performance comparison: DISTINCT and GROUP BY
Date: 2002-08-19 11:22:08
Message-ID: Pine.LNX.4.44.0208191340200.4893-100000@oper.metu.edu.tr (view raw or flat)
Thread:
Lists: 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(at)oper(dot)metu(dot)edu(dot)tr			Tel  : (312) 295 9318
devrim(dot)gunduz(at)linux(dot)org(dot)tr		Faks : (312) 295 9494

		Web : http://devrim.oper.metu.edu.tr
		-------------------------------------


Responses

pgsql-sql by date

Next:From: Christopher Kings-LynneDate: 2002-08-19 12:26:21
Subject: Re: performance comparison: DISTINCT and GROUP BY
Previous:From: Julian ScarfeDate: 2002-08-19 08:01:02
Subject: Re: Ordering with GROUPs

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group