Skip to content

'SHOW TABLES WITH settingName' and 'SHOW CLUSTER SETTINGS FOR TABLE' #78395

@msirek

Description

@msirek

Is your feature request related to a problem? Please describe.

  1. PR#78110 adds support for setting certain cluster setting overrides for individual tables. There is currently no way for a user or DBA to discover which tables in the system have a given setting set, if they wish to unset it for all tables, without issuing a SHOW CREATE TABLE statement on every table in the system. Here is an example query which could find these tables, but it references crdb_internal, which is generally not customer-visible:
SELECT
        tbl.database_name || '.' || tbl.schema_name || '.' || tbl.name
FROM
        crdb_internal.tables AS tbl
        INNER JOIN system.descriptor AS d ON d.id = tbl.table_id
WHERE
        tbl.database_name IS NOT NULL
        AND tbl.drop_time IS NULL
        AND
         crdb_internal.pb_to_json('cockroach.sql.sqlbase.Descriptor',
                d.descriptor, false)->'table'->'clusterSettingsForTable'
                       ->> 'sqlStatsAutomaticCollectionEnabled' = 'true';

      ?column?
--------------------
  defaultdb.mws.t1
  1. Currently, table settings (storage parameters) are displayed in the SHOW CREATE TABLE output. However, it would be nice to have a new statement which displays just the current cluster settings for the table, one per line, instead of a dense WITH clause which prints all settings on one line and has other storage parameters mixed in. If no cluster settings are specified at the table level, that could quickly be determined by empty output.

Describe the solution you'd like

  1. Add a new statement, such as SHOW TABLES [IN _schemaName_] WITH "_settingName_" (SET | UNSET); which would list all tables (or all tables in a given schema) having a given table setting, such as sql.stats.automatic_collection.enabled set to a value, or not set (via the SET or UNSET option). This would not be specific to table-level cluster settings added by [PR#78110](https://github.com/cockroachdb/cockroach/pull/78110), but apply to any table setting added by CREATE TABLE ... WITHorALTER TABLE ... SET`. Optionally, a statement to list all tables with any storage parameter set could be supported. A variant of this could list all tables with any cluster setting set.

  2. A new statement such as SHOW CLUSTER SETTINGS FOR TABLE _tableName_, and possibly a SHOW SESSION SETTINGS FOR TABLE _tableName_ statement could be added to list table-level cluster settings and table-level session settings (currently table-level session settings are not supported). Optionally a SHOW SETTINGS FOR TABLE _tableName_ statement could be added which would list both cluster and session settings in effect for the table.

Describe alternatives you've considered
None

Additional context
None

Jira issue: CRDB-14104

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-queriesSQL Queries Team

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions