Repository navigation
perf(connections): read less of the catalog on connect, commit and database switch - #4445
Merged
Merged
Conversation
…and reread a catalog whose schema list failed
…he SQL Server connect as it was; move completion facts with a schema switch
…r's transaction, and reread a hierarchical catalog whose read failed
…committed the tables
datlechin
marked this pull request as ready for review
November 23, 2026 15:57
datlechin
enabled auto-merge (squash)
November 23, 2026 15:57
datlechin
disabled auto-merge
November 23, 2026 17:57
datlechin
enabled auto-merge (squash)
November 23, 2026 17:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Perf audit 2026-11-22, connections lane (findings 5, 9 and 11).
CatalogChangeServicekeeps the catalog kinds a statement changed while the connection holds a transaction, and refreshes those at COMMIT, ROLLBACK or the transaction bar's end. A data-only transaction refreshes nothing.SessionTransactionTracker.standing(of:)is.unknown) still refreshes objects and schemas at every end.CatalogDriverFacts(current schema, bulk column support) is stored beside each catalog's tables when they commit;resetForDatabase(_:tables:facts:connection:)takes it.SQLSchemaProvider.cachedDriverandloadSchema(using:)are gone. The provider reads columns through its own scope's lease.lower_case_table_namesonce for catalog reads running side by side (C5d).SchemaServicerecords when each catalog committed and marks it stale on those events. A stale or older catalog is read again, as before. Sidebar state is still pruned.Measured on the Mac mini. Before: Release build of 9d0d481 (universal). After:
build.sh app arm64 --unsignedof 2801608, this branch merged with main at 00f003e. The review fixes after it change only concurrent loads and paths the harness does not drive. Harness: the perf audit'sdb-roundtrips,--phases count --sessions main --engines pg,mysql(statements and bytes at the 0 ms proxy) and--phases wall --sessions click --engines pg(200 ms RTT). One run each; load1 19 to 107, which the counts do not depend on.BEGIN; UPDATE; COMMIT;in the editor: statements, bytes downlower_case_table_namesread and one connection fewer);Tests changed on purpose:
CatalogChangeServiceTests: "every transaction end refreshes objects and schemas, whichever driver ran the change" is replaced by the cases below.SchemaServiceTests: "Switching back to a database shows its tables at once and refreshes them without loading" now first lets a change reach the catalog.SchemaServiceDatabaseSwitchTests: "A lazy load reads a kept catalog again until something has refreshed it" now marks the catalog stale first.SQLSchemaProviderTests: 6 cases removed with the cached driver: "loadSchema fetches tables without bulk column loading", "A failed loadSchema leaves the provider empty and does not throw", "resetForDatabase clears columns, updates tables, and sets driver", "getColumns returns empty when driver is not available", "getColumns uses injected metadata source instead of cached driver", "A requested column preload uses the injected metadata source instead of the cached driver". Provider tests build their provider through the new helperDriverBackedSchemaProvider.Deliberately not fixed here:
SchemaService.show(scope:type:)on the switch, so the old database's catalog stays shown until the new load lands and the kept one is never pointed at. Showing the kept catalog there changes what those engines show during a switch; follow-up.SessionDriverGate, a pooled re-route with its refusal rules, a waiting state on the tab, result pane UI, strings and screenshots. Measured: a table open waits 8.05 s behindpg_sleep(8).LibPQDriverCorewith medium risk. Plan: refresh 7 serial reads to 4 flights, connect depth 13 to 11.connect_timeout = 2. Plan: handshake round trips 9 to 8.autocommit=0a MyISAM read answers idle and a following InnoDB read opens a transaction, so skipping the probe after an idle table read hides it. C15c (SELECT SCHEMA_NAME(), @@VERSIONat connect) is in 56f6c31 for the follow-up.Test plan
SchemaLeasingLoadTests(10), C9 cases inCatalogChangeServiceTests(9), C11a cases inSchemaServiceTests(7),SchemaRefreshServiceTests(3),SessionTransactionTrackerTestsstanding,MySQLSchemaNameCaseTests(3).verify.sh test(the whole Unit plan) on the Mac mini at dd909dd: 33,376 passed, 0 failed, 2 skipped.