标签:loop object_id alt cpu 就会 from ops HERE 信息
作为一线的dba,经常会遇到批量业务或联机业务sql中统计信息不准导致的执行计划异常的问题。虽较为常见,但还是记录一下,作为SQL执行异常专题的开篇一章。要了解执行计划,首先要理解统计信息,因为ORACLE主要是基于表的统计信息计算表访问、过滤、表关联的消耗,从而生成最终的执行计划,如果表的统计信息不准,自然而然也就会影响最终sql的执行结果。
一、统计信息的分类
二、在以上统计信息中,有关表的统计信息不准导致的执行计划存在异常的现象最为常见:
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------
Plan hash value: 3251985671
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 23 | 344 (0)| 00:00:05 |
| 1 | NESTED LOOPS | | 1 | 23 | 344 (0)| 00:00:05 |
| 2 | TABLE ACCESS FULL| STATIC_TEST1 | 1 | 18 | 343 (0)| 00:00:05 |
|* 3 | INDEX RANGE SCAN | STATIC_TEST_IDX | 1 | 5 | 1 (0)| 00:00:01 |
--------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("A"."OBJECT_ID"="B"."OBJECT_ID")
15 rows selected.
SQL> explain plan for select a.object_name,b.object_id
from static_test a,static_test1 b
where a.object_id=b.object_id; 2 3
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------
Plan hash value: 1637592733
------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 35 | 344 (0)| 00:00:05 |
| 1 | NESTED LOOPS | | 1 | 35 | 344 (0)| 00:00:05 |
| 2 | NESTED LOOPS | | 1 | 35 | 344 (0)| 00:00:05 |
| 3 | TABLE ACCESS FULL | STATIC_TEST1 | 1 | 5 | 343 (0)| 00:00:05 |
|* 4 | INDEX RANGE SCAN | STATIC_TEST_IDX | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID| STATIC_TEST | 1 | 30 | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("A"."OBJECT_ID"="B"."OBJECT_ID")
17 rows selected.
SQL> explain plan for select a.object_name,b.object_id
from static_test a,static_test1 b
where a.object_id=b.object_id; 2 3
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------
Plan hash value: 1637592733
------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 35 | 344 (0)| 00:00:05 |
| 1 | NESTED LOOPS | | 1 | 35 | 344 (0)| 00:00:05 |
| 2 | NESTED LOOPS | | 1 | 35 | 344 (0)| 00:00:05 |
| 3 | TABLE ACCESS FULL | STATIC_TEST1 | 1 | 5 | 343 (0)| 00:00:05 |
|* 4 | INDEX RANGE SCAN | STATIC_TEST_IDX | 1 | | 1 (0)| 00:00:01 |
| 5 | TABLE ACCESS BY INDEX ROWID| STATIC_TEST | 1 | 30 | 1 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("A"."OBJECT_ID"="B"."OBJECT_ID")
17 rows selected.
标签:loop object_id alt cpu 就会 from ops HERE 信息
原文地址:https://www.cnblogs.com/dayu-liu/p/9671334.html