Note
This view is available starting with V4.0.0.
Purpose
This view displays the column statistics and histogram information of all tables in the current tenant.
Columns
| Column | Type | Nullable? | Description |
|---|---|---|---|
| OWNER | varchar(128) | NO | The user to which the column belongs. |
| TABLE_NAME | varchar(128) | NO | The name of the table to which the column belongs. |
| COLUMN_NAME | varchar(128) | NO | The name of the column. |
| NUM_DISTINCT | decimal(10,0) | NO | The number of distinct values in the column. |
| LOW_VALUE | varchar(128) | NO | The minimum value of the column. |
| HIGH_VALUE | varchar(128) | NO | The maximum value of the column. |
| DENSITY | decimal(10,0) | NO | The density of the column. |
| NUM_NULLS | decimal(10,0) | NO | The number of NULL values in the column. |
| NUM_BUCKETS | decimal(10,0) | NO | The number of buckets in the histogram of the column. |
| LAST_ANALYZED | datetime(6) | NO | The time when the last analysis was performed. |
| SAMPLE_SIZE | decimal(10,0) | NO | The sampling size during the analysis. |
| GLOBAL_STATS | varchar(3) | NO | YES: indicates that the statistics were directly collected or incrementally maintained.NO: other cases. |
| USER_STATS | varchar(3) | NO | Indicates whether the partition statistics were user-defined. |
| NOTES | varchar(80) | NO | Records some additional attributes. |
| AVG_COL_LEN | decimal(10,0) | NO | The average length of the column. |
| HISTOGRAM | varchar(15) | NO | The type of the histogram. |
| SCOPE | varchar(7) | NO | The effective scope of the statistics. |
Sample query
Query the column statistics and histogram information of the t_subpart table in the current user 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 the statistics of all tenants: CDB_TAB_COL_STATISTICS
View the column statistics at the table level: DBA_TAB_STATISTICS
View the column statistics at the partition level: DBA_PART_COL_STATISTICS
View the column statistics at the subpartition level: DBA_SUBPART_COL_STATISTICS
View the histogram statistics at the table level: DBA_TAB_HISTOGRAMS
View the histogram statistics at the partition level: DBA_PART_HISTOGRAMS
View the histogram statistics at the subpartition level: DBA_SUBPART_HISTOGRAMS
View the index statistics: DBA_IND_STATISTICS
For more information about how to collect statistics, see the following topics: