model-writtenrun 6195 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Hubert depesz lubaczewski reported that schema-only pg_dump over a high-latency connection repeatedly queried the same type names and proposed collecting or caching them #1.
- Tom Lane requested measurements to assess whether bulk type-name collection could waste work #4; Hubert found 5000 format_type() calls for only 83 distinct OIDs among 9173 total queries #10, and Laurenz Albe advocated caching #11.
- Tom posted an experimental patch that collected formatted names during the initial pg_type scan, reducing regression-database queries from 3260 to 2905 while leaving older-server paths unfinished #12; Stephen Frost reviewed it favorably and explained why network latency would amplify the savings #14.
- Tom independently proposed reading all RLS policies with one query instead of querying each table, reducing regression-database queries to 2589 and local runtime from 2.1 to 1.8 seconds #21.
- Alvaro Herrera suggested batching trigger queries #23, while Tom considered batching pg_attribute reads but identified wasted work for selective dumps and potentially large results #24; neither idea received an attached patch in this thread.
- Hubert tested the initial type-name patch and reduced dump time from 17m22s to 8m12s, with matching archive listings; adding the RLS patch reduced it further to 7m35s, but exposed many apparently unnecessary function queries #26.
- Hubert identified 1729 extension-owned functions #28, and Tom traced the excess queries to security-label and policy component flags that caused data collection even when nothing would be emitted, concluding that the broader problem needed a substantial rewrite #30.
- Tom replaced eager type-name collection with on-demand caching because bulk format_type() calls could encounter types disappearing during concurrent temporary-table drops; the revised approach also avoided computing unused names #32.
- Hubert tested the revised cache and reported 4261 queries, while noting that common extensions such as PostGIS made the remaining function-query overhead broadly relevant #33.
- Tom committed the revised type-name cache unchanged as 6c450a861f from #32, then committed the independent RLS optimization unchanged as bd3611db5a from #21; both changes were backpatched to supported branches.
- Tom announced that both simple improvements had landed while the extension-related optimization remained too invasive for these fixes #34.
- Tom later closed the thread by linking a separately posted rewrite addressing the broader problem #36, and Hubert welcomed it in the final reply #37; both attached optimization efforts were complete, with the larger work continuing elsewhere.