The OceanBase Database optimizer provides a variety of views for you to query various types of statistics after statistics are collected.
Query statistics of indexes and tables
The following table describes the views that you can query for statistics of indexes and tables.
| Mode | View name | Description |
|---|---|---|
| Oracle | ALL_TAB_STATISTICS |
Displays statistics of tables. |
| Oracle | DBA_TAB_STATISTICS |
Displays statistics of tables. |
| Oracle | USER_TAB_STATISTICS |
Displays statistics of tables. |
| Oracle | ALL_IND_STATISTICS |
Displays statistics of indexes. |
| Oracle | DBA_IND_STATISTICS |
Displays statistics of indexes. |
| Oracle | USER_IND_STATISTICS |
Displays statistics of indexes. |
| MySQL | OCEANBASE.DBA_TAB_STATISTICS |
Displays statistics of tables. |
| MySQL | OCEANBASE.DBA_IND_STATISTICS |
Displays statistics of indexes. |
Key fields to note within these views include:
NUM_ROWS: the total number of rows in the table or index.AVG_ROW_LEN: the average length of rows in the table.LAST_ANALYZED: the time when statistics were collected. A non-NULL value indicates that statistics of the table or index have already been collected.STATTYPE_LOCKED: indicates whether the user has been locked. A non-NULL value indicates that statistics of the table are locked.
Query statistics of columns
The following table describes the views that you can query for statistics of columns.
| Mode | View name | Description |
|---|---|---|
| Oracle | ALL_TAB_COL_STATISTICS |
Displays global column statistics. |
| Oracle | DBA_TAB_COL_STATISTICS |
Displays global column statistics. |
| Oracle | USER_TAB_COL_STATISTICS |
Displays global column statistics. |
| Oracle | ALL_PART_COL_STATISTICS |
Displays partition-level column statistics. |
| Oracle | DBA_PART_COL_STATISTICS |
Displays partition-level column statistics. |
| Oracle | USER_PART_COL_STATISTICS |
Displays partition-level column statistics. |
| Oracle | ALL_SUBPART_COL_STATISTICS |
Displays subpartition-level column statistics. |
| Oracle | DBA_SUBPART_COL_STATISTICS |
Displays subpartition-level column statistics. |
| Oracle | USER_SUBPART_COL_STATISTICS |
Displays subpartition-level column statistics. |
| MySQL | OCEANBASE.DBA_TAB_COL_STATISTICS |
Displays global column statistics. |
| MySQL | OCEANBASE.DBA_PART_COL_STATISTICS |
Displays partition-level column statistics. |
| MySQL | OCEANBASE.DBA_SUBPART_COL_STATISTICS |
Displays subpartition-level column statistics. |
Key fields to note within these views include:
NUM_DISTINCT: the number of distinct values (NDV) in the column.LOW_VALUE: the minimum value of the column.HIGH_VALUE: the maximum value of the column.DENSITY: the density of the column. This field is related to the histogram.NUM_NULLS: the number of NULL values in the column.NUM_BUCKETS: the number of histogram buckets.LAST_ANALYZED: the time when statistics were collected. A non-NULL value indicates that statistics of the column have already been collected.SAMPLE_SIZE: the number of data rows referenced by the statistics collection.AVG_COL_LEN: the average length of the column.HISTOGRAM: the type of the histogram. A non-NULL value indicates that the histograms of the column have been collected.
Query histogram statistics of columns
The following table describes the views that you can query for histogram statistics of columns.
| Mode | View name | Description |
|---|---|---|
| Oracle | ALL_TAB_HISTOGRAMS |
Displays global column histogram statistics. |
| Oracle | DBA_TAB_HISTOGRAMS |
Displays global column histogram statistics. |
| Oracle | USER_TAB_HISTOGRAMS |
Displays global column histogram statistics. |
| Oracle | ALL_PART_HISTOGRAMS |
Displays partition-level column histogram statistics. |
| Oracle | DBA_PART_HISTOGRAMS |
Displays partition-level column histogram statistics. |
| Oracle | USER_PART_HISTOGRAMS |
Displays partition-level column histogram statistics. |
| Oracle | ALL_SUBPART_HISTOGRAMS |
Displays subpartition-level column histogram statistics. |
| Oracle | DBA_SUBPART_HISTOGRAMS |
Displays subpartition-level column histogram statistics. |
| Oracle | USER_SUBPART_HISTOGRAMS |
Displays subpartition-level column histogram statistics. |
| MySQL | OCEANBASE.DBA_TAB_HISTOGRAMS |
Displays global column histogram statistics. |
| MySQL | OCEANBASE.DBA_PART_HISTOGRAMS |
Displays partition-level column histogram statistics. |
| MySQL | OCEANBASE.DBA_SUBPART_HISTOGRAMS |
Displays subpartition-level column histogram statistics. |
Key fields to note within these views include:
ENDPOINT_NUMBER: the total number of rows of the column accumulated by the current bucket.ENDPOINT_ACTUAL_VALUE: the printed literal corresponding to the end value of the current bucket.ENDPOINT_REPEAT_COUNT: the occurrence frequency of the end value of the current bucket.