Skip to content

perf(export): read a PostgreSQL dump's index, comment, sequence and enum DDL once per schema - #4355

Merged
datlechin merged 9 commits into
mainfrom
perf/export-schema-catalog
Nov 19, 2026
Merged

datlechin merged 9 commits into
mainfrom
perf/export-schema-catalog

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • P20: the SQL export reads index DDL, comment DDL, dependent sequences and enum types once per export group, where the driver declares that read answers each table as its own read does. A table the read leaves out has none of that kind.
  • P20: a group with one object of a kind, a group read that fails and one at the 5,000,000 row limit fall back to the per-table reads, so a failure still names its table. A cancelled group read is rethrown.
  • P20: PostgreSQL declares all four. Each is the per-table statement without its relname test, with the relation projected last, decoded by the same row reader. The sequence read is declared only where pg_sequences exists: before it each last value is a statement of its own.
  • P20: names match by their bytes. Swift equates NFC and NFD spellings that PostgreSQL keeps apart, so a schema read holding both spellings of one name falls back, a lookup whose key is spelled otherwise reads alone, and group caches key on the schema name's bytes.
  • PluginKit, additive, in the untagged kit 46 (minimum 19): PluginExportBulkReads gains indexDDL, commentDDL, dependentSequences and dependentTypes. PluginDatabaseDriver and PluginExportDataSource gain fetchAllIndexDDL, fetchAllCommentDDL, fetchAllDependentSequences and fetchAllDependentTypes, default empty. ExportDataSourceAdapter and MaskingExportDataSource forward them.
  • Fix: a table with two columns of one enum type wrote each label twice in its CREATE TYPE, in the SQL export and the DDL tab, and the restore failed on pg_enum_typid_label_index. The enum read now aggregates each type once.
  • MySQL and MariaDB implement none of the four reads (their CREATE TABLE carries indexes and comments), so they declare nothing.
  • New probe apple/scripts/probes/check-postgres-dump-schema-reads.sh: dumps a fixture reading per table and per schema, diffs the files and restores the enum case.

Test plan

  • New SQLExportGroupReadTests: one read per kind per group and the same dump as table reads, fallback after a failed group read with the failing table still named, a lone object read alone, a read at the row limit set aside, Unicode forms of a relation and of a schema kept apart, cancellation rethrown.
  • New PostgreSQLExportSchemaReadTests: each schema statement is the per-table one minus the relname test, each bulk answer equals the per-table decode, pre-10 servers keep sequences per table, a read at the row ceiling or holding two Unicode forms of a name throws.
  • New cases: PostgreSQLCatalogExportTests (enum aggregated once per type), ExportDataSourceAdapterCatalogTests and MaskingExportTests (the four reads forwarded). The bulk statements join PostgreSQLCatalogQualificationTests and PostgreSQLLegacyCatalogQueryTests.
  • Golden files on PostgreSQL 17.11, dumps from main and from this branch (per table and per schema): partial, expression, INCLUDE, partitioned and materialized view indexes, comments on tables, columns, views and materialized views, owned and free sequences (one shared by two tables), quoted names, enum types, NFC and NFD names, 50 plain tables. Byte-identical apart from the Generated: line. The two-columns-of-one-enum dump differs only in its CREATE TYPE line, and now restores.
  • 50-table export through a 200 ms RTT proxy: 84,605 ms and 405 queries on main, 43,697 ms and 209 queries here, the same dump. Left per table: the CREATE TABLE read and the rows.
  • verify.sh: build, plugins, abi (changed, kit 46 against v0.88.0-beta.1's 45), test, lint, ios.
  • Not run: KingbaseES, PGlite and servers before 10.

@datlechin
datlechin enabled auto-merge (squash) November 19, 2026 14:50
@datlechin
datlechin merged commit 7dc0359 into main Nov 19, 2026
11 checks passed
@datlechin
datlechin deleted the perf/export-schema-catalog branch November 20, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant