Skip to content

sql schema: more support for per-table and per-index settings (storage parameters) #67964

@michae2

Description

@michae2

Some settings are best scoped to tables or indexes rather than sessions or users/roles. Four current examples of settings that we would like to configure per-table:

  1. row-level GC TTL settings
  2. table statistics collection settings
  3. disallow_full_table_scans
  4. row-size guardrails

One could imagine these settings being included in CREATE TABLE and CREATE INDEX statements, modified with ALTER TABLE and ALTER INDEX, and viewed with SHOW CREATE TABLE.

As @mgartner pointed out in his comment linked above, Postgres already has syntax for storage parameters for tables and indexes which it uses for per-table autovacuum, among other settings. This could be a logical place to collect CockroachDB-specific table settings as well.

We already parse CREATE TABLE ... WITH and CREATE INDEX ... WITH syntax, but then discard most storage parameters and do not persist them (edit: except for a few, see @otan's comment below). We do not parse ALTER TABLE ... SET (...) nor show storage parameters in SHOW CREATE TABLE output. As @rafiss noted in #43299 we don't have real support for any of the Postgres storage parameters, much less CockroachDB-specific storage parameters.

So I think there are three work items here:

  • persist storage parameters in descriptors
  • add support for ALTER TABLE ... SET (x = y) and ALTER COLUMN ... SET (x = y)
  • show storage parameters in SHOW CREATE TABLE output

Edit: this overlaps with zone configs. (See discussion below.)

Jira issue: CRDB-8801

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-schema-descriptorsRelating to SQL table/db descriptor handling.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions