pgsql: Fix missed optimization in relation_excluded_by_constraints().

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix missed optimization in relation_excluded_by_constraints().
Дата
Msg-id E1qqcR3-0001Xb-15@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix missed optimization in relation_excluded_by_constraints().

In commit 3fc6e2d7f, I (tgl) argued that we only need to check for
a constant-FALSE restriction clause when there's exactly one
restriction clause, on the grounds that const-folding would have
thrown away anything ANDed with a Const FALSE.  That's true just after
const-folding has been applied, but subsequent processing such as
equivalence class expansion could result in cases where a Const FALSE
is ANDed with some other stuff.  (Compare for instance joinrels.c's
restriction_is_constant_false.)  Hence, tweak this logic to check all
the elements of the baserestrictinfo list, not just one; that's cheap
enough to not be worth worrying about.

There is one existing test case where this visibly improves the plan.
There would not be any savings in runtime, but the planner effort and
executor startup effort will be reduced, and anyway it's odd that
we can detect related cases but not this one.

Richard Guo (independently discovered by David Rowley)

Discussion: https://postgr.es/m/CAMbWs4_x3-CnVVrCboS1LkEhB5V+W7sLSCabsRiG+n7+5_kqbg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5d8aa8bcedae7376bd97e79052d606db4e4f8dd4

Modified Files
--------------
src/backend/optimizer/util/plancat.c | 17 +++++++++--------
src/test/regress/expected/join.out   |  8 +++-----
2 files changed, 12 insertions(+), 13 deletions(-)


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Move canAcceptConnections check from ProcessStartupPacket to cal
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Reindent comment in GenericXLogFinish().