Let us see if forcing Nested Loop can help now.
SQL Monitoring Report
SQL Text
------------------------------
select /*+ monitor use_nl(t2 t1) */ t1.* ,t2.* from jt1 t1 ,jt2 t2 where t1.id=t2.id
Global Information
------------------------------
Status : EXECUTING
Instance ID : 1
Session : SYS (1:9741)
SQL ID : 742f55pj83rmf
SQL Execution ID : 16777216
Execution Started : 05/14/2023 22:07:52
First Refresh Time : 05/14/2023 22:07:52
Last Refresh Time : 05/14/2023 22:09:49
Duration : 118s
Module/Action : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)/-
Service : opdb1
Program : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)
Fetch Calls : 6
Global Stats
================================================================
| Elapsed | Cpu | IO | Fetch | Buffer | Read | Read |
| Time(s) | Time(s) | Waits(s) | Calls | Gets | Reqs | Bytes |
================================================================
| 134 | 109 | 25 | 6 | 17M | 130K | 126GB |
================================================================
SQL Plan Monitoring Details (Plan Hash Value=3927851833)
===================================================================================================================================================
| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Read | Read | Activity | Activity Detail |
| | | | (Estim) | | Active(s) | Active | | (Actual) | Reqs | Bytes | (%) |(# samples) |
===================================================================================================================================================
| -> 0 | SELECT STATEMENT | | | | 118 | +0 | 1 | 82 | | | | |
| -> 1 | NESTED LOOPS | | 25M | 1T | 118 | +0 | 1 | 82 | | | | |
| -> 2 | TABLE ACCESS FULL | JT1 | 25M | 55303 | 118 | +0 | 1 | 81 | 2 | 224KB | | |
| -> 3 | TABLE ACCESS FULL | JT2 | 1 | 55343 | 119 | +0 | 82 | 82 | 130K | 126GB | 100.00 | Cpu (91) |
| | | | | | | | | | | | | resmgr:cpu quantum (4) |
| | | | | | | | | | | | | direct path read (23) |
===================================================================================================================================================
...
SQL Monitoring Report
SQL Text
------------------------------
select /*+ monitor use_nl(t2 t1) */ t1.* ,t2.* from jt1 t1 ,jt2 t2 where t1.id=t2.id
Global Information
------------------------------
Status : EXECUTING
Instance ID : 1
Session : SYS (1:9741)
SQL ID : 742f55pj83rmf
SQL Execution ID : 16777216
Execution Started : 05/14/2023 22:07:52
First Refresh Time : 05/14/2023 22:07:52
Last Refresh Time : 05/14/2023 22:11:51
Duration : 240s
Module/Action : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)/-
Service : opdb1
Program : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)
Fetch Calls : 13
Global Stats
================================================================
| Elapsed | Cpu | IO | Fetch | Buffer | Read | Read |
| Time(s) | Time(s) | Waits(s) | Calls | Gets | Reqs | Bytes |
================================================================
| 277 | 228 | 49 | 13 | 37M | 290K | 281GB |
================================================================
SQL Plan Monitoring Details (Plan Hash Value=3927851833)
==============================================================================================================================================================
| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Read | Read | Activity | Activity Detail | Progress |
| | | | (Estim) | | Active(s) | Active | | (Actual) | Reqs | Bytes | (%) |(# samples) | |
==============================================================================================================================================================
| -> 0 | SELECT STATEMENT | | | | 240 | +0 | 1 | 182 | | | | | |
| -> 1 | NESTED LOOPS | | 25M | 1T | 240 | +0 | 1 | 182 | | | | | |
| -> 2 | TABLE ACCESS FULL | JT1 | 25M | 55303 | 240 | +0 | 1 | 181 | 2 | 224KB | | | 0% |
| -> 3 | TABLE ACCESS FULL | JT2 | 1 | 55343 | 241 | +0 | 182 | 182 | 290K | 281GB | 100.00 | Cpu (187) | |
| | | | | | | | | | | | | resmgr:cpu quantum (4) | |
| | | | | | | | | | | | | direct path read (49) | |
==============================================================================================================================================================
The fact, this Nested Loop isnt going to finish anytime soon. Look it has read 281GB already and it has feteched only 181 records until now. we need 25M records fetched!
I dont see disk activity neither swap. I guess it cached the tables in memory. # of buffer gets is increasing with each sample.
All the waits are on CPU. For each 60 rows, its doing a buffer read of 20M!!!
Anyway this plan isnt going to break the system, let it run for sometime
SQL Monitoring Report
SQL Text
------------------------------
select /*+ monitor use_nl(t2 t1) */ t1.* ,t2.* from jt1 t1 ,jt2 t2 where t1.id=t2.id
Global Information
------------------------------
Status : EXECUTING
Instance ID : 1
Session : SYS (1:9741)
SQL ID : 742f55pj83rmf
SQL Execution ID : 16777216
Execution Started : 05/14/2023 22:07:52
First Refresh Time : 05/14/2023 22:07:52
Last Refresh Time : 05/14/2023 22:16:32
Duration : 521s
Module/Action : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)/-
Service : opdb1
Program : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)
Fetch Calls : 23
Global Stats
================================================================
| Elapsed | Cpu | IO | Fetch | Buffer | Read | Read |
| Time(s) | Time(s) | Waits(s) | Calls | Gets | Reqs | Bytes |
================================================================
| 548 | 422 | 126 | 23 | 68M | 535K | 518GB |
================================================================
SQL Plan Monitoring Details (Plan Hash Value=3927851833)
===============================================================================================================================================================
| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Read | Read | Activity | Activity Detail | Progress |
| | | | (Estim) | | Active(s) | Active | | (Actual) | Reqs | Bytes | (%) | (# samples) | |
===============================================================================================================================================================
| 0 | SELECT STATEMENT | | | | 521 | +0 | 1 | 336 | | | | | |
| 1 | NESTED LOOPS | | 25M | 1T | 521 | +0 | 1 | 336 | | | | | |
| -> 2 | TABLE ACCESS FULL | JT1 | 25M | 55303 | 523 | +0 | 1 | 335 | 2 | 224KB | | | 0% |
| -> 3 | TABLE ACCESS FULL | JT2 | 1 | 55343 | 523 | +0 | 336 | 336 | 535K | 518GB | 100.00 | Cpu (356) | 100% |
| | | | | | | | | | | | | resmgr:cpu quantum (27) | |
| | | | | | | | | | | | | direct path read (137) | |
===============================================================================================================================================================
It did a bunch of physical IO now. Let us leave it for sometime to see if it makes 1% atleast?
SQL Monitoring Report
SQL Text
------------------------------
select /*+ monitor use_nl(t2 t1) */ t1.* ,t2.* from jt1 t1 ,jt2 t2 where t1.id=t2.id
Global Information
------------------------------
Status : EXECUTING
Instance ID : 1
Session : SYS (1:9741)
SQL ID : 742f55pj83rmf
SQL Execution ID : 16777216
Execution Started : 05/14/2023 22:07:52
First Refresh Time : 05/14/2023 22:07:52
Last Refresh Time : 05/14/2023 22:51:10
Duration : 2598s
Module/Action : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)/-
Service : opdb1
Program : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)
Fetch Calls : 139
Global Stats
==============================================================================
| Elapsed | Cpu | IO | Concurrency | Fetch | Buffer | Read | Read |
| Time(s) | Time(s) | Waits(s) | Waits(s) | Calls | Gets | Reqs | Bytes |
==============================================================================
| 3003 | 2441 | 562 | 0.10 | 139 | 421M | 3M | 3TB |
==============================================================================
SQL Plan Monitoring Details (Plan Hash Value=3927851833)
===============================================================================================================================================================
| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Read | Read | Activity | Activity Detail | Progress |
| | | | (Estim) | | Active(s) | Active | | (Actual) | Reqs | Bytes | (%) | (# samples) | |
===============================================================================================================================================================
| -> 0 | SELECT STATEMENT | | | | 2599 | +0 | 1 | 2078 | | | | | |
| -> 1 | NESTED LOOPS | | 25M | 1T | 2599 | +0 | 1 | 2078 | | | | | |
| -> 2 | TABLE ACCESS FULL | JT1 | 25M | 55303 | 2599 | +0 | 1 | 2077 | 3 | 344KB | | | 0% |
| -> 3 | TABLE ACCESS FULL | JT2 | 1 | 55343 | 2599 | +0 | 2078 | 2078 | 3M | 3TB | 100.00 | Cpu (1986) | 100% |
| | | | | | | | | | | | | resmgr:cpu quantum (35) | |
| | | | | | | | | | | | | direct path read (574) | |
===============================================================================================================================================================
close to 1hr past, not even 1% done.
22:07:08 SQL> select /*+ monitor use_nl(t2 t1) */ t1.*
,t2.*
from jt1 t1
,jt2 t2
where t1.id=t2.id
;22:07:16 2 22:07:16 3 22:07:16 4 22:07:16 5 22:07:16 6
^CERROR:
ORA-01013: user requested cancel of current operation
2100 rows selected.
Elapsed: 00:44:03.95
Statistics
----------------------------------------------------------
6 recursive calls
0 db block gets
428240139 consistent gets
428227443 physical reads
376 redo size
190714 bytes sent via SQL*Net to client
1987 bytes received via SQL*Net from client
141 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2100 rows processed
22:51:56 SQL>
22:55:54 SQL> select * from table(dbms_xplan.display_cursor(format=>'ALLSTATS LAST +cost +bytes'));
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 742f55pj83rmf, child number 0
-------------------------------------
select /*+ monitor use_nl(t2 t1) */ t1.* ,t2.* from jt1 t1 ,jt2 t2
where t1.id=t2.id
Plan hash value: 3927851833
-------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| A-Rows | A-Time | Buffers | Reads |
-------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 1383G(100)| 2115 |00:44:01.33 | 428M| 428M|
| 1 | NESTED LOOPS | | 1 | 25M| 2593M| 1383G (1)| 2115 |00:44:01.33 | 428M| 428M|
| 2 | TABLE ACCESS FULL| JT1 | 1 | 25M| 1287M| 55303 (1)| 2115 |00:00:00.03 | 158 | 43 |
|* 3 | TABLE ACCESS FULL| JT2 | 2115 | 1 | 54 | 55343 (1)| 2115 |00:44:01.30 | 428M| 428M|
-------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter("T1"."ID"="T2"."ID")
21 rows selected.
Elapsed: 00:00:00.76
22:56:03 SQL>
SQL Monitoring Report
SQL Text
------------------------------
select /*+ monitor use_nl(t2 t1) */ t1.* ,t2.* from jt1 t1 ,jt2 t2 where t1.id=t2.id
Error: ORA-1013
------------------------------
ORA-01013: user requested cancel of current operation
Global Information
------------------------------
Status : DONE (ERROR)
Instance ID : 1
Session : SYS (1:9741)
SQL ID : 742f55pj83rmf
SQL Execution ID : 16777216
Execution Started : 05/14/2023 22:07:52
First Refresh Time : 05/14/2023 22:07:52
Last Refresh Time : 05/14/2023 22:51:56
Duration : 2644s
Module/Action : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)/-
Service : opdb1
Program : sqlplus@vcentos79-oracle-sa1 (TNS V1-V3)
Fetch Calls : 142
Global Stats
==============================================================================
| Elapsed | Cpu | IO | Concurrency | Fetch | Buffer | Read | Read |
| Time(s) | Time(s) | Waits(s) | Waits(s) | Calls | Gets | Reqs | Bytes |
==============================================================================
| 3058 | 2487 | 572 | 0.10 | 142 | 428M | 3M | 3TB |
==============================================================================
SQL Plan Monitoring Details (Plan Hash Value=3927851833)
==========================================================================================================================================
| Id | Operation | Name | Rows | Cost | Time | Start | Execs | Rows | Read | Read | Activity | Activity Detail |
| | | | (Estim) | | Active(s) | Active | | (Actual) | Reqs | Bytes | (%) | (# samples) |
==========================================================================================================================================
| 0 | SELECT STATEMENT | | | | 2645 | +0 | 1 | 2115 | | | | |
| 1 | NESTED LOOPS | | 25M | 1T | 2645 | +0 | 1 | 2115 | | | | |
| 2 | TABLE ACCESS FULL | JT1 | 25M | 55303 | 2645 | +0 | 1 | 2114 | 3 | 344KB | | |
| 3 | TABLE ACCESS FULL | JT2 | 1 | 55343 | 2645 | +0 | 2115 | 2115 | 3M | 3TB | | |
==========================================================================================================================================
SQL>