Repository navigation
perf(export): read a dump's table DDL once per schema - #4592
Merged
Merged
Conversation
A SQL dump read each table's CREATE TABLE with its own catalog queries, three round trips per table on PostgreSQL. PluginKit gains a table DDL group read beside the others; PostgreSQL answers it for every plain table of the schema in two statements, rendered by the per-table renderer, and a table it leaves out keeps its own read.
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
CREATE TABLEonce per schema instead of once per table. On PostgreSQL that is 2 catalog statements for the schema in place of 3 per table.PluginExportBulkReads.tableDDL,PluginDatabaseDriver.fetchAllTableDDL(schema:)andPluginExportDataSource.fetchAllTableDDL(databaseName:), each with an empty default. Additive; the kit is already 47, one past the 46 thatv0.89.0-beta.1shipped, so no bump.PostgreSQLTableDDL.scriptand the same column and constraint text as the per-table read. A partitioned table, a partition, a view or a table the read leaves out is read alone, so its text is unchanged.SQLExportGroupReads.tableDDL(for:)takes the group answer and falls back to the table's own read for a table the group leaves out or a group read that fails.Measured
PostgreSQL 17.12 in Docker on this Mac, a schema of 1,000 tables, server time:
At +50 ms RTT the before reads are about 3,000 round trips, about 150 s; the after reads are 2.
Test plan
PostgreSQLCatalogExportTests: the schema read sends exactly the two statements, and for each table of the fixture (with constraints, without, unlogged) its text equalsfetchTableDDLon the same catalog rows; the predicate leaves out partitions where the server has them.SQLExportGroupReadTests: a dump reads the group once and reads alone only the table the group left out, with the same dump text and warnings as table-by-table reads; a failed group read falls back to every table's own read.Not in this PR, left on the issue: one lex per imported file with classified units, and the UTF-8 byte scanner.
Closes #4555