Note
This view is available starting with V4.0.0.
Overview
Displays the column statistics and histograms for all tables in the tenant.
Columns
Field Name |
Type |
Whether can be NULL |
Description |
|---|---|---|---|
| OWNER | varchar(128) | NO | Database to Which Column Belongs |
| TABLE_NAME | varchar(128) | NO | Table name of the column |
| COLUMN_NAME | varchar(128) | NO | Column name |
| NUM_DISTINCT | decimal(10,0) | NO | Number of distinct values in the column |
| LOW_VALUE | varchar(128) | NO | Minimum value of the column |
| HIGH_VALUE | varchar(128) | NO | Maximum value of the column |
| DENSITY | decimal(10,0) | NO | Column Density |
| NUM_NULLS | decimal(10,0) | NO | In the columnNULLNumber of Values |
| NUM_BUCKETS | decimal(10,0) | NO | Number of Buckets in a Column Histogram |
| LAST_ANALYZED | datetime(6) | NO | Last Analysis Time |
| SAMPLE_SIZE | decimal(10,0) | NO | Sample size for analysis |
| GLOBAL_STATS | varchar(3) | NO |
|
| USER_STATS | varchar(3) | NO | Whether partition statistics are user-defined |
| NOTES | varchar(80) | NO | Record some additional attributes |
| AVG_COL_LEN | decimal(10,0) | NO | Average Column Length |
| HISTOGRAM | varchar(15) | NO | Histogram type |
| SCOPE | varchar(7) | NO | Validity period of statistics |
Sample query
The user tenant queries the column statistics and histogram information for the t_subpart table within its own tenant.
obclient [oceanbase]> SELECT OWNER, TABLE_NAME, COLUMN_NAME, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE, DENSITY, NUM_NULLS, NUM_BUCKETS, SAMPLE_SIZE, AVG_COL_LEN, HISTOGRAM FROM oceanbase.DBA_TAB_COL_STATISTICS WHERE TABLE_NAME ='t_subpart' ORDER BY 1, 2, 3;
The query result is as follows:
+-------+------------+-------------+--------------+-----------+------------+--------------+-----------+-------------+-------------+-------------+-----------+
| OWNER | TABLE_NAME | COLUMN_NAME | NUM_DISTINCT | LOW_VALUE | HIGH_VALUE | DENSITY | NUM_NULLS | NUM_BUCKETS | SAMPLE_SIZE | AVG_COL_LEN | HISTOGRAM |
+-------+------------+-------------+--------------+-----------+------------+--------------+-----------+-------------+-------------+-------------+-----------+
| test | t_subpart | c1 | 9800 | 0 | 9999 | 0.0001020408 | 0 | 5 | 10000 | 20 | HYBRID |
| test | t_subpart | c2 | 1012 | 0 | 999 | 0.0009881423 | 0 | 5 | 10000 | 20 | HYBRID |
| test | t_subpart | c3 | 2030 | 0 | 1999 | 0.0004926108 | 0 | 5 | 10000 | 20 | HYBRID |
+-------+------------+-------------+--------------+-----------+------------+--------------+-----------+-------------+-------------+-------------+-----------+
3 rows in set
References
View statistics for all tenants: CDB_TAB_COL_STATISTICS
View table-level column statistics: DBA_TAB_STATISTICS
View partition-level column statistics: DBA_PART_COL_STATISTICS
View column statistics at the subpartition level: DBA_SUBPART_COL_STATISTICS
View table-level histogram statistics: DBA_TAB_HISTOGRAMS
View histogram statistics at the partition level: DBA_PART_HISTOGRAMS
View histogram statistics at the subpartition level: DBA_SUBPART_HISTOGRAMS
View index statistics: DBA_IND_STATISTICS
For information about how to collect statistics, see the following topics:
