postgresql/src
David Rowley 1e731ed12a Fix incorrect row estimates used for Memoize costing
In order to estimate the cache hit ratio of a Memoize node, one of the
inputs we require is the estimated number of times the Memoize node will
be rescanned.  The higher this number, the large the cache hit ratio is
likely to become.  Unfortunately, the value being passed as the number of
"calls" to the Memoize was incorrectly using the Nested Loop's
outer_path->parent->rows instead of outer_path->rows.  This failed to
account for the fact that the outer_path might be parameterized by some
upper-level Nested Loop.

This problem could lead to Memoize plans appearing more favorable than
they might actually be.  It could also lead to extended executor startup
times when work_mem values were large due to the planner setting overly
large MemoizePath->est_entries resulting in the Memoize hash table being
initially made much larger than might be required.

Fix this simply by passing outer_path->rows rather than
outer_path->parent->rows.  Also, adjust the expected regression test
output for a plan change.

Reported-by: Pavel Stehule
Author: David Rowley
Discussion: https://postgr.es/m/CAFj8pRAMp%3DQsMi6sPQJ4W3hczoFJRvyXHJV3AZAZaMyTVM312Q%40mail.gmail.com
Backpatch-through: 14, where Memoize was introduced
2022-05-16 16:07:56 +12:00
..
backend Fix incorrect row estimates used for Memoize costing 2022-05-16 16:07:56 +12:00
bin Indent C code in flex and bison files 2022-05-13 07:17:29 +02:00
common Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
fe_utils Allow db.schema.table patterns, but complain about random garbage. 2022-04-20 11:37:29 -04:00
include Rename JsonIsPredicate.value_type, fix JSON backend/nodes/ infrastructure. 2022-05-13 11:40:08 -04:00
interfaces Indent C code in flex and bison files 2022-05-13 07:17:29 +02:00
makefiles Refactor DLSUFFIX handling 2022-03-25 08:56:02 +01:00
pl Indent C code in flex and bison files 2022-05-13 07:17:29 +02:00
port Remove extraneous blank lines before block-closing braces 2022-04-13 19:16:02 +02:00
template Refactor DLSUFFIX handling 2022-03-25 08:56:02 +01:00
test Fix incorrect row estimates used for Memoize costing 2022-05-16 16:07:56 +12:00
timezone Update time zone data files to tzdata release 2022a. 2022-05-05 14:54:53 -04:00
tools Add a new shmem_request_hook hook. 2022-05-13 09:31:06 -04:00
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Update Unicode data to CLDR 41 2022-04-06 08:17:33 +02:00
Makefile.shlib AIX: Fix missing libpq symbols by respecting SHLIB_EXPORTS. 2021-09-06 11:27:59 -07:00
nls-global.mk Improve frontend error logging style. 2022-04-08 14:55:14 -04:00