From: Manfred Koizar <mkoi-pg@aon.at>
To: Jonathan Moore <moore@discern.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: dum query plan: more info.
Date: Thu, 17 Apr 2003 18:24:24 +0200
Message-ID: <dtkt9votgp8vaernemj05a22di4v3dns15@4ax.com> (raw)
In-Reply-To: <1050530569.20873.120.camel@spunge-bob>
References: <1050530569.20873.120.camel@spunge-bob>
On 16 Apr 2003 15:02:49 -0700, Jonathan Moore <moore@discern.com>
wrote:
>select A.left form pairs A, pairs B where A.left != B.right;
>
>take the DB:
>
>(1,2)
>(2,1)
>(1,5)
>(4,5)
>(5,2)
>
>[...] 4 is the only value that is on the left and only
>on the left.
But this is not the answer to your SQL statement. The correct answer
is:
left
------
1
1
1
1
2
2
2
1
1
1
1
4
4
4
4
4
5
5
5
(19 rows)
What you are looking for is more like
SELECT left FROM pairs
EXCEPT
SELECT right FROM pairs;
>This methoud is order O(n) if both colums have b-tree indexes so you
>don't have to pre sort them othere wise it is O(n*log(n)) as the sort is
>the greatest complexity. In eathere case it is way better then O(n^2)
>for almost any n.
And I'm sure it will not take O(n^2) time in Postgres.
Servus
Manfred
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: mkoi-pg@aon.at, moore@discern.com
Subject: Re: dum query plan: more info.
In-Reply-To: <dtkt9votgp8vaernemj05a22di4v3dns15@4ax.com>
References: <1050530569.20873.120.camel@spunge-bob> <dtkt9votgp8vaernemj05a22di4v3dns15@4ax.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