crdb_internal

The crdb_internal system catalog is a schema that contains information about internal objects, processes, and metrics related to a specific database.

Warning:

We do not recommend using crdb_internal tables in production environments for the following reasons:

  • The contents of crdb_internal are unstable, and subject to change in new releases of CockroachDB, without prior notice.
  • There are memory and latency costs associated with each table in crdb_internal. Accessing the tables in the schema can impact cluster stability and performance.

Data exposed by crdb_internal

Each table in crdb_internal corresponds to an internal object, process, or metric, for a specific database. crdb_internal tables are read-only.

In CockroachDB v21.2, crdb_internal includes the following tables:

Table Description
active_range_feeds Contains information about range feeds on nodes in your cluster.
backward_dependencies Contains information about backward dependencies.
builtin_functions Contains information about supported functions.
cluster_contended_indexes Contains information about contended indexes in your cluster.
cluster_contended_keys Contains information about contended keys in your cluster.
cluster_contended_tables Contains information about contended tables in your cluster.
cluster_contention_events Contains information about contention in your cluster.
cluster_database_privileges Contains information about the database privileges on your cluster.
cluster_distsql_flows Contains information about the flows of the DistSQL execution scheduled in your cluster.
cluster_inflight_traces Contains information about in-flight tracing in your cluster.
cluster_queries Contains information about queries running on your cluster.
cluster_sessions Contains information about cluster sessions, including current and past queries.
cluster_settings Contains information about cluster settings.
cluster_transactions Contains information about transactions running on your cluster.
create_statements Contains information about tables and indexes in your database.
create_type_statements Contains information about user-defined types in your database.
cross_db_references Contains information about objects that reference other objects, such as foreign keys or views, across databases in your cluster.
databases Contains information about the databases in your cluster.
default_privileges Contains information about per-database default privileges.
feature_usage Contains information about feature usage on your cluster.
forward_dependencies Contains information about forward dependencies.
gossip_alerts Contains information about gossip alerts.
gossip_liveness Contains information about your cluster's gossip liveness.
gossip_network Contains information about your cluster's gossip network.
gossip_nodes Contains information about nodes in your cluster's gossip network.
index_columns Contains information about indexed columns in your cluster.
index_usage_statistics Contains statistics about the primary and secondary indexes used in statements.
interleaved Contains information about interleaved objects in your cluster.
invalid_objects Contains information about invalid objects in your cluster.
jobs Contains information about jobs running on your cluster.
kv_node_liveness Contains information about node liveness.
kv_node_status Contains information about node status at the key-value layer.
kv_store_status Contains information about the key-value store for your cluster.
leases Contains information about leases in your cluster.
lost_descriptors_with_data Contains information about table descriptors that have been deleted but still have data left over in storage.
node_build_info Contains information about nodes in your cluster.
node_contention_events Contains information about contention on the gateway node of your cluster.
node_distsql_flows Contains information about the flows of the DistSQL execution scheduled on nodes in your cluster.
node_inflight_trace_spans Contains information about currently in-flight spans in the current node.
node_metrics Contains metrics for nodes in your cluster.
node_queries Contains information about queries running on nodes in your cluster.
node_runtime_info Contains runtime information about nodes in your cluster.
node_sessions Contains information about sessions to nodes in your cluster.
node_statement_statistics Contains statement statistics for nodes in your cluster.
node_transaction_statistics Contains transaction statistics for nodes in your cluster.
node_transactions Contains information about transactions for nodes in your cluster.
node_txn_stats Contains transaction statistics for nodes in your cluster.
partitions Contains information about partitions in your cluster.
predefined_comments Contains predefined comments about your cluster.
ranges Contains information about ranges in your cluster.
ranges_no_leases Contains information about ranges in your cluster, without leases.
regions Contains information about cluster regions.
schema_changes Contains information about schema changes in your cluster.
session_trace Contains session trace information for your cluster.
session_variables Contains information about session variables in your cluster.
statement_statistics Table that aggregates in-memory and persisted statistics from system.statement_statistics within hourly time intervals based on UTC time, rounded down to the nearest hour. You can manually reset the statistics by calling SELECT crdb_internal.reset_sql_stats().
table_columns Contains information about table columns in your cluster.
table_indexes Contains information about table indexes in your cluster.
table_row_statistics Contains row count statistics for tables in the current database.
tables Contains information about tables in your cluster.
transaction_statistics Table that aggregates in-memory and persisted statistics from system.transaction_statistics within hourly time intervals based on UTC time, rounded down to the nearest hour. You can manually reset the statistics by calling SELECT crdb_internal.reset_sql_stats().
zones Contains information about zone configurations in your cluster.

To list the crdb_internal tables for the current database, use the following SHOW TABLES statement:

icon/buttons/copy
> SHOW TABLES FROM crdb_internal;
   schema_name  |         table_name          | type  | owner | estimated_row_count
----------------+-----------------------------+-------+-------+----------------------
  crdb_internal | backward_dependencies       | table | NULL  |                NULL
  crdb_internal | builtin_functions           | table | NULL  |                NULL
  ...

Querying crdb_internal tables

To get detailed information about objects, processes, or metrics related to your database, you can read from the crdb_internal table that corresponds to the item of interest.

Tip:

To ensure that you can view all of the tables in crdb_internal, query the tables as a user with admin privileges.

Note:

Unless specified otherwise, queries to crdb_internal assume the current database.

For example, to return the crdb_internal table for the ranges of the movr database, you can use the following statement:

icon/buttons/copy
> SELECT * FROM movr.crdb_internal.ranges;
  range_id |                                                                         start_key                                                                          |                                        start_pretty                                         |                                                                          end_key                                                                           |                                         end_pretty                                          | database_name |           table_name            | index_name | replicas |    replica_localities    | learner_replicas |       split_enforced_until       | lease_holder | range_size
-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+---------------+---------------------------------+------------+----------+--------------------------+------------------+----------------------------------+--------------+-------------
         1 |                                                                                                                                                            | /Min                                                                                        | \004\000liveness-                                                                                                                                          | /System/NodeLiveness                                                                        |               |                                 |            | {1}      | {"region=us-east1,az=b"} | {}               | NULL                             |            1 |       8323
         2 | \004\000liveness-                                                                                                                                          | /System/NodeLiveness                                                                        | \004\000liveness.                                                                                                                                          | /System/NodeLivenessMax                                                                     |               |                                 |            | {1}      | {"region=us-east1,az=b"} | {}               | NULL                             |            1 |       9278
         3 | \004\000liveness.                                                                                                                                          | /System/NodeLivenessMax                                                                     | \004tsd                                                                                                                                                    | /System/tsd                                                                                 |               |                                 |            | {1}      | {"region=us-east1,az=b"} | {}               | NULL                             |            1 |      32377
         4 | \004tsd                                                                                                                                                    | /System/tsd                                                                                 | \004tse                                                                                                                                                    | /System/"tse"                                                                               |               |                                 |            | {1}      | {"region=us-east1,az=b"} | {}               | NULL                             |            1 |    4067446
(65 rows)

See also

YesYes NoNo