Re: *very* inefficient choice made by the planner (regarding - Mailing list pgsql-performance

From Tom Lane
Subject Re: *very* inefficient choice made by the planner (regarding
Date
Msg-id 20172.1087568965@sss.pgh.pa.us
Whole thread Raw
In response to Re: *very* inefficient choice made by the planner (regarding  (SZUCS Gábor <surrano@mailbox.hu>)
List pgsql-performance
=?iso-8859-1?Q?SZUCS_G=E1bor?= <surrano@mailbox.hu> writes:
>> It's NULLs inside the subselect that are the issue.
>
> select 1 in (select a from foo)
> select exists ( select 1 from foo where a=1)

> Just a dumb try :)

>   SELECT (exists(select 1 from foo where a isnull) AND NULL)
>        OR exists(select 1 from foo where a=1)

The more general case is where you have a variable (or expression)
on the left of IN.  That could be NULL too, and this still doesn't
give the right result in that case :-(.  With NULL on the left the
correct answer would be FALSE if the subselect has zero rows,
NULL otherwise.

            regards, tom lane

pgsql-performance by date:

Previous
From: Richard Huxton
Date:
Subject: Re: memory allocation
Next
From: Tom Lane
Date:
Subject: Re: Major differences between oracle and postgres performance - what can I do ?