Re: SELECT DISTINCT

From: salah jubeh <s_jubeh(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kevin Grittner <kgrittn(at)mail(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT DISTINCT
Date: 2013-01-18 11:05:15
Message-ID: 1358507115.73834.YahooMailNeo@web122206.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the quick response, I would like to add a patch to postgres to do a simple check for  one table,  since this is straight forward. Unfortunatly, I am not familiar too much with postgres source code. So my question is , what are the source files that I need to check and can you please point me to the appropriate developer guide.
 
Regards

________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kevin Grittner <kgrittn(at)mail(dot)com>
Cc: salah jubeh <s_jubeh(at)yahoo(dot)com>; pgsql <pgsql-general(at)postgresql(dot)org>
Sent: Friday, January 18, 2013 2:02 AM
Subject: Re: [GENERAL] SELECT DISTINCT

"Kevin Grittner" <kgrittn(at)mail(dot)com> writes:
> salah jubeh wrote:
>> I think any query that returns a unique column (primary key,
>> unique) which is not duplicated in some way (join) can use this
>> optimisation technique.

> I agree that if the planner searched for that, there would be cases
> where the DISTINCT keyword could be determined to be a noise word.
> The problem with that is that such searching in the planner would
> not be free -- doing it accurately would increase planning cost for
> every query which was legitimately using the feature.

There is actually infrastructure in the planner that could be used for
this, at least for the case where the query selects from just one base
table.  I tend to agree though that adding such a check to every
DISTINCT query would be slowing everybody down to benefit only dubious
queries.  It would be easier to swallow the overhead if there were a
solid case that reasonably-written queries might sometimes need the
optimization.

            regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marcel van Pinxteren 2013-01-18 13:13:27 Re: Case insensitive collation
Previous Message Albe Laurenz 2013-01-18 10:03:29 Re: String comparison and the SQL standard