pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Neil Conway <neilc@samurai.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Markus Schaber <schabios@logi-track.com>
Cc: PostgreSQL Performance List <pgsql-performance@postgresql.org>
Subject: Re: Multiple Uniques
Date: Fri, 10 Sep 2004 09:06:23 +1000
Message-ID: <4140E1EF.1040303@samurai.com> (raw)
In-Reply-To: <19516.1094134957@sss.pgh.pa.us>
References: <20040902154340.5b1a669a@kingfisher.intern.logi-track.com>
	<19516.1094134957@sss.pgh.pa.us>

Tom Lane wrote:
> Markus Schaber <schabios@logi-track.com> writes:
>>So, now my question is, why does the query optimizer not recognize that
>>it can throw away those "non-unique" Sort/Unique passes?
> 
> Because the issue doesn't come up often enough to justify expending
> cycles to check for it.

How many cycles are we really talking about, though? I have a patch 
which I'll send along in a few days which implements a similar 
optimization: if a subselect is referenced by EXISTS or IN, we can 
discard DISTINCT and ORDER BY clauses in the subquery (actually, we 
can't discard ORDER BY in the case of IN if LIMIT is also specified, but 
the point remains). It's very cheap computationally for the planner to 
do this simplification, and I'd imagine doing the equivalent 
simplifications for UNION is similarly cheap.

While I understand what you're saying WRT to it being a silly query, in 
the real world people make mistakes...

-Neil



view thread (7+ messages)  latest in thread

Message-ID: <4140E1EF.1040303@samurai.com>
Permalink:  ../4140E1EF.1040303@samurai.com/
Also on:    postgresql.org/message-id/4140E1EF.1040303@samurai.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: neilc@samurai.com, tgl@sss.pgh.pa.us, schabios@logi-track.com
  Subject: Re: Multiple Uniques
  In-Reply-To: <4140E1EF.1040303@samurai.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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