From: Tom Lane <tgl@sss.pgh.pa.us>
To: Markus Schaber <schabios@logi-track.com>
Cc: PostgreSQL Performance List <pgsql-performance@postgresql.org>
Subject: Re: Multiple Uniques
Date: Thu, 02 Sep 2004 10:22:37 -0400
Message-ID: <19516.1094134957@sss.pgh.pa.us> (raw)
In-Reply-To: <20040902154340.5b1a669a@kingfisher.intern.logi-track.com>
References: <20040902154340.5b1a669a@kingfisher.intern.logi-track.com>
Markus Schaber <schabios@logi-track.com> writes:
> Today, we stumbled about the following query plan on PostGreSQL 7.4.1:
> logigis=# explain select count(id) from (select distinct id from (select distinct ref_in_id as id from streets union select distinct nref_in_id as id from streets) as blubb) as blabb;
> I was somehow irritated by the fact that the Query Plan contains 4 Uniques.
Well, if you write a silly query, you can get a silly plan ...
As you appear to have realized later, given the definition of UNION,
all three of the explicit DISTINCTs are redundant.
> 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.
regards, tom lane
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: tgl@sss.pgh.pa.us, schabios@logi-track.com
Subject: Re: Multiple Uniques
In-Reply-To: <19516.1094134957@sss.pgh.pa.us>
* 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