From: | "Tomas Vondra" <tv(at)fuzzy(dot)cz> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "Yang Zhang" <yanghatespam(at)gmail(dot)com>, "Tomas Vondra" <tv(at)fuzzy(dot)cz>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Why is this query running slowly? |
Date: | 2011-09-15 14:59:59 |
Message-ID: | 396b58982d6a5fa4bb8d3196e67e2125.squirrel@sq.gransy.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 15 Září 2011, 16:26, Tom Lane wrote:
> Yang Zhang <yanghatespam(at)gmail(dot)com> writes:
>> On Thu, Sep 15, 2011 at 1:22 AM, Tomas Vondra <tv(at)fuzzy(dot)cz> wrote:
>>> [ use a left join instead of NOT IN ]
>
>> This worked great, thank you. Too bad the planner isn't smart enough
>> to do this yet!
>
> It never will be, because they're not equivalent queries. NOT IN has
> different (and very hard-to-optimize) behavior in the face of NULLs in
> the right-hand table.
True, but in this case the subquery selects a PK column (at least I
believe so, we haven't seen the structure), so there should be no NULLs.
So the result should be the same.
Could the planner do this reasoning, i.e. see if there's a NOT NULL
constraint on the column and change the plan accordingly?
Tomas
From | Date | Subject | |
---|---|---|---|
Next Message | Rich Shepard | 2011-09-15 15:01:44 | Re: Cryptic Error Message Importing Table Dump [RESOLVED] |
Previous Message | Harald Fuchs | 2011-09-15 14:30:17 | PostgreSQL 9.1.0 bug? |