perf(sidebar): load tree tables before routines to cut database expand latency#1700
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Thank you for your contribution! Before we can merge this PR, you need to sign our Contributor License Agreement. To sign, please comment below with:
I have read the CLA Document and I hereby sign the CLA. xuhengyu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
|
I have read the CLA Document and I hereby sign the CLA. |
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
What
Expanding a database in the tree sidebar now loads tables first and fills in procedures and functions in the background.
Why
loadObjectsfired three queries throughasync let:fetchTables,fetchProcedures,fetchFunctions. All three ran on the same driver (one libpq / mariadb connection), andMetadataConnectionPool.runSeriallychains same-connection work into strict order, so theasync letparallelism was lost. The tree list only appeared after all three round-trips finished in sequence, and most schemas have no routines at all.Change
DatabaseTreeMetadataService.objectsintotablesStateandroutinesState, each with its ownOnceTaskdedup.loadTablesruns onlyfetchTables. The tree renders as soon as it returns, one round-trip.loadRoutinesruns procedures and functions on a separateMetadataConnectionPoolconnection withworkload: .bulk, physically isolated from the tables query so they no longer block it.objectsContentkeys offtablesLoadState; routines load via a.taskafter tables render and append when ready.MetadataLoadState.isSettled(added) keeps the empty-state from spinning forever if routines fail.refreshObjects,handleDisconnect, andresetPendingupdated for the two split dictionaries.Verification
xcodebuild build(Debug, Xcode 27 beta): BUILD SUCCEEDED.SchemaServiceTests: 3/3 pass, no regression.MetadataLoadStateTests(new): 3/3 pass, coversisSettled.No unit test for
DatabaseTreeMetadataService.loadTables/loadRoutinesitself: the service readsDatabaseManager.sharedandMetadataConnectionPool.sharedsingletons and cannot take an injected driver (unlikeSchemaService, which the existing tests cover). Decoupling that is a separate refactor.Notes
Built with Xcode 27 beta (
DEVELOPER_DIR=/Applications/Xcode-beta.app). Worth a second pass on a stable Xcode before merge.