postgres: support per-column statistics target#14
Draft
ilyalavrenov wants to merge 1 commit into
Draft
Conversation
threads a `statisticsTarget` option through ColumnOptions / ColumnMetadata / TableColumnOptions / TableColumn so entities can declare a per-column planner statistics target: @column("int", { statisticsTarget: 1000 }) hotColumn: number; PostgresQueryRunner: - loadTables: reads pg_attribute.attstattarget; treats pg's -1 sentinel as "no override" so the diff doesn't fire on every column. - createTable: emits follow-up ALTER ... SET STATISTICS per column with a target (CREATE TABLE can't carry it inline). - addColumn: same. - changeColumn: diffs old vs new statisticsTarget and emits up/down ALTERs, mapping null/undefined to -1 (cluster default) on the reset path. postgres only; other drivers pass the option through without using it. tests: 4 functional cases against live postgres 14 (createTable round-trip, changeColumn diff, reset to default, addColumn). adjacent columns-comments suite still green.
9f3b5d4 to
b9f6b87
Compare
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.
what
new
statisticsTargetoption on@Column()(postgres only). emitsALTER COLUMN ... SET STATISTICS Non createTable, addColumn, and changeColumn. loadTables readspg_attribute.attstattargetsomigration:generatediffs correctly.why
so
SET STATISTICSlives at the entity, not in a one-off migration. drop/recreate of an annotated column re-applies the target on the nextmigration:generateinstead of silently reverting to cluster default.