Re: Improving NOT IN

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Improving NOT IN
Дата
Msg-id 12336.1170196465@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Improving NOT IN  ("Simon Riggs" <simon@2ndquadrant.com>)
Ответы Re: Improving NOT IN  ("Simon Riggs" <simon@2ndquadrant.com>)
Re: Improving NOT IN  ("Simon Riggs" <simon@2ndquadrant.com>)
Список pgsql-hackers
"Simon Riggs" <simon@2ndquadrant.com> writes:
> First we need to show that the referenced table's PK values are a fully
> continuous sequence of integers with no gaps.

Since that is unlikely to be the case, I can't see that this is worth
implementing...

> I'll describe this using SQL statements, which execute as SeqScans of
> the PK and then FK tables. There is no preparatory step - no building a
> sort table or preparing a hash table, so these SQL statements always
> execute faster than the fastest current plan.

Except that when you fail to prove it, as you usually will, you have
wasted a complete seqscan of the table, and still have to fall back on
a regular plan.  If the thing were amenable to falling out fairly
quickly on proof failure, it would be better, but AFAICS you don't know
anything until you've completed the whole scan.

I think the NOT IN optimization that *would* be of use is to
automatically transform the NOT IN representation to an
outer-join-with-null-test type of operation, so as to give us a wider
choice of join methods.  However, I'm not sure about correct handling
of NULLs on the RHS in such a scenario.  The existing hashed-IN code
has to jump through some really ugly hoops to give spec-compliant
answers with NULLs.

BTW, your sketch fails in the presence of NULLs on the RHS ...
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: parsenodes vs. primnodes
Следующее
От: "Simon Riggs"
Дата:
Сообщение: Re: Improving NOT IN