SQL> SELECT status, sql_id, sql_child_number
2 FROM v$session
3 WHERE username = 'CURTIS';
STATUS SQL_ID SQL_CHILD_NUMBER
------- ------------- ---------------
ACTIVE 1scu79x31qavt 1
SQL> SELECT sql_id, child_number, sql_text
2 FROM v$sql
3 WHERE sql_fulltext LIKE '%online discount%'
4 AND sql_text NOT LIKE '%v$sql%';
SQL_ID CHILD_NUMBER SQL_TEXT
------------- ------------ --------------------------------------------------
1hqjydsjbvmwq 0 SELECT SUM(AMOUNT_SOLD) FROM SALES S, PROMOTIONS P
WHERE S.PROMO_ID = P.PROMO_ID AND PROMO_SUBCATEGORY
= 'online discount'
SQL> SELECT * FROM table(dbms_xplan.display_cursor('1hqjydsjbvmwq', 0));
PLAN_TABLE_OUTPUT -----------------------------------------------------------------------------------
SQL_ID 1hqjydsjbvmwq, child number 0 ------------------------------------
SELECT SUM(AMOUNT_SOLD) FROM SALES S, PROMOTIONS P WHERE S.PROMO_ID =
P.PROMO_ID AND PROMO_SUBCATEGORY = 'online discount'
Plan hash value: 265338492
-----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 139 (100)| |
| 1 | SORT AGGREGATE | | 1 | 30 | | |
|* 2 | HASH JOIN | | 913K| 26M| 139 (33)| 00:00:01 |
|* 3 | TABLE ACCESS FULL | PROMOTIONS | 23 | 483 | 4 (0)| 00:00:01 |
| 4 | PARTITION RANGE ALL| | 918K| 8075K| 123 (27)| 00:00:01 |
| 5 | TABLE ACCESS FULL | SALES | 918K| 8075K| 123 (27)| 00:00:01 |
-----------------------------------------------------------------------------------
Predicate Information (identified by operation id):
--------------------------------------------------
2 - access("S"."PROMO_ID"="P"."PROMO_ID")
3 - filter("PROMO_SUBCATEGORY"='online discount')
SQL> SELECT * FROM table(dbms_xplan.display_awr('1hqjydsjbvmwq'));
PLAN_TABLE_OUTPUT
-----------------------------------------------------------------------------------
SQL_ID 1hqjydsjbvmwq
-------------------
SELECT SUM(AMOUNT_SOLD) FROM SALES S, PROMOTIONS P WHERE S.PROMO_ID
= P.PROMO_ID AND PROMO_SUBCATEGORY = 'online discount'
Plan hash value: 265338492
-----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 139 (100)| |
| 1 | SORT AGGREGATE | | 1 | 30 | | |
| 2 | HASH JOIN | | 913K| 26M| 139 (33)| 00:00:01 |
| 3 | TABLE ACCESS FULL | PROMOTIONS | 23 | 483 | 4 (0)| 00:00:01 |
| 4 | PARTITION RANGE ALL| | 918K| 8075K| 123 (27)| 00:00:01 |
| 5 | TABLE ACCESS FULL | SALES | 918K| 8075K| 123 (27)| 00:00:01 |
------------------------------------------------------------------------------------
SQL ID: 1hqjydsjbvmwq DB/Inst: DBM11203/DBM11203 Snaps: 576-577
-> 1st Capture and Last Capture Snap IDs
refer to Snapshot IDs witin the snapshot range
-> SELECT SUM(AMOUNT_SOLD) FROM SALES S, PROMOTIONS P WHERE S.PROMO_ID = ...
Plan Hash Total Elapsed 1st Capture Last Capture
# Value Time(ms) Executions Snap ID Snap ID
--- ---------------- ---------------- ------------- ------------- -------------
1 2446651477 16,577 2 577 577
2 265338492 14,736 4 577 577
--- ---------------------------------------------------------------------------
Plan 1(PHV: 2446651477)
----------------------
Stat Name Statement Per Execution % Snap
---------------------------------------- ---------- -------------- ------
Elapsed Time (ms) 16,577 8,288.6 50.2
CPU Time (ms) 16,071 8,035.3 50.9
Executions 2 N/A N/A
Buffer Gets 163,606 81,803.0 90.1
Disk Reads 161,900 80,950.0 96.0
Parse Calls 2 1.0 1.0
Rows 2 1.0 N/A
-------------------------------------------------------------------------
-----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2798 (100)| |
| 1 | SORT AGGREGATE | | 1 | 30 | | |
| 2 | NESTED LOOPS | | 913K| 26M| 2798 (27)| 00:00:12 |
| 3 | TABLE ACCESS FULL | PROMOTIONS | 23 | 483 | 4 (0)| 00:00:01 |
| 4 | PARTITION RANGE ALL| | 39950 | 351K| 121 (27)| 00:00:01 |
| 5 | TABLE ACCESS FULL | SALES | 39950 | 351K| 121 (27)| 00:00:01 |
-----------------------------------------------------------------------------------
Plan 2(PHV: 265338492)
---------------------
Stat Name Statement Per Execution % Snap
---------------------------------------- ---------- -------------- ------
Elapsed Time (ms) 14,736 3,684.0 44.6
CPU Time (ms) 14,565 3,641.2 46.1
Executions 4 N/A N/A
Buffer Gets 6,755 1,688.8 3.7
Disk Reads 6,485 1,621.3 3.8
Parse Calls 1 0.3 0.5
Rows 4 1.0 N/A
-------------------------------------------------------------------------
-----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 139 (100)| |
| 1 | SORT AGGREGATE | | 1 | 30 | | |
| 2 | HASH JOIN | | 913K| 26M| 139 (33)| 00:00:01 |
| 3 | TABLE ACCESS FULL | PROMOTIONS | 23 | 483 | 4 (0)| 00:00:01 |
| 4 | PARTITION RANGE ALL| | 918K| 8075K| 123 (27)| 00:00:01 |
| 5 | TABLE ACCESS FULL | SALES | 918K| 8075K| 123 (27)| 00:00:01 |
-----------------------------------------------------------------------------------
- 강좌 URL : http://www.gurubee.net/lecture/4392
- 구루비 강좌는 개인의 학습용으로만 사용 할 수 있으며, 다른 웹 페이지에 게재할 경우에는 출처를 꼭 밝혀 주시면 고맙겠습니다.~^^
- 구루비 강좌는 서비스 제공을 위한 목적이나, 학원 홍보, 수익을 얻기 위한 용도로 사용 할 수 없습니다.