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

Re: PostgreSQL NOT IN performance

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Віталій Тимчишин <tivv00(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: PostgreSQL NOT IN performance
Date: 2008-11-19 14:44:58
Message-ID: 20081119062806.Y58658@megazone.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-performance
On Wed, 19 Nov 2008, [ISO-8859-5]   wrote:

> Query 1:
> select * from t1 where id not in (select id from t2);
>
> Query 2 (gives same result as Q1):
> select * from t1 except all (select id from t2);

It gives the same result as long as no nulls are in either table. If
either table can have a null, the conversion changes the results.

In addition, a conversion like the above only happens to work because t1
only has an id column. If t1 had two columns you'd get an error because
the two sides of except all must have the same number of columns.


In response to

Responses

pgsql-performance by date

Next:From: Віталій ТимчишинDate: 2008-11-19 14:55:18
Subject: Re: PostgreSQL NOT IN performance
Previous:From: Alvaro HerreraDate: 2008-11-19 13:11:43
Subject: Re: PostgreSQL NOT IN performance

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