postgres_fdw: Fix cost estimation for aggregate pushdown.

Etsuro Fujita <efujita@postgresql.org>

Commit: edbcbe277d795ecc339b0e4fa29bae42ce1a7be9
Author: Etsuro Fujita <efujita@postgresql.org>
Date: 2019-05-09T09:39:23Z
Releases: 12.0
postgres_fdw: Fix cost estimation for aggregate pushdown.

In commit 7012b132d0, which added support for aggregate pushdown in
postgres_fdw, the expense of evaluating the final scan/join target
computed by make_group_input_target() was not accounted for at all in
costing aggregate pushdown paths with local statistics.  The right fix
for this would be to have a separate upper stage to adjust the final
scan/join relation (see comments for apply_scanjoin_target_to_paths());
but for now, fix by adding the tlist eval cost when costing aggregate
pushdown paths with local statistics.

Apply this to HEAD only to avoid destabilizing existing plan choices.

Author: Etsuro Fujita
Reviewed-By: Antonin Houska
Discussion: https://postgr.es/m/5C66A056.60007%40lab.ntt.co.jp

Files

PathChange+/−
contrib/postgres_fdw/postgres_fdw.c modified +13 −3
src/backend/optimizer/plan/planner.c modified +4 −0

Discussion