Note
This view is introduced in OceanBase Database 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 statistics were last collected. |
| SAMPLE_SIZE | decimal(10,0) | NO | The sample size used during the analysis. |
| GLOBAL_STATS | varchar(3) | NO | YES: indicates that statistics are directly collected or incrementally maintained.NO: other cases. |
| USER_STATS | varchar(3) | NO | Specifies whether to collect statistics for partitions. |
| 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 scope of the statistics. |
Sample query
Query the column statistics and histogram information of the t_subpart table in the system 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 column statistics for tables: DBA_TAB_STATISTICS
View column statistics for partitions: DBA_PART_COL_STATISTICS
View column statistics for subpartitions: DBA_SUBPART_COL_STATISTICS
View histogram statistics for tables: DBA_TAB_HISTOGRAMS
View histogram statistics for partitions: DBA_PART_HISTOGRAMS
View histogram statistics for subpartitions: DBA_SUBPART_HISTOGRAMS
View index statistics: DBA_IND_STATISTICS
For more information about how to collect statistics, see the following topics: