SHOW STATISTICS

The SHOW STATISTICS statement lists table statistics used by the cost-based optimizer.

Synopsis

SHOWSTATISTICSFORTABLEtable_name

Required Privileges

No privileges are required to list table statistics.

Parameters

ParameterDescription
table_nameThe name of the table you want to view statistics for.

Examples

List table statistics

  1. > CREATE STATISTICS students ON id FROM students_by_list;
  1. CREATE STATISTICS
  1. > SHOW STATISTICS FOR TABLE students_by_list;
  1. statistics_name | column_names | created | row_count | distinct_count | null_count | histogram_id
  2. +-----------------+--------------+----------------------------------+-----------+----------------+------------+--------------+
  3. students | {"id"} | 2018-10-26 15:06:34.320165+00:00 | 0 | 0 | 0 | NULL
  4. (1 row)

Delete statistics

To delete statistics for all tables in all databases:

  1. > DELETE FROM system.table_statistics WHERE true;

To delete a named set of statistics (e.g, one named "my_stats"), run a query like the following:

  1. > DELETE FROM system.table_statistics WHERE name = 'my_stats';

For more information about the DELETE statement, see DELETE.

See Also

Was this page helpful?
YesNo