pgsql: postgres_fdw: Fix costing of pre-sorted foreign paths withlocal
От | Etsuro Fujita |
---|---|
Тема | pgsql: postgres_fdw: Fix costing of pre-sorted foreign paths withlocal |
Дата | |
Msg-id | E1hbkmI-0001Fh-Mv@gemulon.postgresql.org обсуждение исходный текст |
Список | pgsql-committers |
postgres_fdw: Fix costing of pre-sorted foreign paths with local stats. Commit aa09cd242 modified estimate_path_cost_size() so that it reuses cached costs of a basic foreign path for a given foreign-base/join relation when costing pre-sorted foreign paths for that relation, but it incorrectly re-computed retrieved_rows, an estimated number of rows fetched from the remote side, which is needed for costing both the basic and pre-sorted foreign paths. To fix, handle retrieved_rows the same way as the cached costs: store in that relation's fpinfo the retrieved_rows estimate computed for costing the basic foreign path, and reuse it when costing the pre-sorted foreign paths. Also, reuse the rows/width estimates stored in that relation's fpinfo when costing the pre-sorted foreign paths, to make the code consistent. In commit ffab494a4, to extend the costing mentioned above to the foreign-grouping case, I made a change to add_foreign_grouping_paths() to store in a given foreign-grouped relation's RelOptInfo the rows estimate for that relation for reuse, but this patch makes that change unnecessary since we already store the row estimate in that relation's fpinfo, which this patch reuses when costing a foreign path for that relation with the sortClause ordering; remove that change. In passing, fix thinko in commit 7012b132d: in estimate_path_cost_size(), the width estimate for a given foreign-grouped relation to be stored in that relation's fpinfo was reset incorrectly when costing a basic foreign path for that relation with local stats. Apply the patch to HEAD only to avoid destabilizing existing plan choices. Author: Etsuro Fujita Discussion: https://postgr.es/m/CAPmGK17jaJLPDEkgnP2VmkOg=5wT8YQ1CqssU8JRpZ_NSE+dqQ@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/08d2d58a2a1c8ef8d39e8132d39ee14a1d029500 Modified Files -------------- contrib/postgres_fdw/postgres_fdw.c | 95 ++++++++++++++++++++++--------------- contrib/postgres_fdw/postgres_fdw.h | 9 +++- 2 files changed, 63 insertions(+), 41 deletions(-)
В списке pgsql-committers по дате отправления: