After statistics are collected or when you want to confirm whether statistics exist for a table, OceanBase Database provides various views to query statistics.
Query index and table-level statistics
To query table-level and index statistics, you can query the following views.
| Mode | View | Description |
|---|---|---|
| Oracle | ALL_TAB_STATISTICS |
Queries table-level statistics. |
| Oracle | DBA_TAB_STATISTICS |
Queries table-level statistics. |
| Oracle | USER_TAB_STATISTICS |
Queries table-level statistics. |
| Oracle | ALL_IND_STATISTICS |
Queries index statistics. |
| Oracle | DBA_IND_STATISTICS |
Queries index statistics. |
| Oracle | USER_IND_STATISTICS |
Queries index statistics. |
| MySQL | OCEANBASE.DBA_TAB_STATISTICS |
Queries table-level statistics. |
| MySQL | OCEANBASE.DBA_IND_STATISTICS |
Queries index statistics. |
The following fields are important in the views:
NUM_ROWS: the total number of rows in a table or index.AVG_ROW_LEN: the average row length of a table.LAST_ANALYZED: the time when statistics are collected. If this field is not NULL, statistics are collected for the table or index.STATTYPE_LOCKED: specifies whether statistics of a table are locked. If this field is not NULL, statistics of the table are locked.
Query column-level statistics
To query column-level statistics, you can query the following views.
| Mode | View | Description |
|---|---|---|
| Oracle | ALL_TAB_COL_STATISTICS |
Queries GLOBAL column-level statistics. |
| Oracle | DBA_TAB_COL_STATISTICS |
Queries GLOBAL column-level statistics. |
| Oracle | USER_TAB_COL_STATISTICS |
Queries GLOBAL column-level statistics. |
| Oracle | ALL_PART_COL_STATISTICS |
Queries PARTITION column-level statistics. |
| Oracle | DBA_PART_COL_STATISTICS |
Queries PARTITION column-level statistics. |
| Oracle | USER_PART_COL_STATISTICS |
Queries PARTITION column-level statistics. |
| Oracle | ALL_SUBPART_COL_STATISTICS |
Queries SUBPARTITION column-level statistics. |
| Oracle | DBA_SUBPART_COL_STATISTICS |
Queries SUBPARTITION column-level statistics. |
| Oracle | USER_SUBPART_COL_STATISTICS |
Queries SUBPARTITION column-level statistics. |
| MySQL | OCEANBASE.DBA_TAB_COL_STATISTICS |
Queries GLOBAL column-level statistics. |
| MySQL | OCEANBASE.DBA_PART_COL_STATISTICS |
Queries PARTITION column-level statistics. |
| MySQL | OCEANBASE.DBA_SUBPART_COL_STATISTICS |
Queries SUBPARTITION column-level statistics. |
The following fields are important in the views:
NUM_DISTINCT: the number of distinct values (NDV) of a column.LOW_VALUE: the minimum value of a column.HIGH_VALUE: the maximum value of a column.DENSITY: the density of a column, which is related to histograms.NUM_NULLS: the number of NULL values in a column.NUM_BUCKETS: the number of histogram buckets.LAST_ANALYZED: the time when statistics are collected. If this field is not NULL, statistics are collected for the column at some point in the past.SAMPLE_SIZE: the number of data rows used to collect statistics.AVG_COL_LEN: the average column length.HISTOGRAM: the histogram type. If this field is not NULL, a histogram is collected for the column.
Query column histogram statistics
To query histogram statistics, you can query the following views.
| Mode | View | Description |
|---|---|---|
| Oracle | ALL_TAB_HISTOGRAMS |
Queries GLOBAL column-level histogram information. |
| Oracle | DBA_TAB_HISTOGRAMS |
Queries GLOBAL column-level histogram information. |
| Oracle | USER_TAB_HISTOGRAMS |
Queries GLOBAL column-level histogram information. |
| Oracle | ALL_PART_HISTOGRAMS |
Queries PARTITION column-level histogram information. |
| Oracle | DBA_PART_HISTOGRAMS |
Queries PARTITION column-level histogram information. |
| Oracle | USER_PART_HISTOGRAMS |
Queries PARTITION column-level histogram information. |
| Oracle | ALL_SUBPART_HISTOGRAMS |
Queries SUBPARTITION column-level histogram information. |
| Oracle | DBA_SUBPART_HISTOGRAMS |
Queries SUBPARTITION column-level histogram information. |
| Oracle | USER_SUBPART_HISTOGRAMS |
Queries SUBPARTITION column-level histogram information. |
| MySQL | OCEANBASE.DBA_TAB_HISTOGRAMS |
Queries GLOBAL column-level histogram statistics. |
| MySQL | OCEANBASE.DBA_PART_HISTOGRAMS |
Queries PARTITION column-level histogram information. |
| MySQL | OCEANBASE.DBA_SUBPART_HISTOGRAMS |
Queries SUBPARTITION column-level histogram information. |
The following fields are important in the views:
ENDPOINT_NUMBER: the total number of rows in the column up to the current bucket.ENDPOINT_ACTUAL_VALUE: the printed character value corresponding to the end value of the current bucket.ENDPOINT_REPEAT_COUNT: the frequency of the end value of the current bucket.
