Professional Documents
Culture Documents
SQL> @hstats t
Name Null? Type
----------------------------------------- -------- ----------------------------
PKEY NOT NULL NUMBER
STATUS NUMBER
FLAG CHAR(1)
==========================================================================================
Table Statistics
==========================================================================================
TABLE_NAME : T
LAST_ANALYZED : 04-MAR-2005 11:53:17
DEGREE : 1
PARTITIONED : NO
NUM_ROWS : 100000
CHAIN_CNT : 0
BLOCKS : 207
EMPTY_BLOCKS : 48
AVG_SPACE : 934
AVG_ROW_LEN : 13
MONITORING : NO
SAMPLE_SIZE : 100000
-----------------
==========================================================================================
Column Statistics
==========================================================================================
Name Analyzed Null? NDV Density # Nulls # Buckets Sample Avg Col Len
==========================================================================================
PKEY 03/04/2005 NOT NULL 100000 .000010 0 1 100000 4
STATUS 03/04/2005 3 .333333 0 1 100000 2
FLAG 03/04/2005 2 .500000 0 1 100000 1
==========================================================================================
Index Information
==========================================================================================
INDEX_NAME : SYS_C002345
INDEX_TYPE : NORM
LAST_ANALYZED : 04-MAR-2005 11:53:17
DEGREE : 1
PARTITIONED : NO
BLEVEL : 1
LEAF_BLOCKS : 187
DISTINCT_KEYS : 100000
AVG_LEAF_BLOCKS_PER_KEY : 1
AVG_DATA_BLOCKS_PER_KEY : 1
CLUSTERING_FACTOR : 204
BLOCKS_IN_TABLE : 207
ROWS_IN_TABLE : 100000
-----------------
INDEX_NAME : T_N1
INDEX_TYPE : NORM
LAST_ANALYZED : 04-MAR-2005 11:53:17
DEGREE : 1
PARTITIONED : NO
BLEVEL : 1
LEAF_BLOCKS : 238
DISTINCT_KEYS : 3
AVG_LEAF_BLOCKS_PER_KEY : 79
AVG_DATA_BLOCKS_PER_KEY : 68
CLUSTERING_FACTOR : 204
BLOCKS_IN_TABLE : 207
ROWS_IN_TABLE : 100000
-----------------
INDEX_NAME : T_N2
INDEX_TYPE : NORM
LAST_ANALYZED : 04-MAR-2005 11:53:17
DEGREE : 1
PARTITIONED : NO
BLEVEL : 1
LEAF_BLOCKS : 293
DISTINCT_KEYS : 2
AVG_LEAF_BLOCKS_PER_KEY : 146
AVG_DATA_BLOCKS_PER_KEY : 204
CLUSTERING_FACTOR : 408
BLOCKS_IN_TABLE : 207
ROWS_IN_TABLE : 100000
-----------------
INDEX_NAME : T_N3
INDEX_TYPE : NORM
LAST_ANALYZED : 04-MAR-2005 11:53:17
DEGREE : 1
PARTITIONED : NO
BLEVEL : 1
LEAF_BLOCKS : 355
DISTINCT_KEYS : 6
AVG_LEAF_BLOCKS_PER_KEY : 59
AVG_DATA_BLOCKS_PER_KEY : 68
CLUSTERING_FACTOR : 410
BLOCKS_IN_TABLE : 207
ROWS_IN_TABLE : 100000
-----------------
==========================================================================================
Index Columns Information
==========================================================================================
Index Name Pos# Order Column Name Expression
==========================================================================================
SQL>
SQL>
SQL>
SQL> @hstats flags
Name Null? Type
----------------------------------------- -------- ----------------------------
FLAG NOT NULL CHAR(1)
==========================================================================================
Table Statistics
==========================================================================================
TABLE_NAME : FLAGS
LAST_ANALYZED : 04-MAR-2005 10:58:41
DEGREE : 1
PARTITIONED : NO
NUM_ROWS : 5
CHAIN_CNT : 0
BLOCKS :
EMPTY_BLOCKS :
AVG_SPACE :
AVG_ROW_LEN : 4
MONITORING : NO
SAMPLE_SIZE : 5
-----------------
==========================================================================================
Column Statistics
==========================================================================================
Name Analyzed Null? NDV Density # Nulls # Buckets Sample Avg Col Len
==========================================================================================
FLAG 03/04/2005 NOT NULL 5 .200000 0 1 5 1
==========================================================================================
Index Information
==========================================================================================
INDEX_NAME : SYS_IOT_TOP_29235
INDEX_TYPE : IOT
LAST_ANALYZED : 04-MAR-2005 10:58:41
DEGREE : 1
PARTITIONED : NO
BLEVEL : 0
LEAF_BLOCKS : 1
DISTINCT_KEYS : 5
AVG_LEAF_BLOCKS_PER_KEY : 1
AVG_DATA_BLOCKS_PER_KEY : 1
CLUSTERING_FACTOR : 0
BLOCKS_IN_TABLE :
ROWS_IN_TABLE : 5
-----------------
==========================================================================================
Index Columns Information
==========================================================================================
Index Name Pos# Order Column Name Expression
==========================================================================================
SQL> @hix t
Index Flags Height Column Name
------------------------------ ------- ------ ------------------------------
SYS_C002345 U 2 PKEY
T_N1 2 STATUS
T_N2 2 FLAG
T_N3 2 STATUS
. FLAG
SQL>
SQL> @hix flags
Index Flags Height Column Name
------------------------------ ------- ------ ------------------------------
SYS_IOT_TOP_29235 U 1 FLAG
SQL>
SQL> @hcons t
1 update t
2 set flag='B'
3* where status=2
SQL>
SQL>
SQL> @hds
TableOwner[OP] :
TableName : t
ColumnList : flag, status
WhereClause:
PageSize[30] :
COUNT(*)
----------
80000
1 row selected.
SQL>
SQL> select count(*) from t where status = '2' and flag = 'B' ;
COUNT(*)
----------
78400
1 row selected.
SQL>
SQL>
SQL> @dodml
Enter .sql file name (without extension): test
Enter the workspace name: update
Enter the scenario name: problem
Display results of SQL (ON/OFF)?: off
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 99999 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 33333 | 99999 | 22 |
--------------------------------------------------------------------
2 - filter("T"."STATUS"=2)
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=563 r=651 w=0 time=5998399 us)'
STAT #1 id=2 cnt=80000 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=200 w=0 time=480438 us)'
SQL>
SQL>
SQL> @lsscstat
Statistic Name
Statistic Type (S=stat, L=Latch) Value
---------------------------------------- - --------------
active checkpoint queue latch L 10
cache buffer handles L 54
channel operations parent latch L 4
checkpoint queue latch L 6,935
child cursor hash table L 15
Consistent RBA L 66
dml lock allocation L 7
FIB s.o chain latch L 4
FOB s.o list latch L 4
hash table column usage latch L 4
lgwr LWN SCN L 66
library cache pin allocation L 90
list of block allocation L 7
messages L 258
mostly latch-free SCN L 66
multiblock read objects L 48
post/wait queue L 38
redo writing L 216
session allocation L 2
session idle bit L 17
session timer L 2
sim partition latch L 20
simulator hash latch L 5,867
simulator lru latch L 206
SQL memory manager latch L 2
SQL memory manager workarea list latch L 134
transaction allocation L 1
undo global data L 693
active txn count during cleanout S 2
buffer is not pinned count S 244
bytes received via SQL*Net from client S 1,123
bytes sent via SQL*Net to client S 709
calls to get snapshot scn: kcmgss S 340
calls to kcmgas S 542
change write time S 65
cleanout - number of ktugct calls S 150
cluster key scan block gets S 4
buffer pool L 0
cache buffers chains L 480,644
cache buffers lru chain L 6,850
enqueue hash chains L 444
enqueues L 126
library cache L 282
library cache pin L 178
redo allocation L 88,471
redo copy L 88,333
row cache enqueue latch L 204
row cache objects L 219
shared pool L 193
execute count S 18
parse count (hard) S 2
parse count (total) S 18
redo size S 22,887,828
table fetch by rowid S 11
table scan blocks gotten S 207
table scan rows gotten S 100,000
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=563 r=651 w=0 time=5998399 us)'
STAT #1 id=2 cnt=80000 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=200 w=0 time=480438 us)'
SQL>
SQL>
SQL>
SQL> @hopttrace
Enter the workspace name: update
Enter the scenario name: problem
_NEW_INITIAL_JOIN_ORDERS = TRUE
ALWAYS_ANTI_JOIN = CHOOSE
ALWAYS_SEMI_JOIN = CHOOSE
_OPTIMIZER_MODE_FORCE = TRUE
_OPTIMIZER_UNDO_CHANGES = FALSE
_UNNEST_SUBQUERY = TRUE
_PUSH_JOIN_UNION_VIEW = TRUE
_FAST_FULL_SCAN_ENABLED = TRUE
_OPTIM_ENHANCE_NNULL_DETECTION = TRUE
_ORDERED_NESTED_LOOP = TRUE
_NESTED_LOOP_FUDGE = 100
_NO_OR_EXPANSION = FALSE
_QUERY_COST_REWRITE = TRUE
QUERY_REWRITE_EXPRESSION = TRUE
_IMPROVED_ROW_LENGTH_ENABLED = TRUE
_USE_NOSEGMENT_INDEXES = FALSE
_ENABLE_TYPE_DEP_SELECTIVITY = TRUE
_IMPROVED_OUTERJOIN_CARD = TRUE
_OPTIMIZER_ADJUST_FOR_NULLS = TRUE
_OPTIMIZER_CHOOSE_PERMUTATION = 0
_USE_COLUMN_STATS_FOR_FUNCTION = TRUE
_SUBQUERY_PRUNING_ENABLED = TRUE
_SUBQUERY_PRUNING_REDUCTION_FACTOR = 50
_SUBQUERY_PRUNING_COST_FACTOR = 20
_LIKE_WITH_BIND_AS_EQUALITY = FALSE
_TABLE_SCAN_COST_PLUS_ONE = TRUE
_SORTMERGE_INEQUALITY_JOIN_OFF = FALSE
_DEFAULT_NON_EQUALITY_SEL_CHECK = TRUE
_ONESIDE_COLSTAT_FOR_EQUIJOINS = TRUE
_OPTIMIZER_COST_MODEL = CHOOSE
_GSETS_ALWAYS_USE_TEMPTABLES = FALSE
DB_FILE_MULTIBLOCK_READ_COUNT = 16
_NEW_SORT_COST_ESTIMATE = TRUE
_GS_ANTI_SEMI_JOIN_ALLOWED = TRUE
_CPU_TO_IO = 0
_PRED_MOVE_AROUND = TRUE
***************************************
BASE STATISTICAL INFORMATION
***********************
Table stats Table: T Alias: T
TOTAL :: CDN: 100000 NBLKS: 207 AVG_ROW_LEN: 13
-- Index stats
INDEX NAME: SYS_C002345 COL#: 1
TOTAL :: LVLS: 1 #LB: 187 #DK: 100000 LB/K: 1 DB/K: 1 CLUF: 204
INDEX NAME: T_N1 COL#: 2
TOTAL :: LVLS: 1 #LB: 238 #DK: 3 LB/K: 79 DB/K: 68 CLUF: 204
INDEX NAME: T_N2 COL#: 3
TOTAL :: LVLS: 1 #LB: 225 #DK: 2 LB/K: 112 DB/K: 204 CLUF: 408
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> @horatrace
Enter the workspace name: update
Enter the scenario name: problem
Review tkprof output? (Y/N): Y
Your trace file (hotsos_ora_3364.trc) has been spooled to your default directory.
SQL>
SQL>
SQL>
SQL>
SQL> get test_ans1
1 update t
2 set flag='B'
3 where status=2
4* and flag != 'B'
SQL>
SQL>
SQL> @dodml
Enter .sql file name (without extension): test_ans1
Enter the workspace name: update
Enter the scenario name: answer1
Display results of SQL (ON/OFF)?: off
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 16667 | 50001 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 16667 | 50001 | 22 |
--------------------------------------------------------------------
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=717 w=0 time=2217354 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=205 w=0 time=277281 us)'
SQL>
SQL>
SQL> @lsscstat
Workspace [UPDATE]:
Statistic Name
Statistic Type (S=stat, L=Latch) Value
---------------------------------------- - --------------
active checkpoint queue latch L 4
channel operations parent latch L 2
checkpoint queue latch L 2,357
child cursor hash table L 15
Consistent RBA L 5
dml lock allocation L 3
hash table column usage latch L 6
buffer pool L 0
execute count S 6
parse count (hard) S 2
parse count (total) S 6
redo size S 1,633,416
table fetch by rowid S 1
table scan blocks gotten S 207
table scan rows gotten S 100,000
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=717 w=0 time=2217354 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=205 w=0 time=277281 us)'
SQL>
SQL>
SQL>
SQL> @diff
buffer pool L 0 0 0
cache buffers chains L 480,644 65,004 -415,640
cache buffers lru chain L 6,850 2,507 -4,343
enqueue hash chains L 444 16 -428
enqueues L 126 11 -115
library cache L 282 150 -132
library cache pin L 178 82 -96
redo allocation L 88,471 8,038 -80,433
redo copy L 88,333 8,028 -80,305
row cache enqueue latch L 204 58 -146
row cache objects L 219 61 -158
shared pool L 193 136 -57
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=563 r=651 w=0 time=5998399 us)'
STAT #1 id=2 cnt=80000 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=200 w=0 time=480438 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=717 w=0 time=2217354 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=205 w=0 time=277281 us)'
==========================================================================
UPDATE:PROBLEM
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 99999 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 33333 | 99999 | 22 |
--------------------------------------------------------------------
2 - filter("T"."STATUS"=2)
==========================================================================
UPDATE:ANSWER1
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 16667 | 50001 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 16667 | 50001 | 22 |
--------------------------------------------------------------------
SQL>
SQL> get test_ans2
1 update t
2 set flag='B'
3 where status=2
4* and flag in (select flag from flags minus select 'B' from dual )
SQL>
SQL>
SQL> @dodml
Enter .sql file name (without extension): test_ans2
Enter the workspace name: update
Enter the scenario name: answer2
Display results of SQL (ON/OFF)?: off
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 83333 | 488K| 26 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 83333 | 488K| 26 |
| 3 | VIEW | VW_NSO_1 | 5 | 15 | 25 |
| 4 | MINUS | | | | |
| 5 | SORT UNIQUE | | 5 | 5 | |
| 6 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 5 | 5 | 1 |
| 7 | TABLE ACCESS FULL| DUAL | 8168 | | 11 |
|* 8 | INDEX RANGE SCAN | T_N3 | 16667 | 50001 | |
----------------------------------------------------------------------------
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=494 w=0 time=1203620 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=3 w=0 time=40684 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=15222 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=15205 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=15077 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=14973 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=84 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=2 w=0 time=18340 us)'
SQL>
SQL>
SQL> @lsscstat
Workspace [UPDATE]:
Statistic Name
Statistic Type (S=stat, L=Latch) Value
---------------------------------------- - --------------
active checkpoint queue latch L 4
channel operations parent latch L 2
checkpoint queue latch L 1,641
child cursor hash table L 15
Consistent RBA L 4
dml lock allocation L 3
hash table column usage latch L 10
lgwr LWN SCN L 4
library cache load lock L 2
library cache pin allocation L 58
list of block allocation L 6
messages L 25
mostly latch-free SCN L 4
post/wait queue L 2
redo writing L 18
session allocation L 2
session idle bit L 17
session timer L 1
sim partition latch L 1
simulator hash latch L 258
simulator lru latch L 62
SQL memory manager latch L 1
SQL memory manager workarea list latch L 71
undo global data L 6
buffer is not pinned count S 2
bytes received via SQL*Net from client S 1,191
bytes sent via SQL*Net to client S 709
calls to get snapshot scn: kcmgss S 8
calls to kcmgas S 4
consistent gets - examination S 1
CPU used by this session S 11
CPU used when call started S 11
cursor authentications S 1
db block changes S 4,421
dirty buffers inspected S 538
enqueue releases S 2
enqueue requests S 4
free buffer inspected S 541
free buffer requested S 537
hot buffers moved to head of LRU S 222
index scans kdiixs1 S 9
messages sent S 4
no work - consistent read gets S 7
opened cursors cumulative S 7
parse time cpu S 2
buffer pool L 0
cache buffers chains L 16,101
cache buffers lru chain L 1,434
enqueue hash chains L 12
enqueues L 7
library cache L 208
library cache pin L 100
redo allocation L 2,217
redo copy L 2,209
row cache enqueue latch L 120
row cache objects L 123
shared pool L 180
execute count S 7
parse count (hard) S 2
parse count (total) S 7
redo size S 638,912
table fetch by rowid S 0
table scan blocks gotten S 1
table scan rows gotten S 1
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=494 w=0 time=1203620 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=3 w=0 time=40684 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=15222 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=15205 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=15077 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=14973 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=84 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=2 w=0 time=18340 us)'
SQL>
SQL>
SQL>
SQL> @hrank update
Scenario ranking for workspace update by elapsed time
SQL>
SQL> @diff
buffer pool L 0 0 0
cache buffers chains L 480,644 16,101 -464,543
cache buffers lru chain L 6,850 1,434 -5,416
enqueue hash chains L 444 12 -432
enqueues L 126 7 -119
library cache L 282 208 -74
library cache pin L 178 100 -78
redo allocation L 88,471 2,217 -86,254
redo copy L 88,333 2,209 -86,124
row cache enqueue latch L 204 120 -84
row cache objects L 219 123 -96
shared pool L 193 180 -13
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=563 r=651 w=0 time=5998399 us)'
STAT #1 id=2 cnt=80000 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=200 w=0 time=480438 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=494 w=0 time=1203620 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=3 w=0 time=40684 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=15222 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=15205 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=15077 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=14973 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=84 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=2 w=0 time=18340 us)'
==========================================================================
UPDATE:PROBLEM
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 99999 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 33333 | 99999 | 22 |
--------------------------------------------------------------------
2 - filter("T"."STATUS"=2)
==========================================================================
UPDATE:ANSWER2
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 83333 | 488K| 26 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 83333 | 488K| 26 |
| 3 | VIEW | VW_NSO_1 | 5 | 15 | 25 |
| 4 | MINUS | | | | |
| 5 | SORT UNIQUE | | 5 | 5 | |
| 6 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 5 | 5 | 1 |
| 7 | TABLE ACCESS FULL| DUAL | 8168 | | 11 |
|* 8 | INDEX RANGE SCAN | T_N3 | 16667 | 50001 | |
----------------------------------------------------------------------------
SQL>
SQL> @diff
messages sent S 6 4 -2
no work - consistent read gets S 209 7 -202
opened cursors cumulative S 6 7 1
parse time cpu S 0 2 2
parse time elapsed S 0 13 13
pinned buffers inspected S 36 3 -33
prefetched blocks S 181 0 -181
prefetched blocks aged out before use S 25 0 -25
recursive calls S 8 5 -3
recursive cpu usage S 0 2 2
redo entries S 8,011 2,189 -5,822
session pga memory S 189,544 0 -189,544
shared hash latch upgrades - no wait S 1 10 9
switch current to new buffer S 166 0 -166
table scans (long tables) S 1 0 -1
table scans (short tables) S 0 1 1
workarea executions - optimal S 0 5 5
write clones created in foreground S 12 4 -8
buffer pool L 0 0 0
cache buffers chains L 65,004 16,101 -48,903
cache buffers lru chain L 2,507 1,434 -1,073
enqueue hash chains L 16 12 -4
enqueues L 11 7 -4
library cache L 150 208 58
library cache pin L 82 100 18
redo allocation L 8,038 2,217 -5,821
redo copy L 8,028 2,209 -5,819
row cache enqueue latch L 58 120 62
row cache objects L 61 123 62
shared pool L 136 180 44
execute count S 6 7 1
parse count (hard) S 2 2 0
parse count (total) S 6 7 1
redo size S 1,633,416 638,912 -994,504
table fetch by rowid S 1 0 -1
table scan blocks gotten S 207 1 -206
table scan rows gotten S 100,000 1 -99,999
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=717 w=0 time=2217354 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=205 w=0 time=277281 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=494 w=0 time=1203620 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=3 w=0 time=40684 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=15222 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=15205 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=15077 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=14973 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=84 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=2 w=0 time=18340 us)'
==========================================================================
UPDATE:ANSWER1
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 16667 | 50001 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 16667 | 50001 | 22 |
--------------------------------------------------------------------
==========================================================================
UPDATE:ANSWER2
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 83333 | 488K| 26 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 83333 | 488K| 26 |
| 3 | VIEW | VW_NSO_1 | 5 | 15 | 25 |
| 4 | MINUS | | | | |
| 5 | SORT UNIQUE | | 5 | 5 | |
| 6 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 5 | 5 | 1 |
| 7 | TABLE ACCESS FULL| DUAL | 8168 | | 11 |
|* 8 | INDEX RANGE SCAN | T_N3 | 16667 | 50001 | |
----------------------------------------------------------------------------
SQL>
SQL>
SQL> get test_ans3
1 update t
2 set flag='B'
3 where status=2
4* and flag in (select flag from flags where flag != 'B')
SQL>
SQL>
SQL> @dodml
Enter .sql file name (without extension): test_ans3
Enter the workspace name: update
Enter the scenario name: answer3
Display results of SQL (ON/OFF)?: off
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 130K| 2 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 33333 | 130K| 2 |
|* 3 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 4 | 4 | 1 |
|* 4 | INDEX RANGE SCAN | T_N3 | 8333 | 24999 | |
---------------------------------------------------------------------------
3 - filter("FLAGS"."FLAG"<>'B')
4 - access("T"."STATUS"=2 AND "T"."FLAG"="FLAGS"."FLAG")
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=212 w=0 time=666891 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=29875 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13743 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11135 us)'
SQL>
SQL>
SQL> @lsscstat
Workspace [UPDATE]:
Statistic Name
Statistic Type (S=stat, L=Latch) Value
---------------------------------------- - --------------
active checkpoint queue latch L 4
checkpoint queue latch L 910
child cursor hash table L 14
Consistent RBA L 3
dml lock allocation L 3
hash table column usage latch L 15
lgwr LWN SCN L 3
library cache pin allocation L 42
list of block allocation L 6
messages L 22
mostly latch-free SCN L 3
redo writing L 13
session idle bit L 16
simulator hash latch L 203
simulator lru latch L 29
SQL memory manager workarea list latch L 4
undo global data L 6
buffer is not pinned count S 1
bytes received via SQL*Net from client S 1,181
bytes sent via SQL*Net to client S 709
calls to get snapshot scn: kcmgss S 3
calls to kcmgas S 1
consistent gets - examination S 1
CPU used by this session S 12
CPU used when call started S 12
db block changes S 4,421
dirty buffers inspected S 2
enqueue releases S 2
enqueue requests S 4
free buffer inspected S 2
free buffer requested S 247
hot buffers moved to head of LRU S 303
index scans kdiixs1 S 5
messages sent S 3
no work - consistent read gets S 6
opened cursors cumulative S 5
redo entries S 2,189
shared hash latch upgrades - no wait S 6
SQL*Net roundtrips to/from client S 5
user calls S 8
workarea executions - optimal S 4
write clones created in foreground S 1
buffer pool L 0
cache buffers chains L 13,914
cache buffers lru chain L 504
enqueue hash chains L 10
enqueues L 4
library cache L 156
library cache pin L 78
redo allocation L 2,212
redo copy L 2,206
row cache enqueue latch L 74
row cache objects L 77
shared pool L 152
execute count S 5
parse count (hard) S 2
parse count (total) S 5
redo size S 638,912
table fetch by rowid S 0
table scan blocks gotten S 0
table scan rows gotten S 0
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=212 w=0 time=666891 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=29875 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13743 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11135 us)'
SQL>
SQL>
SQL>
SQL> @hrank update
SQL> @diff
buffer pool L 0 0 0
cache buffers chains L 480,644 13,914 -466,730
cache buffers lru chain L 6,850 504 -6,346
enqueue hash chains L 444 10 -434
enqueues L 126 4 -122
library cache L 282 156 -126
library cache pin L 178 78 -100
redo allocation L 88,471 2,212 -86,259
redo copy L 88,333 2,206 -86,127
row cache enqueue latch L 204 74 -130
row cache objects L 219 77 -142
shared pool L 193 152 -41
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=563 r=651 w=0 time=5998399 us)'
STAT #1 id=2 cnt=80000 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=200 w=0 time=480438 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=212 w=0 time=666891 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=29875 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13743 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11135 us)'
==========================================================================
UPDATE:PROBLEM
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 99999 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 33333 | 99999 | 22 |
--------------------------------------------------------------------
2 - filter("T"."STATUS"=2)
==========================================================================
UPDATE:ANSWER3
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 130K| 2 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 33333 | 130K| 2 |
|* 3 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 4 | 4 | 1 |
|* 4 | INDEX RANGE SCAN | T_N3 | 8333 | 24999 | |
---------------------------------------------------------------------------
3 - filter("FLAGS"."FLAG"<>'B')
4 - access("T"."STATUS"=2 AND "T"."FLAG"="FLAGS"."FLAG")
SQL>
SQL>
SQL> @diff
ANSWER2
ANSWER3
PROBLEM
recursive calls S 5 0 -5
recursive cpu usage S 2 0 -2
shared hash latch upgrades - no wait S 10 6 -4
table scans (short tables) S 1 0 -1
workarea executions - optimal S 5 4 -1
write clones created in foreground S 4 1 -3
buffer pool L 0 0 0
cache buffers chains L 16,101 13,914 -2,187
cache buffers lru chain L 1,434 504 -930
enqueue hash chains L 12 10 -2
enqueues L 7 4 -3
library cache L 208 156 -52
library cache pin L 100 78 -22
redo allocation L 2,217 2,212 -5
redo copy L 2,209 2,206 -3
row cache enqueue latch L 120 74 -46
row cache objects L 123 77 -46
shared pool L 180 152 -28
execute count S 7 5 -2
parse count (hard) S 2 2 0
parse count (total) S 7 5 -2
redo size S 638,912 638,912 0
table fetch by rowid S 0 0 0
table scan blocks gotten S 1 0 -1
table scan rows gotten S 1 0 -1
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=494 w=0 time=1203620 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=3 w=0 time=40684 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=15222 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=15205 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=15077 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=14973 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=84 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=2 w=0 time=18340 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=212 w=0 time=666891 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=29875 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13743 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11135 us)'
==========================================================================
UPDATE:ANSWER2
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 83333 | 488K| 26 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 83333 | 488K| 26 |
| 3 | VIEW | VW_NSO_1 | 5 | 15 | 25 |
| 4 | MINUS | | | | |
| 5 | SORT UNIQUE | | 5 | 5 | |
==========================================================================
UPDATE:ANSWER3
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 130K| 2 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 33333 | 130K| 2 |
|* 3 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 4 | 4 | 1 |
|* 4 | INDEX RANGE SCAN | T_N3 | 8333 | 24999 | |
---------------------------------------------------------------------------
3 - filter("FLAGS"."FLAG"<>'B')
4 - access("T"."STATUS"=2 AND "T"."FLAG"="FLAGS"."FLAG")
SQL>
SQL>
SQL> analyze table t compute statistics for columns status ;
Table analyzed.
SQL>
SQL>
SQL> get test_ans1
1 update t
2 set flag='B'
3 where status=2
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 40000 | 117K| 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 40000 | 117K| 22 |
--------------------------------------------------------------------
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=364 w=0 time=1577867 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=4 w=0 time=72003 us)'
SQL>
SQL>
SQL> @lsscstat
Workspace [UPDATE]:
Statistic Name
Statistic Type (S=stat, L=Latch) Value
---------------------------------------- - --------------
active checkpoint queue latch L 4
channel operations parent latch L 2
checkpoint queue latch L 2,101
child cursor hash table L 15
Consistent RBA L 7
dml lock allocation L 3
hash table column usage latch L 6
lgwr LWN SCN L 7
library cache pin allocation L 42
list of block allocation L 5
messages L 39
mostly latch-free SCN L 7
multiblock read objects L 2
post/wait queue L 4
redo writing L 28
session allocation L 2
session idle bit L 17
session timer L 1
sim partition latch L 1
simulator hash latch L 356
simulator lru latch L 58
SQL memory manager latch L 1
SQL memory manager workarea list latch L 67
undo global data L 11
buffer is not pinned count S 210
bytes received via SQL*Net from client S 1,142
bytes sent via SQL*Net to client S 709
calls to get snapshot scn: kcmgss S 9
calls to kcmgas S 209
change write time S 5
CPU used by this session S 23
CPU used when call started S 23
buffer pool L 0
cache buffers chains L 64,161
cache buffers lru chain L 1,957
enqueue hash chains L 20
enqueues L 15
library cache L 150
library cache pin L 82
redo allocation L 8,043
redo copy L 8,029
row cache enqueue latch L 58
row cache objects L 62
shared pool L 130
execute count S 6
parse count (hard) S 2
parse count (total) S 6
redo size S 1,633,476
table fetch by rowid S 1
table scan blocks gotten S 207
table scan rows gotten S 100,000
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=364 w=0 time=1577867 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=4 w=0 time=72003 us)'
SQL>
SQL>
SQL>
SQL> get test_ans2
1 update t
2 set flag='B'
3 where status=2
4* and flag in (select flag from flags minus select 'B' from dual )
SQL>
SQL> @dodml
Enter .sql file name (without extension): test_ans2
Enter the workspace name: update
Enter the scenario name: answer2_hist
Display results of SQL (ON/OFF)?: off
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 200K| 1171K| 26 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 200K| 1171K| 26 |
| 3 | VIEW | VW_NSO_1 | 5 | 15 | 25 |
| 4 | MINUS | | | | |
| 5 | SORT UNIQUE | | 5 | 5 | |
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=411 w=0 time=1185803 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=2 w=0 time=30175 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=13335 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=13318 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=13199 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13100 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=76 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11444 us)'
SQL>
SQL>
SQL> @lsscstat
Workspace [UPDATE]:
Statistic Name
Statistic Type (S=stat, L=Latch) Value
---------------------------------------- - --------------
active checkpoint queue latch L 2
checkpoint queue latch L 1,113
child cursor hash table L 15
Consistent RBA L 4
dml lock allocation L 3
hash table column usage latch L 10
lgwr LWN SCN L 4
library cache pin allocation L 46
list of block allocation L 6
messages L 17
mostly latch-free SCN L 4
redo writing L 14
session idle bit L 16
simulator hash latch L 206
simulator lru latch L 54
SQL memory manager workarea list latch L 4
undo global data L 7
buffer is not pinned count S 2
bytes received via SQL*Net from client S 1,191
bytes sent via SQL*Net to client S 709
calls to get snapshot scn: kcmgss S 6
calls to kcmgas S 1
consistent gets - examination S 1
CPU used by this session S 20
CPU used when call started S 20
db block changes S 4,421
dirty buffers inspected S 292
enqueue releases S 2
enqueue requests S 4
free buffer inspected S 296
free buffer requested S 446
hot buffers moved to head of LRU S 219
index scans kdiixs1 S 5
messages sent S 2
no work - consistent read gets S 7
opened cursors cumulative S 5
parse time cpu S 2
parse time elapsed S 2
pinned buffers inspected S 3
redo entries S 2,189
session pga memory max S 131,072
shared hash latch upgrades - no wait S 6
SQL*Net roundtrips to/from client S 5
table scans (short tables) S 1
user calls S 8
workarea executions - optimal S 5
write clones created in foreground S 1
buffer pool L 0
cache buffers chains L 14,833
cache buffers lru chain L 972
enqueue hash chains L 10
enqueues L 4
library cache L 173
library cache pin L 82
redo allocation L 2,215
redo copy L 2,207
row cache enqueue latch L 100
row cache objects L 104
shared pool L 152
execute count S 5
parse count (hard) S 2
parse count (total) S 5
redo size S 638,912
table fetch by rowid S 0
table scan blocks gotten S 1
table scan rows gotten S 1
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=411 w=0 time=1185803 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=2 w=0 time=30175 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=13335 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=13318 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=13199 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13100 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=76 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11444 us)'
SQL>
SQL>
SQL>
SQL> get test_ans3
1 update t
2 set flag='B'
3 where status=2
4* and flag in (select flag from flags where flag != 'B')
SQL>
SQL> @dodml
Enter .sql file name (without extension): test_ans3
Enter the workspace name: update
Enter the scenario name: answer3_hist
Display results of SQL (ON/OFF)?: off
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 80000 | 312K| 2 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 80000 | 312K| 2 |
|* 3 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 4 | 4 | 1 |
|* 4 | INDEX RANGE SCAN | T_N3 | 20000 | 60000 | |
---------------------------------------------------------------------------
3 - filter("FLAGS"."FLAG"<>'B')
4 - access("T"."STATUS"=2 AND "T"."FLAG"="FLAGS"."FLAG")
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=174 w=0 time=565098 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=25717 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=9258 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11507 us)'
SQL>
SQL>
SQL> @lsscstat
Workspace [UPDATE]:
Statistic Name
Statistic Type (S=stat, L=Latch) Value
---------------------------------------- - --------------
active checkpoint queue latch L 2
checkpoint queue latch L 694
child cursor hash table L 15
Consistent RBA L 4
dml lock allocation L 3
hash table column usage latch L 15
lgwr LWN SCN L 4
library cache pin allocation L 40
list of block allocation L 8
messages L 19
mostly latch-free SCN L 4
redo writing L 14
session idle bit L 16
simulator hash latch L 177
simulator lru latch L 24
SQL memory manager workarea list latch L 4
transaction allocation L 2
undo global data L 17
buffer is not pinned count S 1
bytes received via SQL*Net from client S 1,181
bytes sent via SQL*Net to client S 709
calls to get snapshot scn: kcmgss S 3
change write time S 1
consistent gets - examination S 1
CPU used by this session S 14
CPU used when call started S 14
db block changes S 4,421
dirty buffers inspected S 212
enqueue releases S 2
enqueue requests S 4
free buffer inspected S 216
free buffer requested S 208
hot buffers moved to head of LRU S 441
index scans kdiixs1 S 5
messages sent S 2
no work - consistent read gets S 6
opened cursors cumulative S 5
parse time cpu S 1
parse time elapsed S 2
pinned buffers inspected S 4
redo entries S 2,189
session pga memory max S 65,536
shared hash latch upgrades - no wait S 6
SQL*Net roundtrips to/from client S 5
user calls S 8
workarea executions - optimal S 4
buffer pool L 0
cache buffers chains L 14,332
cache buffers lru chain L 636
enqueue hash chains L 16
enqueues L 4
library cache L 151
library cache pin L 76
redo allocation L 2,238
redo copy L 2,230
row cache enqueue latch L 74
row cache objects L 78
shared pool L 140
execute count S 5
parse count (hard) S 2
parse count (total) S 5
redo size S 638,912
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=174 w=0 time=565098 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=25717 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=9258 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11507 us)'
SQL>
SQL>
SQL>
SQL> @hrank update
SQL>
SQL>
SQL> @diff
UPDATE
redo writing L 21 28 7
session timer L 0 1 1
sim partition latch L 2 1 -1
simulator hash latch L 464 356 -108
simulator lru latch L 91 58 -33
undo global data L 10 11 1
calls to kcmgas S 178 209 31
change write time S 0 5 5
CPU used by this session S 33 23 -10
CPU used when call started S 33 23 -10
db block changes S 16,111 16,112 1
dirty buffers inspected S 835 824 -11
free buffer inspected S 898 985 87
free buffer requested S 981 658 -323
hot buffers moved to head of LRU S 365 65 -300
messages sent S 6 5 -1
parse time cpu S 0 1 1
parse time elapsed S 0 1 1
pinned buffers inspected S 36 9 -27
prefetched blocks S 181 2 -179
prefetched blocks aged out before use S 25 0 -25
session pga memory S 189,544 0 -189,544
switch current to new buffer S 166 153 -13
write clones created in foreground S 12 56 44
buffer pool L 0 0 0
cache buffers chains L 65,004 64,161 -843
cache buffers lru chain L 2,507 1,957 -550
enqueue hash chains L 16 20 4
enqueues L 11 15 4
library cache L 150 150 0
library cache pin L 82 82 0
redo allocation L 8,038 8,043 5
redo copy L 8,028 8,029 1
row cache enqueue latch L 58 58 0
row cache objects L 61 62 1
shared pool L 136 130 -6
execute count S 6 6 0
parse count (hard) S 2 2 0
parse count (total) S 6 6 0
redo size S 1,633,416 1,633,476 60
table fetch by rowid S 1 1 0
table scan blocks gotten S 207 207 0
table scan rows gotten S 100,000 100,000 0
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=717 w=0 time=2217354 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=205 w=0 time=277281 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=215 r=364 w=0 time=1577867 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=29237 op='TABLE ACCESS FULL T (cr=211 r=4 w=0 time=72003 us)'
==========================================================================
UPDATE:ANSWER1
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 16667 | 50001 | 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 16667 | 50001 | 22 |
--------------------------------------------------------------------
==========================================================================
UPDATE:ANSWER1_HIST
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 40000 | 117K| 22 |
| 1 | UPDATE | T | | | |
|* 2 | TABLE ACCESS FULL | T | 40000 | 117K| 22 |
--------------------------------------------------------------------
SQL>
SQL>
SQL> @diff
ANSWER1
ANSWER1_HIST
ANSWER2
ANSWER2_HIST
ANSWER3
ANSWER3_HIST
PROBLEM
buffer pool L 0 0 0
cache buffers chains L 16,101 14,833 -1,268
cache buffers lru chain L 1,434 972 -462
enqueue hash chains L 12 10 -2
enqueues L 7 4 -3
library cache L 208 173 -35
library cache pin L 100 82 -18
redo allocation L 2,217 2,215 -2
redo copy L 2,209 2,207 -2
row cache enqueue latch L 120 100 -20
row cache objects L 123 104 -19
shared pool L 180 152 -28
execute count S 7 5 -2
parse count (hard) S 2 2 0
parse count (total) S 7 5 -2
redo size S 638,912 638,912 0
table fetch by rowid S 0 0 0
table scan blocks gotten S 1 1 0
table scan rows gotten S 1 1 0
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=494 w=0 time=1203620 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=3 w=0 time=40684 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=15222 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=15205 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=15077 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=14973 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=84 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=2 w=0 time=18340 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=15 r=411 w=0 time=1185803 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=15 r=2 w=0 time=30175 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=0 op='VIEW (cr=4 r=1 w=0 time=13335 us)'
STAT #1 id=4 cnt=4 pid=3 pos=1 obj=0 op='MINUS (cr=4 r=1 w=0 time=13318 us)'
STAT #1 id=5 cnt=5 pid=4 pos=1 obj=0 op='SORT UNIQUE (cr=1 r=1 w=0 time=13199 us)'
STAT #1 id=6 cnt=5 pid=5 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13100 us)'
STAT #1 id=7 cnt=1 pid=4 pos=2 obj=222 op='TABLE ACCESS FULL DUAL (cr=3 r=0 w=0 time=76 us)'
STAT #1 id=8 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11444 us)'
------------------------------------------------------------
YES
NO
==========================================================================
UPDATE:ANSWER2
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 83333 | 488K| 26 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 83333 | 488K| 26 |
| 3 | VIEW | VW_NSO_1 | 5 | 15 | 25 |
| 4 | MINUS | | | | |
| 5 | SORT UNIQUE | | 5 | 5 | |
| 6 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 5 | 5 | 1 |
| 7 | TABLE ACCESS FULL| DUAL | 8168 | | 11 |
|* 8 | INDEX RANGE SCAN | T_N3 | 16667 | 50001 | |
----------------------------------------------------------------------------
==========================================================================
UPDATE:ANSWER2_HIST
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 200K| 1171K| 26 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 200K| 1171K| 26 |
| 3 | VIEW | VW_NSO_1 | 5 | 15 | 25 |
| 4 | MINUS | | | | |
| 5 | SORT UNIQUE | | 5 | 5 | |
| 6 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 5 | 5 | 1 |
| 7 | TABLE ACCESS FULL| DUAL | 8168 | | 11 |
|* 8 | INDEX RANGE SCAN | T_N3 | 40000 | 117K| |
----------------------------------------------------------------------------
SQL>
SQL> @diff
buffer pool L 0 0 0
cache buffers chains L 13,914 14,332 418
cache buffers lru chain L 504 636 132
enqueue hash chains L 10 16 6
enqueues L 4 4 0
library cache L 156 151 -5
library cache pin L 78 76 -2
redo allocation L 2,212 2,238 26
redo copy L 2,206 2,230 24
row cache enqueue latch L 74 74 0
row cache objects L 77 78 1
shared pool L 152 140 -12
execute count S 5 5 0
parse count (hard) S 2 2 0
parse count (total) S 5 5 0
redo size S 638,912 638,912 0
table fetch by rowid S 0 0 0
table scan blocks gotten S 0 0 0
table scan rows gotten S 0 0 0
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=212 w=0 time=666891 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=29875 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=13743 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11135 us)'
STAT #1 id=1 cnt=0 pid=0 pos=1 obj=0 op='UPDATE (cr=12 r=174 w=0 time=565098 us)'
STAT #1 id=2 cnt=1600 pid=1 pos=1 obj=0 op='NESTED LOOPS (cr=12 r=2 w=0 time=25717 us)'
STAT #1 id=3 cnt=4 pid=2 pos=1 obj=29236 op='INDEX FULL SCAN SYS_IOT_TOP_29235 (cr=1 r=1 w=0 time=9258 us)'
STAT #1 id=4 cnt=1600 pid=2 pos=2 obj=29241 op='INDEX RANGE SCAN T_N3 (cr=11 r=1 w=0 time=11507 us)'
==========================================================================
UPDATE:ANSWER3
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 33333 | 130K| 2 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 33333 | 130K| 2 |
|* 3 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 4 | 4 | 1 |
|* 4 | INDEX RANGE SCAN | T_N3 | 8333 | 24999 | |
---------------------------------------------------------------------------
3 - filter("FLAGS"."FLAG"<>'B')
4 - access("T"."STATUS"=2 AND "T"."FLAG"="FLAGS"."FLAG")
==========================================================================
UPDATE:ANSWER3_HIST
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | UPDATE STATEMENT | | 80000 | 312K| 2 |
| 1 | UPDATE | T | | | |
| 2 | NESTED LOOPS | | 80000 | 312K| 2 |
|* 3 | INDEX FULL SCAN | SYS_IOT_TOP_29235 | 4 | 4 | 1 |
|* 4 | INDEX RANGE SCAN | T_N3 | 20000 | 60000 | |
---------------------------------------------------------------------------
3 - filter("FLAGS"."FLAG"<>'B')
4 - access("T"."STATUS"=2 AND "T"."FLAG"="FLAGS"."FLAG")
SQL>