MergeConstraintsIntoExisting() patch: measurements ================================================== master: c1dd701fb5f (2026-11-29), make -O2 -g, no cassert patched: same plus v1-0001 old cluster for pg_upgrade: REL_18_STABLE 18.6, same flags Runs alternate between master and patched. "instr" = user-space instructions (perf stat -e instructions:u). The 95% confidence interval is a bootstrap of the change in the median. 1. ATTACH PARTITION, parent with N NOT NULL columns, child created with LIKE. attach-bench.sh.txt curve 20: 20 runs per build and N, synchronous_commit=off, time from psql's \timing. One fresh cluster per round and build runs every N, after one unmeasured ATTACH; the build that goes first alternates between rounds. N master ms patched ms change 95% CI 25 0.62 0.56 -8.9% -10.6 .. -4.1% 50 1.44 1.15 -20.3% -21.9 .. -17.7% 100 2.91 1.87 -35.8% -37.3 .. -34.5% 200 8.49 4.25 -49.9% -50.8 .. -48.0% 400 23.50 7.43 -68.4% -69.4 .. -67.1% 800 77.87 15.60 -80.0% -80.4 .. -79.3% 1600 276.66 29.84 -89.2% -89.4 .. -88.7% Local exponent of the median, log(t2/t1) / log(N2/N1): N1 -> N2 master patched 25 -> 50 1.22 1.02 50 -> 100 1.01 0.70 100 -> 200 1.55 1.19 200 -> 400 1.47 0.81 400 -> 800 1.73 1.07 800 -> 1600 1.83 0.94 Every cell has one mode. At most two runs per cell are more than 30% above its median (the largest, 1.96 times). 2. ATTACH/DETACH x 200, parent with 1 CHECK. attach-bench.sh.txt checks 3 (instr of the whole server) child CHECKs round master M patched M 1601 1 6002.3 6001.7 1601 2 6002.2 6001.7 1601 3 6002.3 6001.7 1 1 592.6 594.1 1 2 592.6 593.8 1 3 592.6 593.8 3. pg_upgrade --copy --no-sync from 18.6, schema "wide" (one table, 1000 partitions, 200 NOT NULL columns plus a primary key, no rows). pg_upgrade-bench.sh.txt wide 9; instr of the whole pg_upgrade process tree. instr G: master median 512.31, patched 434.84: -15.1% (95% CI -15.1 .. -15.1), the same in all nine rounds wall s: master 32.7 34.6 36.4 37.2 38.5 39.3 41.3 47.0 61.0 patched 28.0 31.3 35.1 37.9 39.3 47.2 48.6 55.5 77.7 change of the median +2.1% (95% CI -18.7 .. +40.6): the interval crosses zero, so there is no wall clock result. 4. pg_upgrade --copy from 18.6, schema "tom" (the case from the b3f0e0503f3 thread: 100 tables x 1000 CHECK constraints, each with one INHERITS child). pg_upgrade-bench.sh.txt tom 3; instr. round master G patched G 1 12395.29 12197.88 2 12395.32 12197.98 3 12395.28 12198.07 5. Restore of the "tom" case cut to 10 tables, split by command. restore-split.sh.txt 3 (pg_dump --binary-upgrade, restore with log_min_duration_statement = 0; seconds summed per command kind) round build instr G wall s ADD CONSTRAINT s INHERIT s 1 master 192.10 104.7 97.5 4.48 1 patched 162.45 98.7 94.0 1.88 2 master 192.10 96.1 89.1 4.37 2 patched 162.45 90.5 86.1 1.86 3 master 192.10 89.9 83.8 3.82 3 patched 162.45 98.9 93.7 2.09 6. pg_upgrade --copy --no-sync on the smaller tier of David Rowley's partition and foreign-key schema, with 91,678 pg_class rows. Both clusters were 20devel. The source used master at 9cd6fe0d0ab throughout. The four destination builds used that same base, with MergeConstraints, the FK constraint-name patch (#118 v1), or both. Runs used tmpfs and three rounds with rotated build order. All 12 upgrades completed. Build Total instr G Paired change Total wall s Master 530.46 - 43.524 MergeConstraints 530.19 -0.04% 43.469 #118 522.66 -1.50% 43.480 Both 522.48 -1.62% 42.856 Instruction counts and wall times are medians. Paired changes are medians of the changes relative to master within each round. The MergeConstraints-only reductions ranged from 0.02% to 0.22%. Separate perf profiles (one per build) estimated the inclusive share of user-space instruction samples during schema restore. Build MergeConstraintsIntoExisting Master 1.15% MergeConstraints 0.72% #118 0.91% Both 0.56%