model-writtenrun 9276 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tom Lane opened the thread with a real-world query whose repeated table references produced 167,815 foreign-key entries and made foreign-key-to-equivalence-class matching consume 69% of runtime #1.
- David Rowley supplied a small patch that skips equivalence classes lacking either relation, substantially reducing runtime, then proposed per-relation bitmap indexes and fast array access to avoid scanning irrelevant classes altogether #2 #3.
- David's first indexing prototype built temporary arrays for foreign-key matching, and its successor shared the index through PlannerInfo to accelerate additional join-planning functions #4 #5.
- Tomas Vondra confirmed large speedups but found four regression-suite failures and requested simple-query benchmarks; he also supplied a separate Bitmapset.minword experiment with a roughly 5% additional gain #6.
- David fixed the prototype's omission of child equivalence members with ec_allrelids and extended indexing to more functions, while questioning whether the separate bitmap optimization justified overhead for typically small sets #7; Tomas subsequently discussed lazy construction and minimal-query testing #8.
- David prioritized a backpatchable fix because the broader indexing proposal affected interfaces and planner structures #9, and Tom committed the original filtering patch, most recently resent in #11, with only comment changes as fa86238f1e, backpatched through PostgreSQL 9.6.
- Tom also rebased the indexing prototype #12, then criticized its temporary structure, optional fast paths, and weak documentation #14, prompting David to target PostgreSQL 13 and adopt per-RelOptInfo bitmap indexes #15 #16.
- David's redesigned patch maintained indexes as members were added and included an optional list_skip_forward() workaround for linked-list lookup costs; a quick revision fixed uninitialized-index warnings #16 #17.
- Tom objected to expensive index resequencing when classes merged and proposed delaying index construction or retaining merged entries #18; David initially implemented retained empty entries and factored common-index lookup into a helper #20.
- Tom then supplied a larger rewrite that builds indexes after merging, tracks that boundary with ec_merging_done, and removes an incorrect optimization that ignored the explicit EC list passed to generate_join_implied_equalities_for_ecs() #21.
- The developers deferred the broader optimization while awaiting array-based Lists rather than committing the temporary list traversal workaround, with a manually managed EC array discussed as a fallback #22 #23.
- After rebasing Tom's rewrite, David identified a potential dangling pointer from sharing parent and child index bitmaps #24 and subsequently added bms_copy() despite being unable to reproduce a crash #25.
- Once array-based Lists were available, David posted a rebased two-patch series adding a separate indexed generate_join_implied_equalities() implementation, preserving the custom-list function and measuring about a fourfold speedup on the original query #26.
- David combined both patches into 3373c71553, credited himself and Tom as authors, and tightened child-index membership and join matching before committing; his simple-join benchmark showed approximately 0.25% average slowdown amid measurement noise #27.
- Andreas Seltenreich immediately reported a sqlsmith assertion failure #28, which David traced to join removal leaving dead relations in EC membership #29.
- David fixed the assertion to accept dead relations in e1a0f6a983, preserving their indexes rather than special-casing them #30; the thread ends with the indexing series and follow-up fix landed, while the separate minword experiment from #6 has no recorded landing here.