Re: Make Append Cost aware of some run time partition prune case

From: Ryan Lambert <ryan(at)rustprooflabs(dot)com>
To: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Amit Langote <amitlangote09(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: Make Append Cost aware of some run time partition prune case
Date: 2021-03-04 00:14:26
Message-ID: CAN-V+g-X-49XuN_AbqTwNhTCNaV6UwqO88kuqkADbyZ7Aa_7rA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 9, 2020 at 5:44 PM Andy Fan <zhihui(dot)fan1213(at)gmail(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-03-04 00:21:54 Re: buildfarm windows checks / tap tests on windows
Previous Message Jacob Champion 2021-03-04 00:03:36 [PATCH] test/ssl: rework the sslfiles Makefile target