Skip to main content
The WITH (storage parameter) sets a storage parameter on a table.

Syntax

create_index_with_storage_param ::= create_index_with_storage_param syntax diagram create_table_with_storage_param ::= create_table_with_storage_param syntax diagram

Command parameters

ParameterDescription
tableThe table to which you are setting the parameter.
indexThe index to which you are setting the parameter.
parameter_nameThe name of the storage parameter. See Storage parameters for a list of available parameters.

Storage parameters

Index parameters

Parameter nameDescriptionData typeDefault value
bucket_countThe number of buckets into which a will split.IntegerThe value of the sql.defaults.default_hash_sharded_index_bucket_count .No
shard_columnsThe first key column or columns to use when computing the shard column for a . The value must match a prefix of the index key columns. If this parameter is omitted, CockroachDB hashes all index key columns.Tuple of column identifiers or a single column identifierAll index key columnsNo
skip_unique_checksDisables for indexes with columns, including indexes on tables. This avoids expensive cross-partition uniqueness checks in multi-region deployments. Can only be set on unique indexes with implicit partitioning. Warning: This should only be used if the application can guarantee uniqueness. Safe use cases include externally generated UUIDs, or columns using or as defaults (provided you do not also manually insert values into those columns). Incorrectly applying this parameter when uniqueness is not guaranteed could result in logically duplicate keys in different partitions of a unique index. Note that, by default, the optimizer does not perform uniqueness checks on columns using .BooleanfalseYes
geometry_max_xThe maximum X-value of the for the object(s) being covered. This only needs to be set if you are using a custom .Derived from SRID bounds, else (1 <&lt; 31) -1.No
geometry_max_yThe maximum Y-value of the for the object(s) being covered. This only needs to be set if you are using a custom .Derived from SRID bounds, else (1 <&lt; 31) -1.No
geometry_min_xThe minimum X-value of the for the object(s) being covered. This only needs to be set if the default bounds of the SRID are too large/small for the given data, or SRID = 0 and you wish to use a smaller range (unfortunately this is currently not exposed, but is viewable on <https://epsg.io/3857). By default, SRID = 0 assumes [-min int32, max int32] ranges.Derived from SRID bounds, else -(1 <&lt; 31).No
geometry_min_yThe minimum Y-value of the for the object(s) being covered. This only needs to be set if you are using a custom .Derived from SRID bounds, else -(1 <&lt; 31).No
s2_level_mods2_max_level must be divisible by s2_level_mod. s2_level_mod must be between 1 and 3.Integer1No
s2_max_cellsThe maximum number of S2 cells used in the covering. Provides a limit on how much work is done exploring the possible coverings. Allowed values: 1-30. You may want to use higher values for odd-shaped regions such as skinny rectangles. Used in .Integer4No
s2_max_levelThe maximum level of S2 cell used in the covering. Allowed values: 1-30. Setting it to less than the default means that CockroachDB will be forced to generate coverings using larger cells. Used in .Integer30No
The following parameters are included for PostgreSQL compatibility and do not affect how CockroachDB runs:
  • fillfactor

Table parameters

Parameter nameDescriptionData typeDefault value
exclude_data_from_backupExclude the data in this table from any future backups.Booleanfalse
infer_rbr_region_col_using_constraintFor tables, automatically populate the hidden crdb_region column on INSERT, UPDATE, and UPSERT by looking up the region of the referenced parent row. Set this parameter to the name of a constraint on the table that includes the crdb_region column. The foreign key cannot be dropped while the parameter is set.StringNULL
schema_lockedIndicates that a is not currently ongoing on this table. By default, CockroachDB attempts to automatically unset this parameter before performing many schema changes and reapplies it when done. To require manual unlocks for all DDL on schema-locked tables, set to false. Enabling schema_locked can help running on this table.Booleanfalse
sql_stats_automatic_collection_enabledEnable automatic collection of and statistics for this table.Booleantrue
sql_stats_automatic_collection_min_stale_rowsMinimum number of stale rows in this table that will trigger a full statistics refresh.Integer500
sql_stats_automatic_collection_fraction_stale_rowsFraction of stale rows in this table that will trigger a full statistics refresh.Float0.2
sql_stats_automatic_full_collection_enabledEnable automatic collection of for this table. sql_stats_automatic_collection_enabled must be true.Booleantrue
sql_stats_automatic_partial_collection_enabledEnable automatic collection of for this table. sql_stats_automatic_collection_enabled must be true.Booleantrue
sql_stats_automatic_partial_collection_min_stale_rowsMinimum number of stale rows that triggers for this table.Integer100
sql_stats_automatic_partial_collection_fraction_stale_rowsTarget fraction of stale rows that triggers for this table.Float0.05
sql_stats_canary_windowNew in v26.2: How long statistics for this table remain in before being promoted to stable status.Duration0
sql_stats_forecasts_enabledEnable collection for this table.Booleantrue
The following parameters are included for PostgreSQL compatibility and do not affect how CockroachDB runs:
  • autovacuum_enabled
  • fillfactor
For the list of storage parameters that affect how works, see the list of .

Required privileges

The user must be a member of the or roles, or have the on the table.

Examples

Create a table with row-level TTL enabled

In this case, CockroachDB implicitly added the ttl and ttl_job_cron .

See also