BUG #19861 - measurements (master 8d90516d76d, cassert, meson + gcc) Builds master unpatched v3 master + v3-0001-Skip-SJE-if-jointree-containing-VOLATILE-function (Tender Wang's v2 rebased over 9774003d953, no functional changes) narrow master + one condition at the list_member() test in fixup_selfjoin_quals(): a qual that became a duplicate is kept if it contains volatile functions (for comparison only) 1. Differential sweep 190000 generated queries, fixed seed (20261129). Each query runs with enable_self_join_elimination on and off in the same server; rows, errors, row locks and the number of calls of counting volatile functions must agree. 19 classes of 10000 cases: inner, third relation, chains, outer joins above/below/across, nesting, subqueries, PHVs, LATERAL, sublinks, top-level clauses, row marks, DML, volatile, RLS, negative, unusual indexes, special columns. 1474 cases error out identically in both modes on every build. build cases that differ server TRAP/PANIC master 4978 0 v3 0 0 narrow 2348 0 On master and narrow every differing case is in class "volatile". 2. Joins removed (a scan of the self-joined table disappears with the GUC on) class master v3 narrow volatile 10000 975 10000 rls 3361 1259 3361 the other 17 98403 98403 98403 The 2102 rls cases where v3 no longer removes the join all have the volatile function leak() in WHERE on one side only; master returns the same rows and the same number of calls in all of them. 3. Class "volatile" (10000 cases, the join is removable in all of them) By shape of the volatile expression (cases / differ on master, v3, narrow): one side only, in WHERE 1947 0 0 0 vol(x.a) = vol(y.a) 1065 0 0 1 target list only 975 0 0 0 same qual once per side, WHERE 4994 4978 0 2347 same qual, one in ON, one WHERE 1019 0 0 0 v3 keeps removing the join only in the "target list only" shape. 4. Of the differing cases, is a qual missing from the plan? For each differing case: number of volatile calls shown by EXPLAIN (VERBOSE, COSTS OFF) with the GUC on, against the same with it off. build fewer with GUC on equal master 4978 0 narrow 0 2348 On narrow no qual is dropped; what differs is how many times, or in what order, the volatile function runs (1991 cases: call count; 357 cases: rows, all with a predicate on the parity of nextval()). The narrow count is not exactly reproducible between runs with the same seed. 5. Regression tests, v3 regress: 243 subtests passed (the new join test included) isolation: 143 subtests passed 6. Target-list cases from Kirill's mail Self-join form; master and v3 give the same output: ORDER BY x, GUC on 1|1, last_value 1 ORDER BY x, GUC off 1|2, last_value 2 no ORDER BY, GUC on 1|2, last_value 2 generate_series pair, GUC on one row 1|1 generate_series pair, GUC off 1|1 and NULL|2 The same expressions written against ONE relation, no join (tlist-control.sql.txt): two identical volatile expressions, ORDER BY x 15.19, 17.11, master 1|1, last_value 1 the same, no ORDER BY 15.19, 17.11, master 1|2, last_value 2 two identical set-returning expressions 15.19, 17.11, master one row 1|1, last_value 1