Re: Allowing NOT IN to use ANTI joins

Поиск
Список
Период
Сортировка
От Marti Raudsepp
Тема Re: Allowing NOT IN to use ANTI joins
Дата
Msg-id CABRT9RCKu1vLBkbFo_BDbKFMSEF6Be2z9hsmtuVjGCBWyevT7Q@mail.gmail.com
обсуждение исходный текст
Ответ на Allowing NOT IN to use ANTI joins  (David Rowley <dgrowleyml@gmail.com>)
Ответы Re: Allowing NOT IN to use ANTI joins
Re: Allowing NOT IN to use ANTI joins
Список pgsql-hackers
On Sun, Jun 8, 2014 at 3:36 PM, David Rowley <dgrowleyml@gmail.com> wrote:
> Currently pull_up_sublinks_qual_recurse only changes the plan for NOT EXISTS
> queries and leaves NOT IN alone. The reason for this is because the values
> returned by a subquery in the IN clause could have NULLs.

I believe the reason why this hasn't been done yet, is that the plan
becomes invalid when another backend modifies the nullability of the
column. To get it to replan, you'd have to introduce a dependency on
the "NOT NULL" constraint, but it's impossible for now because there's
no pg_constraint entry for NOT NULLs.

The only way to consistently guarantee nullability is through primary
key constraints. Fortunately that addresses most of the use cases of
NOT IN(), in my experience.

See the comment in check_functional_grouping:
* Currently we only check to see if the rel has a primary key that is a* subset of the grouping_columns.  We could also
useplain unique constraints* if all their columns are known not null, but there's a problem: we need* to be able to
representthe not-null-ness as part of the constraints added* to *constraintDeps.  FIXME whenever not-null constraints
getrepresented* in pg_constraint.
 

The behavior you want seems somewhat similar to
check_functional_grouping; maybe you could unify it with your
targetListIsGuaranteedNotToHaveNulls at some level. (PS: that's one
ugly function name :)

Regards,
Marti



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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Allowing NOT IN to use ANTI joins
Следующее
От: Vik Fearing
Дата:
Сообщение: Re: "RETURNING PRIMARY KEY" syntax extension