pgsql: Fix old bug in get_loop_count().

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix old bug in get_loop_count().
Дата
Msg-id E1YVtFh-0006n1-OH@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix old bug in get_loop_count().

While poking at David Kubečka's issue I noticed an ancient logic error
in get_loop_count(): it used 1.0 as a "no data yet" indicator, but since
that is actually a valid rowcount estimate, this doesn't work.  If we
have one input relation with 1.0 as rowcount and then another one with
a larger rowcount, we should use 1.0 as the result, but we picked the
larger rowcount instead.  (I think when I coded this, I recognized the
conflict, but mistakenly thought that the logic would pick the desired
count anyway.)

Fixing this changed the plan for one existing regression test case.
Since the point of that test is to exercise creation of a particular
shape of nestloop plan, I tweaked the query a little bit so it still
results in the same plan choice.

This is definitely a bug, but I'm hesitant to back-patch since it might
change plan choices unexpectedly, and anyway failure to implement a
heuristic precisely as intended is a pretty low-grade bug.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/b746d0c32d4fe749c8d39ccb09d8f0fb38bcc197

Modified Files
--------------
src/backend/optimizer/path/indxpath.c |    7 ++++---
src/test/regress/expected/join.out    |    6 +++---
src/test/regress/sql/join.sql         |    4 ++--
3 files changed, 9 insertions(+), 8 deletions(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Improve planner's cost estimation in the presence of semijoins.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Support flattening of empty-FROM subqueries and one-row VALUES t