499 Views
November 19, 14
スライド概要
Slideshare移行 2023-08-10時点View : 4840 views
個人事業主/Love SQL/Tuning/DBエンジニア/JPOUG/Oracle ACE Pro/ex-AWS BigData Consultant/ex-DEC/Oracle,PostgreSQL,Aurora,Redshift,Athena,SCT,DMS,Glue/偶にNowPlaying♪垂れ流し/
1
〜 2
Oracle Core Operating System 3
4
5
6
7
8
9
10
11
12
13
14
🔺 15
🔺 ✖ ✖ 16
17
18
19
20
21
22
〜 23
24
25000行が選択されました。 実行計画 ------------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 25000 | 12M| 1841 (1)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| DELUDING_TAB | 25000 | 12M| 1841 (1)| 00:00:01 | |* 2 | INDEX RANGE SCAN | PK_DELUDING_TAB | 25000 | | 54 (0)| 00:00:01 | ------------------------------------------------------------------------------------------------------30000行が選択されました。 実行計画 ---------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 30000 | 14M| 1947 (1)| 00:00:01 | |* 1 | TABLE ACCESS FULL| DELUDING_TAB | 30000 | 14M| 1947 (1)| 00:00:01 | ---------------------------------------------------------------------------------- 25
25000行が選択されました。 実行計画 ------------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 25000 | 12M| 1841 (1)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| DELUDING_TAB | 25000 | 12M| 1841 (1)| 00:00:01 | |* 2 | INDEX RANGE SCAN | PK_DELUDING_TAB | 25000 | | 54 (0)| 00:00:01 | ------------------------------------------------------------------------------------------------------30000行が選択されました。 実行計画 ---------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 30000 | 14M| 1947 (1)| 00:00:01 | |* 1 | TABLE ACCESS FULL| DELUDING_TAB | 30000 | 14M| 1947 (1)| 00:00:01 | ---------------------------------------------------------------------------------- 26
2100行が選択されました。 実行計画 -------------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 2102 | 1077K| 2115 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| DELUDING_TAB2 | 2102 | 1077K| 2115 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | PK_DELUDING_TAB2 | 2102 | | 13 (0)| 00:00:01 | -------------------------------------------------------------------------------------------------------2500行が選択されました。 実行計画 ----------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 2482 | 1272K| 2117 (1)| 00:00:01 | |* 1 | TABLE ACCESS FULL| DELUDING_TAB2 | 2482 | 1272K| 2117 (1)| 00:00:01 | ----------------------------------------------------------------------------------- 27
2100行が選択されました。 実行計画 -------------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 2102 | 1077K| 2115 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| DELUDING_TAB2 | 2102 | 1077K| 2115 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | PK_DELUDING_TAB2 | 2102 | | 13 (0)| 00:00:01 | -------------------------------------------------------------------------------------------------------2500行が選択されました。 実行計画 ----------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 2482 | 1272K| 2117 (1)| 00:00:01 | |* 1 | TABLE ACCESS FULL| DELUDING_TAB2 | 2482 | 1272K| 2117 (1)| 00:00:01 | ----------------------------------------------------------------------------------- 28
INDEX_NAME CLUSTERING_FACTOR NUM_ROWS ------------------------------ ----------------- ---------PK_DELUDING_TAB 7143 100000 PK_DELUDING_TAB2 99990 100000 29
30
31
32
33
34
35
統計 ---------------------------------------------------------0 recursive calls 0 db block gets 107173 consistent gets 統計 ---------------------------------------------------------0 recursive calls 0 db block gets 13911 consistent gets 36
37
🔺 38
39
select * from bad_statistics_tab where status=リテラル値; 40
--------------------------------------------------------| Id | Operation | Name | Rows |-------------------------------------------------------| 0 | SELECT STATEMENT | | 99900 | |* 1 | TABLE ACCESS FULL| BAD_STATISTICS_TAB | 99900 | ---------------------------------------------------------Predicate Information (identified by operation id): --------------------------------------------------1 - filter("STATUS"=0) 41
1 recursive calls 0 db block gets 20159 consistent gets 0 physical reads 0 redo size --------------------------------------------------------2262529 bytes sent via SQL*Net to client | Id | Operation | Name | Rows 73800 bytes received via SQL*Net from client |-------------------------------------------------------6661 SQL*Net roundtrips to/from client | 0 | SELECT STATEMENT | 99900 | 0 sorts (memory)| |* 1 | TABLE ACCESS FULL| BAD_STATISTICS_TAB | 99900 | 0 sorts (disk) ---------------------------------------------------------99900 rows processed Predicate Information (identified by operation id): --------------------------------------------------1 - filter("STATUS"=0) 42
-------------------------------------------------------------------------| Id | Operation | Name | Rows | -------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| BAD_STATISTICS_TAB | 1 | |* 2 | INDEX RANGE SCAN | BAD_INDEX | 1 | -------------------------------------------------------------------------Predicate Information (identified by operation id): --------------------------------------------------2 - access("STATUS"=1) 43
1 recursive calls 0 db block gets 35214 consistent gets 0 physical reads 674340 redo size -------------------------------------------------------------------------103579092 bytes sent via SQL*Net | toName client | Id | Operation | Rows | 73800 bytes received via SQL*Net from client -------------------------------------------------------------------------6661 SQL*Net roundtrips to/from client | 0 | SELECT STATEMENT | | 1 | 0 sorts (memory) | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| BAD_STATISTICS_TAB | 1 | 0 sorts |* 2 | INDEX RANGE SCAN (disk) | BAD_INDEX | 1 | 99900 rows processed -------------------------------------------------------------------------Predicate Information (identified by operation id): --------------------------------------------------2 - access("STATUS"=1) 44
-------------------------------------------------------------------------| Id | Operation | Name | Rows | -------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1 | | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| BAD_STATISTICS_TAB | 1 | |* 2 | INDEX RANGE SCAN | BAD_INDEX | 1 | -------------------------------------------------------------------------Predicate Information (identified by operation id): --------------------------------------------------2 - access("STATUS"=2) 45
1 recursive calls 0 db block gets 35215 consistent gets 0 physical reads 674340 redo size -------------------------------------------------------------------------103579092 bytes sent via SQL*Net to client | Id | Operation | Name | Rows | 73800 bytes received via SQL*Net from client -------------------------------------------------------------------------SQL*Net roundtrips to/from client | 0 | SELECT 6661 STATEMENT | | 1 | 0 sorts (memory) | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| BAD_STATISTICS_TAB | 1 | 0 sorts |* 2 | INDEX RANGE SCAN (disk) | BAD_INDEX | 1 | 99900 rows processed -------------------------------------------------------------------------Predicate Information (identified by operation id): --------------------------------------------------2 - access("STATUS"=2) 46
1 recursive calls 0 db block gets 35215 consistent gets 0 physical reads 674340 redo size -------------------------------------------------------------------------103579092 bytes sent via SQL*Net to client | Id | Operation | Name | Rows | 73800 bytes received via SQL*Net from client -------------------------------------------------------------------------SQL*Net roundtrips to/from client | 0 | SELECT 6661 STATEMENT | | 1 | 0 sorts (memory) | 1 | TABLE ACCESS BY INDEX ROWID BATCHED| BAD_STATISTICS_TAB | 1 | 0 sorts |* 2 | INDEX RANGE SCAN (disk) | BAD_INDEX | 1 | 99900 rows processed -------------------------------------------------------------------------Predicate Information (identified by operation id): --------------------------------------------------2 - access("STATUS"=2) 47
48
🔺 49
🔺 50
51
52
--------------------------------------------------| Id | Operation | Name | Rows | --------------------------------------------------| 0 | SELECT STATEMENT | | 100K| | 1 | TABLE ACCESS FULL| DELUDING_TAB2 | 100K| --------------------------------------------------統計 -------------------------------------------------0 recursive calls 0 db block gets 13905 consistent gets 7742 physical reads 0 redo size 55292936 bytes sent via SQL*Net to client 73878 bytes received via SQL*Net from client 6668 SQL*Net roundtrips to/from client 53
============================================~============================================== | Id | Operation | Name |~| Activity | Activity Detail | | | | |~| (%) | (# samples) | ============================================~============================================== | 0 | SELECT STATEMENT | |~| 20.00 | Cpu (1) | | 1 | TABLE ACCESS FULL | DELUDING_TAB2 |~| 80.00 | Cpu (1) | | | | |~| | SQL*Net message to client (1) | | | | |~| | SQL*Net more data to client (2) | ============================================~============================================== 54
call count ------- -----Parse 1 Execute 1 Fetch 6668 ------- -----total 6670 cpu elapsed disk query current -------- ---------- ---------- ---------- ---------0.00 0.00 0 0 0 0.00 0.00 0 0 0 0.85 0.81 7742 13905 0 -------- ---------- ---------- ---------- ---------0.85 0.81 7742 13905 0 Elapsed times include waiting on following events: Event waited on Times ---------------------------------------Waited SQL*Net message to client 6668 direct path read 130 SQL*Net message from client 6668 55 Max. Wait ---------0.00 0.00 0.01 rows ---------0 0 100000 ---------100000 Total Waited -----------0.14 0.02 8.17
56
統計 -------------------------------------------------0 recursive calls 0 db block gets 13905 consistent gets 7742 physical reads 0 redo size 55292936 bytes sent via SQL*Net to client 73878 bytes received via SQL*Net from client 6668 SQL*Net roundtrips to/from client 0 0 8367 7742 0 54128936 7878 668 recursive calls db block gets consistent gets physical reads redo size bytes sent via SQL*Net to client bytes received via SQL*Net from client SQL*Net roundtrips to/from client 57
============================================~============================================== | Id | Operation | Name |~| Activity | Activity Detail | | | | |~| (%) | (# samples) | ============================================~============================================== | 0 | SELECT STATEMENT | |~| 20.00 | Cpu (1) | | 1 | TABLE ACCESS FULL | DELUDING_TAB2 |~| 80.00 | Cpu (1) | | | | |~| | SQL*Net message to client (1) | | | | |~| | SQL*Net more data to client (2) | ============================================~============================================== ============================================~============================== | Id | Operation | Name |~| Activity | Activity Detail | | | | |~| (%) | (# samples) | ============================================~============================== | 0 | SELECT STATEMENT | |~| | | | 1 | TABLE ACCESS FULL | DELUDING_TAB2 |~| 100.00 | Cpu (2) | ============================================~============================== 58
FETCH #140651855557776:c=0,e=68,p=0,cr=2,cu=0,mis=0,r=15, .... WAIT #140651855557776: nam='SQL*Net message from client' .... WAIT #140651855557776: nam='SQL*Net message to client' .... FETCH #140651855557776:c=0,e=79,p=0,cr=2,cu=0,mis=0,r=15 .... WAIT #140651855557776: nam='SQL*Net message from client'.... WAIT #140651855557776: nam='SQL*Net message to client'.... FETCH #140651855557776:c=0,e=147,p=0,cr=9,cu=0,mis=0,r=15.... WAIT #140651855557776: nam='SQL*Net message from client' .... WAIT #140651855557776: nam='SQL*Net message to client'.... FETCH #140651855557776:c=0,e=101,p=0,cr=9,cu=0,mis=0,r=15,.... ....以下略.... 59
FETCH #140651855557776:c=2000,e=1695,p=64,cr=13,cu=0,mis=0,r=150,... WAIT #140651855557776: nam='SQL*Net message from client'..... WAIT #140651855557776: nam='SQL*Net message to client'..... FETCH #140651855557776:c=0,e=1093,p=0,cr=12,cu=0,mis=0,r=150,... WAIT #140651855557776: nam='SQL*Net message from client'..... WAIT #140651855557776: nam='SQL*Net message to client'..... FETCH #140651855557776:c=0,e=161,p=0,cr=12,cu=0,mis=0,r=150,.... WAIT #140651855557776: nam='SQL*Net message from client'..... WAIT #140651855557776: nam='SQL*Net message to client'..... FETCH #140651855557776:c=18000,e=17507,p=0,cr=13,cu=0,mis=0,r=150,.. ....以下略.... 60
call count ------- -----Parse 1 Execute 1 Fetch 6668 Fetch 668 cpu elapsed disk query current -------- ---------- ---------- ---------- ---------0.00 0.00 0 0 0 0.00 0.00 0 0 0 0.85 0.81 7742 13905 0 0.17 0.17 7742 8367 Elapsed times include waiting on following events: Event waited on Times ---------------------------------------Waited SQL*Net message to client 6668 direct path read 130 SQL*Net message from client 6668 SQL*Net message from client 668 61 0 rows ---------0 0 100000 100000 Max. Wait ---------0.00 0.00 0.01 Total Waited -----------0.14 0.02 8.17 0.03 3.83
62
🔺 63
64
65
http://www.jpoug.org 66 ✌