Remove inner joins based on foreign keys

First seen: 2026-03-21 02:47:03+00:00 · Messages: 13 · Participants: 6

Latest Update

2026-05-27 · claude-opus-4-6

Richard Guo's PGConf.dev Synthesis and Formal Options Enumeration (v5)

Richard returns from PGConf.dev with a significant message that restructures the entire discussion. Rather than defending the lock-based predicate further, he steps back to present a neutral taxonomy of all possible approaches to the trigger-gap problem, explicitly soliciting community input. This is a deliberate widening of the design space after in-person conversations revealed "concerns" with approach (B).

Key new technical content

1. Concrete demonstration of the trigger gap on unpatched master

Richard provides a fully self-contained reproduction script (the show_gap() function called from DELETE ... RETURNING) that proves the trigger gap is observable today on stock PostgreSQL with no patch applied. This is pedagogically important: prior messages described the gap abstractly, but this is the first time the thread contains a copy-paste-runnable proof. The demonstration uses PL/pgSQL's SPI snapshot inside a RETURNING clause — a path that any reviewer can verify in seconds.

2. Six enumerated approaches (A through F)

This is the first time all options have been laid out in a single message with explicit pros/cons:

3. Patch split into two parts (v5)

v5 is now structured as:

Richard explicitly states 0001 is not safe to commit alone — the split is for review ergonomics only. This is a mature engineering decision that allows the community to evaluate the optimization's correctness independently of the gap-handling strategy.

4. The "replan storm" problem (newly articulated)

Richard identifies a performance pathology in option (B) that was not previously discussed: for cached plans that benefited from FK removal, choose_custom_plan() will detect the RowExclusiveLock and force a custom plan on every execution within the writing transaction. This isn't a one-time replan — it's a per-execution overhead that persists for the transaction's lifetime. For connection-pooled OLTP workloads where transactions mix reads and writes, this could make the optimization actively harmful to latency variance.

What this message signals about project trajectory

Richard's neutral framing ("I'm not advocating any particular option") and the CC of PGConf.dev conversants suggests the lock-based predicate may not survive as the final approach. The snapshot-anchored predicate (C) is the most technically interesting new proposal — it trades architectural purity of SnapshotData for precision, eliminating both false positives and the replan storm. The thread is now at a decision point where committer input on architectural acceptability will likely determine direction.

Still unaddressed