Re: postgres_fdw: Fix costing of remote sorts without remote estimates

From: "Jelte Fennema-Nio" <postgres(at)jeltef(dot)nl>
To: "Rui Zhao" <zhaorui126(at)gmail(dot)com>
Cc: "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>, "Etsuro Fujita" <etsuro(dot)fujita(at)gmail(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Ashutosh Bapat" <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, "Narayanan Venkateswaran" <narayananvpostgres(at)gmail(dot)com>
Subject: Re: postgres_fdw: Fix costing of remote sorts without remote estimates
Date: 2026-11-26 14:59:29
Message-ID: DN58CUGBUJTX.1UFKMTFKD064Q@jeltef.nl
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 4 Nov 2026 at 23:35, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> wrote:
> Attached v3 adds 0005 with comments explaining that.

Cfbot complained that the tests were failing for this patch. It turns
out the tests added in 11591f273e6 changed their plans. I looked closely
at them and found they exposed another plan regression.

That regression resulted from incorrect costing of remote joins, which
could cause bad plans without this patchset, but would do so more often
now. Attached is a v4 patchset that now also fixes this by costing
remote joins more accurately, similar to how this patchset costs remote
sorts. Previously, remote joins were costed as cross products; now, they
are costed as hash joins when the join conditions permit.

The other plan changes in those tests were not regressions, but since
the tests are there to test async MergeAppend, I disabled local sorts in
them.

Attachment Content-Type Size
v4-0001-postgres_fdw-Track-run-cost-instead-of-total-cost.patch text/x-patch 9.2 KB
v4-0002-postgres_fdw-Add-tests-for-costing-local-work-bel.patch text/x-patch 6.4 KB
v4-0003-postgres_fdw-Separate-remote-transfer-and-local-c.patch text/x-patch 17.5 KB
v4-0004-postgres_fdw-Add-test-for-costing-pushed-down-joi.patch text/x-patch 2.9 KB
v4-0005-postgres_fdw-Cost-pushed-down-equi-joins-like-a-h.patch text/x-patch 11.0 KB
v4-0006-postgres_fdw-Add-test-for-sorting-below-a-cheap-l.patch text/x-patch 2.7 KB
v4-0007-postgres_fdw-Fix-costing-of-remote-sorts-without-.patch text/x-patch 41.8 KB
v4-0008-postgres_fdw-Explain-where-remote-tlist-costing-d.patch text/x-patch 2.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Shuntian Jiao 2026-11-26 15:15:25 Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773
Previous Message Jelte Fennema-Nio 2026-11-26 14:53:04 Re: Bump soft open file limit (RLIMIT_NOFILE) to hard limit on startup