Skip to main content
The SHOW STATISTICS statement lists table statistics used by the cost-based optimizer. By default, CockroachDB automatically generates statistics on all indexed columns and up to 100 non-indexed columns, and automatically collects multi-column statistics on the columns that prefix each index.

Synopsis

show_stats syntax diagram

Required privileges

To list table statistics, the user must have any privilege on the table being inspected.

Parameters

Options

Output

Examples

Setup

To follow along, run cockroach demo to start a temporary, in-memory cluster with the movr sample dataset preloaded:

List table statistics

Display forecasted statistics

The WITH FORECAST option calculates and displays forecasted statistics along with the existing table statistics. The following example shows 3 historical statistics collections and the subsequent forecast:

Delete statistics

To delete statistics for all tables in all databases:
To delete a named set of statistics (e.g, one named “users_stats”), run a query like the following:
For more information about the DELETE statement, see DELETE.

See also