pgsql: Fix some questionable edge-case behaviors in add_path() and frie

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix some questionable edge-case behaviors in add_path() and frie
Дата
Msg-id E1Z0GkK-0006eL-Qa@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix some questionable edge-case behaviors in add_path() and friends.

add_path_precheck was doing exact comparisons of path costs, but it really
needs to do them fuzzily to be sure it won't reject paths that could
survive add_path's comparisons.  (This can only matter if the initial cost
estimate is very close to the final one, but that turns out to often be
true.)

Also, it should ignore startup cost for this purpose if and only if
compare_path_costs_fuzzily would do so.  The previous coding always ignored
startup cost for parameterized paths, which is wrong as of commit
3f59be836c555fa6; it could result in improper early rejection of paths that
we care about for SEMI/ANTI joins.  It also always considered startup cost
for unparameterized paths, which is just as wrong though the only effect is
to waste planner cycles on paths that can't survive.  Instead, it should
consider startup cost only when directed to by the consider_startup/
consider_param_startup relation flags.

Likewise, compare_path_costs_fuzzily should have symmetrical behavior
for parameterized and unparameterized paths.  In this case, the best
answer seems to be that after establishing that total costs are fuzzily
equal, we should compare startup costs whether or not the consider_xxx
flags are on.  That is what it's always done for unparameterized paths,
so let's make the behavior for parameterized  paths match.

These issues were noted while developing the SEMI/ANTI join costing fix
of commit 3f59be836c555fa6, but we chose not to back-patch these fixes,
because they can cause changes in the planner's choices among
nearly-same-cost plans.  (There is in fact one minor change in plan choice
within the core regression tests.)  Destabilizing plan choices in back
branches without very clear improvements is frowned on, so we'll just fix
this in HEAD.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/3b0f77601b9f9f3a2e36a813e4cd32c00e0864d6

Modified Files
--------------
src/backend/optimizer/util/pathnode.c |   50 ++++++++++++++++---------------
src/test/regress/expected/join.out    |   52 ++++++++++++++++-----------------
2 files changed, 53 insertions(+), 49 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix planner's cost estimation for SEMI/ANTI joins with inner ind
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: doc: Fix PDF build with FOP