Skip to main content
Use the SHOW to display the value of one or all of the session variables. You configure session variables using .

Required privileges

No are required to display the session variables.

Synopsis

show_session syntax diagram
The SHOW statement for session variables is unrelated to the other SHOW statements like , , and .

Parameters

ParameterDescription
var_nameThe session variable name to show.
The variable name is case-insensitive and can be enclosed in double quotes.

Supported variables

Variable nameDescriptionInitial valueModify with SET?View with SHOW?
always_distribute_full_scansWhen set to on, full table scans are always distributed.offYesYes
allow_unsafe_internalsControls access to unsafe internals in the system database and the crdb_internal schema. When set to off, queries to the system and crdb_internal namespaces will fail unless access is manually enabled. You should access only information_schema tables.

Usage of unsafe internals is audited via the SENSITIVE_ACCESS logging channel.
offYesYes
application_nameThe current application name for statistics collection.Empty string, or cockroach for sessions from the built-in SQL client.YesYes
autocommit_before_ddlWhen the autocommit_before_ddl session setting is set to on, any schema change statement that is sent during an explicit transaction will cause the transaction to commit before executing the schema change. This is useful because CockroachDB does not fully support multiple schema changes in a single transaction. : This setting is enabled by default. To disable it for all roles, issue the following statement: ALTER ROLE ALL SET autocommit_before_ddl = falseonYesYes
bytea_outputThe mode for conversions from STRING to BYTES.hexYesYes
client_min_messagesThe severity level of notices displayed in the SQL shell. Accepted values include debug5, debug4, debug3, debug2, debug1, log, notice, warning, and error.noticeYesYes
copy_from_atomic_enabledIf set to on, COPY FROM statements are committed atomically, matching PostgreSQL behavior. If set to off, COPY FROM statements are segmented into batches of 100 rows unless issued within an explicit transaction, matching the CockroachDB behavior in versions prior to v22.2.onYesYes
copy_transaction_quality_of_serviceThe default quality of service for COPY statements in the current session. The supported options are regular, critical, and background. See Set quality of service level.backgroundYesYes
cost_scans_with_default_col_sizeWhether to prevent the optimizer from considering column size when costing plans.falseYesYes
crdb_versionThe version of CockroachDB.CockroachDB OSS versionNoYes
create_table_with_schema_lockedWhen enabled, ensures that all tables created during a session enable the schema_locked storage parameter, which improves changefeed performance by indicating that a schema change is not currently ongoing.onYesYes
databaseThe current database.Database in connection string, or empty if not specified.YesYes
datestyleThe input string format for DATE and TIMESTAMP values. Accepted values include ISO,MDY, ISO,DMY, and ISO,YMD.The value set by the sql.defaults.datestyle cluster setting (ISO,MDY, by default).YesYes
default_int_sizeThe size, in bytes, of an INT type.8YesYes
default_text_search_configThe dictionary used to normalize tokens and eliminate stop words when calling a full-text search function without a configuration parameter. See Full-Text Search.englishYesYes
default_transaction_isolationThe isolation level at which transactions in the session execute (SERIALIZABLE or READ COMMITTED). See Isolation levels.SERIALIZABLEYesYes
default_transaction_priorityThe default transaction priority for the current session. The supported options are low, normal, and high.normalYesYes
default_transaction_quality_of_serviceThe default transaction quality of service for the current session. The supported options are regular, critical, and background. See Set quality of service level.regularYesYes
default_transaction_read_onlyThe default transaction access mode for the current session.
If set to on, only read operations are allowed in transactions in the current session; if set to off, both read and write operations are allowed. See SET TRANSACTION for more details.
offYesYes
default_transaction_use_follower_readsIf set to on, all read-only transactions use AS OF SYSTEM TIME follower_read_timestamp() to allow the transaction to use follower reads.
If set to off, read-only transactions will only use follower reads if an AS OF SYSTEM TIME clause is specified in the statement, with an interval of at least 4.8 seconds.
offYesYes
disable_changefeed_replicationWhen true, changefeeds will not emit messages for any changes (e.g., INSERT, UPDATE) issued to watched tables during that session.falseYesYes
disallow_full_table_scansIf set to on, queries on “large” tables with a row count greater than large_full_scan_rows will not use full table or index scans. If no other query plan is possible, queries will return an error message. This setting does not apply to internal queries, which may plan full table or index scans without checking the session variable.offYesYes
distribute_group_by_row_count_thresholdMinimum number of rows that a GROUP BY operation must process in order to be distributed.1000YesYes
distribute_scan_row_count_thresholdMinimum number of rows that a scan operation must process in order to be distributed. This means that full table scans will not be distributed if they read fewer than this number of rows. To always distribute full table scans, set always_distribute_full_scans.10000YesYes
distribute_sort_row_count_thresholdMinimum number of rows that a sort operation must process in order to be distributed.1000YesYes
distsqlThe query distribution mode for the session. By default, CockroachDB determines which queries are faster to execute if distributed across multiple nodes. Distribution preferences for GROUP BY, scan, and sort operations are set with distribute_group_by_row_count_threshold, distribute_scan_row_count_threshold. and distribute_sort_row_count_threshold., respectively. All other queries are run through the gateway node.autoYesYes
enable_auto_rehomingWhen enabled, the home regions of rows in REGIONAL BY ROW tables are automatically set to the region of the gateway node from which any UPDATE or UPSERT statements that operate on those rows originate.offYesYes
enable_durable_locking_for_serializableIndicates whether CockroachDB replicates FOR UPDATE and FOR SHARE locks via Raft, allowing locks to be preserved when leases are transferred. Note that replicating FOR UPDATE and FOR SHARE locks will add latency to those statements. This setting only affects SERIALIZABLE transactions and matches the default READ COMMITTED behavior when enabled.offYesYes
enable_implicit_fk_locking_for_serializableIndicates whether CockroachDB uses shared locks to perform foreign key checks. To take effect, the enable_shared_locking_for_serializable setting must also be enabled. This setting only affects SERIALIZABLE transactions and matches the default READ COMMITTED behavior when enabled.offYesYes
enable_implicit_select_for_updateIndicates whether UPDATE, UPSERT, and DELETE statements acquire locks using the FOR UPDATE locking mode during their initial row scan, which improves performance for contended workloads.

For more information about how FOR UPDATE locking works, see the documentation for SELECT FOR UPDATE.
onYesYes
enable_implicit_transaction_for_batch_statementsIndicates whether multiple statements in a single query (a “batch statement”) will all run in the same implicit transaction, which matches the PostgreSQL wire protocol.onYesYes
enable_insert_fast_pathIndicates whether CockroachDB will use a specialized execution operator for inserting into a table. We recommend leaving this setting on.onYesYes
enable_shared_locking_for_serializableIndicates whether shared locks are enabled for SERIALIZABLE transactions. When off, SELECT statements using FOR SHARE are still permitted under SERIALIZABLE isolation, but silently do not lock.offYesYes
enable_super_regionsWhen enabled, you can define a super region: a set of database regions on a multi-region cluster such that your schema objects will have all of their replicas stored only in regions that are members of the super region.offYesYes
enable_create_stats_using_extremesIf on, allows manual creation of partial statistics using the CREATE STATISTICS ... USING EXTREMES syntax.onYesYes
enable_zigzag_joinIndicates whether the cost-based optimizer will plan certain queries using a zigzag merge join algorithm, which searches for the desired intersection by jumping back and forth between the indexes based on the fact that after constraining indexes, they share an ordering.onYesYes
enforce_home_regionIf set to on, queries return an error and in some cases a suggested resolution if they cannot run entirely in their home region. This can occur if a query has no home region (for example, if it reads from different home regions in a regional by row table) or a query’s home region differs from the gateway region. Note that only tables with ZONE survivability can be scanned without error when this is enabled. For more information about home regions, see Table localities.

This feature is in preview. It is subject to change.
offYesYes
enforce_home_region_follower_reads_enabledIf on while the enforce_home_region setting is on, allows enforce_home_region to perform AS OF SYSTEM TIME follower reads to detect and report a query’s home region, if any.

This feature is in preview. It is subject to change.
offYesYes
expect_and_ignore_not_visible_columns_in_copyIf on, COPY FROM with no column specifiers will assume that hidden columns are in the copy data, but will ignore them when applying COPY FROM.offYesYes
extra_float_digitsThe number of digits displayed for floating-point values. Only values between -15 and 3 are supported.0YesYes
force_savepoint_restartWhen set to true, allows the SAVEPOINT statement to accept any name for a savepoint.offYesYes
foreign_key_cascades_limitLimits the number of cascading operations that run as part of a single query.10000YesYes
idle_in_session_timeoutAutomatically terminates sessions that idle past the specified threshold.

When set to 0, the session will not timeout.
The value set by the sql.defaults.idle_in_session_timeout cluster setting (0s, by default).YesYes
idle_in_transaction_session_timeoutAutomatically terminates sessions that are idle in a transaction past the specified threshold.

When set to 0, the session will not timeout.
The value set by the sql.defaults.idle_in_transaction_session_timeout cluster setting (0s, by default).YesYes
index_recommendations_enabledIf true, display recommendations to create indexes required to eliminate full table scans.
For more details, see Default statement plans.
trueYesYes
inject_retry_errors_enabledIf true, any statement executed inside of an explicit transaction (with the exception of SET statements) will return a transaction retry error. If the client retries the transaction using the special cockroach_restart SAVEPOINT name, after the 3rd retry error, the transaction will proceed as normal. Otherwise, the errors will continue until inject_retry_errors_enabled is set to false. For more details, see Test transaction retry logic.falseYesYes
intervalstyleThe input string format for INTERVAL values. Accepted values include postgres, iso_8601, and sql_standard.The value set by the sql.defaults.intervalstyle cluster setting (postgres, by default).YesYes
is_superuserIf on or true, the current user is a member of the admin role.User-dependentNoYes
large_full_scan_rowsDetermines which tables are considered “large” such that disallow_full_table_scans rejects full table or index scans of “large” tables. The default value is 0, which disallows all full table or index scans.User-dependentNoYes
legacy_varchar_typingIf on, type checking and overload resolution for VARCHAR types ignore overloads that cause errors, allowing comparisons between VARCHAR and non-STRING-like placeholder values to execute successfully. If off, type checking of these comparisons is more strict and must be handled with explicit type casts.offYesYes
localityThe location of the node.

For more information, see Locality.
Node-dependentNoYes
lock_timeoutThe amount of time a query can spend acquiring or waiting for a single row-level lock.
In CockroachDB, unlike in PostgreSQL, non-locking reads wait for conflicting locks to be released. As a result, the lock_timeout configuration applies to writes, and to locking and non-locking reads in read-write and read-only transactions.
If lock_timeout = 0, queries do not timeout due to lock acquisitions.
The value set by the sql.defaults.lock_timeout cluster setting (0, by default)YesYes
multiple_active_portals_enabledWhether to enable the multiple active portals pgwire feature.falseYesYes
node_idThe ID of the node currently connected to.

This variable is particularly useful for verifying load balanced connections.
Node-dependentNoYes
null_ordered_lastSet the default ordering of NULLs. The default order is NULLs first for ascending order and NULLs last for descending order.falseYesYes
optimizer_merge_joins_enabledIf on, the optimizer will explore query plans with merge joins.onYesYes
optimizer_push_offset_into_index_joinIf on, the optimizer will attempt to push offset expressions into index join expressions to produce more efficient query plans.onYesYes
optimizer_use_forecastsIf on, the optimizer uses forecasted statistics for query planning.onYesYes
optimizer_use_histogramsIf on, the optimizer uses collected histograms for cardinality estimation.onNoYes
optimizer_use_improved_multi_column_selectivity_estimateIf on, the optimizer uses an improved selectivity estimate for multi-column predicates.onYesYes
optimizer_use_improved_zigzag_join_costingIf on, the cost of zigzag joins is updated so they will be never be chosen over scans unless they produce fewer rows. To take effect, the enable_zigzag_join setting must also be enabled.onYesYes
optimizer_use_lock_op_for_serializableIf on, the optimizer uses a Lock operator to construct query plans for SELECT statements using the FOR UPDATE and FOR SHARE clauses. This setting only affects SERIALIZABLE transactions. READ COMMITTED transactions are evaluated with the Lock operator regardless of the setting.offYesYes
optimizer_use_merged_partial_statisticsIf on, the optimizer uses partial statistics merged with existing full table statistics to produce more accurate cardinality estimates.onYesYes
optimizer_use_multicol_statsIf on, the optimizer uses collected multi-column statistics for cardinality estimation.onNoYes
optimizer_use_not_visible_indexesIf on, the optimizer uses not visible indexes for planning.offNoYes
optimizer_use_virtual_computed_column_statsIf on, the optimizer uses table statistics on virtual computed columns.onYesYes
plan_cache_modeThe type of plan that is cached in the query plan cache: auto, force_generic_plan, or force_custom_plan.

For more information, refer to Query plan type.
autoYesYes
plpgsql_use_strict_intoIf on, PL/pgSQL SELECT ... INTO and RETURNING ... INTO statements behave as though the STRICT option is specified. This causes the SQL statement to error if it does not return exactly one row.offYesYes
pg_trgm.similarity_thresholdThe threshold above which a % string comparison returns true. The value must be between 0 and 1. For more information, see Trigram Indexes.0.3YesYes
prefer_lookup_joins_for_fksIf on, the optimizer prefers lookup joins to merge joins when performing foreign key checks.offYesYes
reorder_joins_limitMaximum number of joins that the optimizer will attempt to reorder when searching for an optimal query execution plan.

For more information, see Join reordering.
8YesYes
require_explicit_primary_keysIf on, CockroachDB throws an error for all tables created without an explicit primary key defined.offYesYes
row_securityControls whether queries in the current session should silently honor row-level security (RLS) policies or signal an error when those policies would filter out rows.onYesYes
search_pathA list of schemas that will be searched to resolve unqualified table or function names.
For more details, see SQL name resolution.
publicYesYes
serial_normalizationSpecifies the default handling of SERIAL in table definitions. Valid options include 'rowid', 'virtual_sequence', sql_sequence, sql_sequence_cached, sql_sequence_cached_node, and unordered_rowid.
If set to 'virtual_sequence', the SERIAL type auto-creates a sequence for better compatibility with Hibernate sequences.
If set to sql_sequence_cached or sql_sequence_cached_node, you can use the sql.defaults.serial_sequences_cache_size cluster setting to control the number of values to cache in a user’s session, with a default of 256.
If set to unordered_rowid, the SERIAL type generates a globally unique 64-bit integer (a combination of the insert timestamp and the ID of the node executing the statement) that does not have unique ordering.
'rowid'YesYes
server_versionThe version of PostgreSQL that CockroachDB emulates.Version-dependentNoYes
server_version_numThe version of PostgreSQL that CockroachDB emulates.Version-dependentYesYes
session_idThe ID of the current session.Session-dependentNoYes
session_userThe user connected for the current session.User in connection stringNoYes
sql_safe_updatesIf true, the following potentially unsafe SQL statements are disallowed: DROP DATABASE of a non-empty database and all dependent objects; DELETE and UPDATE without a WHERE clause, unless a LIMIT clause is included; SELECT ... FOR UPDATE and SELECT ... FOR SHARE without a WHERE or LIMIT clause; ALTER TABLE ... DROP COLUMN; and converting an existing table to REGIONAL BY ROW using ALTER TABLE ... LOCALITY, unless a region column has already been added to the table.
For more details, refer to Allow potentially unsafe SQL statements.
true for interactive sessions from the built-in SQL client,
false for sessions from other clients
YesYes
statement_timeoutThe amount of time a statement can run before being stopped.
This value can be an int (e.g., 10) and will be interpreted as milliseconds. It can also be an interval or string argument, where the string can be parsed as a valid interval (e.g., '4s').
A value of 0 turns it off.
The value set by the sql.defaults.statement_timeout cluster setting (0s, by default).YesYes
stub_catalog_tablesIf off, querying an unimplemented, empty pg_catalog table will result in an error, as is the case in v20.2 and earlier. If on, querying an unimplemented, empty pg_catalog table simply returns no rows.onYesYes
timezoneThe default time zone for the current session.UTCYesYes
tracingThe trace recording state.offYesYes
transaction_isolationThe isolation level at which the transaction executes (SERIALIZABLE or READ COMMITTED). See Isolation levels.SERIALIZABLEYesYes
transaction_priorityThe priority of the current transaction. See Transactions: Transaction priorities for more details. This session variable was called transaction priority (with a space) in CockroachDB 1.x. It has been renamed for compatibility with PostgreSQL.NORMALYesYes
transaction_read_onlyThe access mode of the current transaction. See SET TRANSACTION for more details.offYesYes
transaction_rows_read_errThe limit for the number of rows read by a SQL transaction. If this value is exceeded the transaction will fail (or the event will be logged to SQL_INTERNAL_PERF for internal transactions).0YesYes
transaction_rows_read_logThe threshold for the number of rows read by a SQL transaction. If this value is exceeded, the event will be logged to SQL_PERF (or SQL_INTERNAL_PERF for internal transactions).0YesYes
transaction_rows_written_errThe limit for the number of rows written by a SQL transaction. If this value is exceeded the transaction will fail (or the event will be logged to SQL_INTERNAL_PERF for internal transactions).0YesYes
transaction_rows_written_logThe threshold for the number of rows written by a SQL transaction. If this value is exceeded, the event will be logged to SQL_PERF (or SQL_INTERNAL_PERF for internal transactions).0YesYes
transaction_statusThe state of the current transaction. See Transactions for more details.NoTxnNoYes
transaction_timeoutAborts an explicit transaction when it runs longer than the configured duration. Stored in milliseconds; can be expressed in milliseconds or as an INTERVAL.0YesYes
troubleshooting_mode_enabledWhen enabled, avoid performing additional work on queries, such as collecting and emitting telemetry data. This session variable is particularly useful when the cluster is experiencing issues, unavailability, or failure.offYesYes
use_declarative_schema_changerWhether to use the declarative schema changer for supported statements.onYesYes
vector_search_beam_sizeThe size of the vector search beam, which determines how many vector partitions are considered during query execution. For details, refer to Tune vector indexes.32YesYes
vectorizeThe vectorized execution engine mode. Options include on and off. For more details, see Configure vectorized execution for CockroachDB.onYesYes
virtual_cluster_nameThe name of the virtual cluster that the SQL client is connected to.Session-dependentNoYes
The following session variables are exposed only for backwards compatibility with earlier CockroachDB releases and have no impact on how CockroachDB runs:
Variable nameInitial valueModify with SET?View with SHOW?
backslash_quotesafe_encodingNoYes
client_encodingUTF8NoYes
default_tablespaceNoYes
enable_drop_enum_valueoffYesYes
enable_seqscanonYesYes
escape_string_warningonNoYes
experimental_enable_hash_sharded_indexesoffYesYes
integer_datetimesonNoYes
max_identifier_length128NoYes
max_index_keys32NoYes
standard_conforming_stringsonNoYes
server_encodingUTF8YesYes
synchronize_seqscansonNoYes
synchronous_commitonYesYes

Examples

Showing the value of a single session variable

Showing the value of all session variables

See also

  • , including