Oracle PL/SQL Tutorial/SQL PLUS Session Environment/EXPLAIN PLAN — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 10:04, 26 мая 2010
Execution plan for the specified statement_id
SQL>
SQL> UNDEFINE v_statement_id;
SQL>
SQL> SELECT id ||
2 DECODE(id, 0, "", LPAD(" ", 2*(level - 1))) || " " ||
3 operation || " " ||
4 options || " " ||
5 object_name || " " ||
6 object_type || " " ||
7 DECODE(cost, NULL, "", "Cost = " || position)
8 AS execution_plan
9 FROM plan_table
10 CONNECT BY PRIOR id = parent_id
11 AND statement_id = "&&v_statement_id"
12 START WITH id = 0
13 AND statement_id = "&v_statement_id";
Enter value for v_statement_id:
old 11: AND statement_id = "&&v_statement_id"
new 11: AND statement_id = ""
old 13: AND statement_id = "&v_statement_id"
new 13: AND statement_id = ""
no rows selected
SQL>
Explain sql statement
SQL>
SQL> create table emp (
2 EmpNo NUMBER(10) primary key,
3 Name VARCHAR2(40),
4 DeptNo NUMBER(2),
5 Salary NUMBER(7,2),
6 Birth_Date DATE,
7 Soc_Sec_Num VARCHAR2(9),
8 State_Code CHAR(2)
9 );
SQL>
SQL> explain plan
2 set Statement_Id = "TEST"
3 for
4 select * from emp;
SQL>
SQL> select LPAD(" ",2*Level)||Operation||" "||Options||" "||Object_Name Q_Plan
2 from PLAN_TABLE
3 where Statement_Id = "TEST"
4 connect by prior ID = Parent_ID and Statement_ID = "TEST"
5 start with ID=0;
Q_PLAN
------------------------------------------------------------------------------------------------------------------------
SELECT STATEMENT
TABLE ACCESS FULL EMP
TABLE ACCESS FULL EMP
SELECT STATEMENT
TABLE ACCESS FULL EMP
TABLE ACCESS FULL EMP
SQL>
SQL> set autotrace off explain
SQL>
SQL>
SQL> drop table emp;
SET AUTOTRACE TRACE EXP and EXPLAIN PLAN output
SQL>
SQL> select * from dual;
Execution Plan
----------------------------------------------------------
Plan hash value: 272002086
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
SQL>
SQL> SET AUTOTRACE OFF
SQL>