Re: Check each of base restriction clauses for constant-FALSE-or-NULL

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Check each of base restriction clauses for constant-FALSE-or-NULL
Дата
Msg-id CAApHDvoYfnHCxfEUayqhf-jiV=kO-J7Oh6Zd9Zq9DDYw27PHeg@mail.gmail.com
обсуждение исходный текст
Ответ на Check each of base restriction clauses for constant-FALSE-or-NULL  (Richard Guo <guofenglinux@gmail.com>)
Ответы Re: Check each of base restriction clauses for constant-FALSE-or-NULL  (Richard Guo <guofenglinux@gmail.com>)
Список pgsql-hackers
On Sat, 7 Oct 2023 at 22:44, Richard Guo <guofenglinux@gmail.com> wrote:
>
> In relation_excluded_by_constraints() when we're trying to figure out
> whether the relation need not be scanned, one of the checks we do is to
> detect constant-FALSE-or-NULL restriction clauses.  Currently we perform
> this check only when there is exactly one baserestrictinfo entry, and
> the comment explains this as below.
>
>  * Regardless of the setting of constraint_exclusion, detect
>  * constant-FALSE-or-NULL restriction clauses.  Because const-folding will
>  * reduce "anything AND FALSE" to just "FALSE", any such case should
>  * result in exactly one baserestrictinfo entry.

Coincidentally (?), I saw the same thing just a few weeks ago while
working on [1].  I made the exact same adjustment to the code in
relation_excluded_by_constraints() as you have.

I wasn't really expecting the baserestrictinfo list to be excessively
long, and if it ever was, I think looking at things like selectivity
estimations would by far drown out looping over the entire list in
relation_excluded_by_constraints() rather than just looking at the
first item in the list.

After making the change, I saw the same regression test change as you
did, but didn't really feel like it was worth tackling separately from
the patch that we were working on.

David

[1] https://postgr.es/m/CAApHDvpkfS1hY3P4DWbOw6WCgRrja=yDLoEz+5g+E2z19Upsrg@mail.gmail.com



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

Предыдущее
От: Esteban Zimanyi
Дата:
Сообщение: Fwd: Advice about preloaded libraries
Следующее
От: Aleksander Alekseev
Дата:
Сообщение: Re: Add const to values and nulls arguments