查询统计信息部分提供性能调试信息

如果启用了 EXPLAIN_STAT 配置参数,那么“查询统计信息”部分将显示在 SQL 的 SET EXPLAIN 语句和 onmode -Y session_id 命令所显示的说明输出文件中。

说明输出文件中的“查询统计信息”部分显示了查询计划预期返回的估计行数、实际返回的行数以及有关查询的其他信息。可以使用这些信息(显示查询计划综合流量以及查询的每个阶段通过的行流量数)来调试性能问题。

以下示例显示了 SET EXPLAIN 输出中的查询统计信息。如果已扫描或已连接的估计行数和实际行数相差很大,那么有关这些表的统计信息可能是旧的,应该更新它们。

图: SET EXPLAIN 输出中的查询统计信息

select * from tab1, tab2 where tab1.c1 = tab2.c1 and tab1.c3 between 0 and 15

Estimated Cost: 104
Estimated # of Rows Returned: 69

    1) zelaine.tab2: SEQUENTIAL SCAN

    2) zelaine.tab1: INDEX PATH

        (1) Index Keys: c1 c3   (Serial, fragments: ALL)
                Lower Index Filter: (zelaine.tab1.c1 = zelaine.tab2.c1 
                             AND zelaine.tab1.c3 >= 0 ) 
                Upper Index Filter: zelaine.tab1.c3 <= 15 
NESTED LOOP JOIN 

Query statistics:
-----------------

    Table map :
  ----------------------------
    Internal name     Table name
  ----------------------------
    t1                tab2
    t2                tab1

    type     table  rows_prod  est_rows  rows_scan  time       est_cost
  -------------------------------------------------------------------
    scan     t1     50         50        50         00:00:00   4       

    type     table  rows_prod  est_rows  rows_scan  time       est_cost
  -------------------------------------------------------------------
    scan     t2     67         69        4          00:00:00   2       

    type     rows_prod  est_rows  time       est_cost
  -------------------------------------------------
    nljoin   67         70        00:00:00   104