On Mon, Nov 9, 2020 at 5:44 PM Andy Fan <zhihui.fan1...@gmail.com> wrote:
> Currently the cost model of append path sums the cost/rows for all the > subpaths, it usually works well until we run into the run-time partition > prune > case. The first result is that generic plans will rarely be used for some > cases. > For instance, SELECT * FROM p WHERE pkey = $1; The custom plan will only > count the cost of one partition, however generic plan will count the cost > for all the > partitions even we are sure that only 1 partition will survive. Another > impact > is that planners may choose a wrong plan. for example, SELECT * FROM t1, > p > WHERE t1.a = p.pkey; The cost/rows of t1 nest loop p is estimated highly > improperly. This patch wants to help this case to some extent. > Greetings, I was referred to this patch by Amit as a possible improvement for an issue I noticed recently. I had a test setup where I expected run-time pruning to kick in but it did not. I am trying to test this patch to see if it helps for that scenario, but ran into an error running make install against the current master (commit 0a687c8f1). costsize.c: In function ‘cost_append’: costsize.c:2171:32: error: ‘AppendPath’ {aka ‘struct AppendPath’} has no member named ‘partitioned_rels’ 2171 | List *partitioned_rels = apath->partitioned_rels; | ^~ make[4]: *** [<builtin>: costsize.o] Error 1 make[4]: Leaving directory '/var/lib/postgresql/git/postgresql/src/backend/optimizer/path' make[3]: *** [../../../src/backend/common.mk:39: path-recursive] Error 2 make[3]: Leaving directory '/var/lib/postgresql/git/postgresql/src/backend/optimizer' make[2]: *** [common.mk:39: optimizer-recursive] Error 2 make[2]: Leaving directory '/var/lib/postgresql/git/postgresql/src/backend' make[1]: *** [Makefile:42: install-backend-recurse] Error 2 make[1]: Leaving directory '/var/lib/postgresql/git/postgresql/src' make: *** [GNUmakefile:11: install-src-recurse] Error 2 Thanks, Ryan Lambert