Repository navigation
Description
Problem
After the table list, the sidebar's schemas, routines, triggers, types and server objects each cost one round trip, one after another, and the database list waits behind all of them. In the PostgreSQL statement log (research/pglog/tablepro.log), the first metadata connection sends, in order and one Query each: the table list (07.797), the schema list (07.803), routines (07.807), triggers (07.848), types (07.850), extensions (07.857), then the database list (07.863).
Locally that is 66 ms. Each step is one RTT, so at +50 ms it is an estimated 250-300 ms and at +200 ms about 1.2 s before procedures, types, schema-qualified completion and the database switcher are complete (estimate from the round-trip count, not measured). The table list itself is not delayed. High-latency links make this visible (see closed #1574).
Cause
readSideKinds(_:leasingFrom:scope:)loops overSideKind.allCasesand takes onewithMetadataDriverlease per kind, awaiting each before the next (apple/TablePro/Core/Services/Query/SchemaService+CatalogLoad.swift:136-159). The comment at:13-14gives the reason: a column read asked for meanwhile goes before the next kind.- A refresh runs the same kinds with
async leton one driver (SchemaService+CatalogLoad.swift:115-134), but one connection serves them one Query at a time, so it is still one RTT per kind. A DDL statement from the editor triggers that full refresh (apple/TablePro/Core/Services/Query/SchemaRefreshService.swift:279-325). loadSchemaawaits the whole load, thensyncAutocompleteNamespaces, thenloadDatabases(apple/TablePro/Views/Main/Extensions/MainContentCoordinator+SchemaLoading.swift:118-147).fetchDatabaseListresolves to the browse scope and lands on the same pooled interactive entry (apple/TablePro/Core/Services/Query/DatabaseTreeMetadataService.swift:596-608), so started earlier it would still queue on that entry between kinds.- PostgreSQL already has a one-Query multi-read path,
executeCatalogReadswithLibPQCatalogBatch(apple/Plugins/PostgreSQLDriverPlugin/LibPQDriverCore.swift:349,apple/Plugins/PostgreSQLDriverPlugin/LibPQCatalogBatch.swift:11). The catalog load does not use it. - MySQL connects with
CLIENT_FOUND_ROWSonly, no multi-statements (apple/Plugins/MySQLDriverPlugin/MariaDBPluginConnection+Transport.swift:44), but it already pipelines twomysql_send_querycalls and reads the replies in order (sendWithSelectLimit,apple/Plugins/MySQLDriverPlugin/MariaDBPluginConnection.swift:959-1000).
Overlaps #4459: C5c already covers sending queued PostgreSQL catalog reads as one Query (a read queue in LibPQDriverCore). This issue adds the host side (one lease for all kinds), the other engines and the database list.
Change
- Add a driver capability that reads several catalog kinds in one round trip and returns one result per kind, with a default that runs them one by one. PostgreSQL implements it with
executeCatalogReads(one Query, oneSET LOCAL search_path); MySQL pipelines the reads withmysql_send_queryand reads the replies in order. Other engines keep the default until each is measured. readSideKindstakes one lease for all side kinds and commits each kind as its result arrives, as today. Keep the column-read priority by checking the entry's waiter queue between result sets instead of taking a fresh lease per kind.- Put the database list in the same round trip where the engine allows, or start it alongside the load, knowing it shares the entry.
- The refresh path uses the same capability.
Measure
- Statement log and packet capture: one round trip for the side kinds after the table list, on PostgreSQL and MySQL.
- Signposts from tables visible to the last side kind committed and to the database switcher filled, at +50 ms and +200 ms RTT, median of 10. Target: (kinds - 1) x RTT less than today.
Part of the performance plan.
Activity
datlechin commentedon Nov 25, 2026
#4576 ships the host side (one lease and one driver call for every side kind, the refresh path included), the PluginKit capability with a one-by-one default, the PostgreSQL one-Query read, and the database list read beside the load. Left for a follow-up:
mysql_send_querygoes through the execute path's reconnect, select-limit and footprint handling, which is its own driver change. MySQL keeps the one-by-one default, on the one lease, for now.DatabaseTreeMetadataServicewith its own state, dedup and fence, so it now starts beside the load instead of riding the batch.