Review
Geraldo Peralta, July 05, 2019 - 6:13 pm UTC
Do I have to wait for the delete statement to finish in order to run "select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'))"?
July 08, 2019 - 3:01 am UTC
Yes.
Review
Geraldo Peralta, July 08, 2019 - 3:19 pm UTC
This is the output meessage:
SQL_ID 2ygnt73ck3jk8, child number 0
begin dbms_utility.expand_sql_text ( input_sql_text => :sql,
output_sql_text => :x ); end;
NOTE: cannot fetch plan for SQL_ID: 2ygnt73ck3jk8, CHILD_NUMBER: 0
Please verify value of SQL_ID and CHILD_NUMBER;
It could also be that the plan is no longer in cursor cache (check v$sql_plan)
Review
Geraldo Peralta, July 09, 2019 - 1:06 pm UTC
I ran the delete statement again.
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID d161mzg4t17v8, child number 0
-------------------------------------
delete /*+ GATHER_PLAN_STATISTICS */ from
efact.detalle_productos_servicios d where d.encabezado_b2b_id in
(select eb.encabezado_b2b_id from
efact.encabezados e,
efact.encabezados_b2b eb where
e.encabezado_id = eb.encabezado_id and
e.rnc_emisor in ( '131880657', '131880606', '131880681', '131880703',
'131880711' ))
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 1491651541
-----------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-----------------------------------------------------------------------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 1 | | 0 |00:27:00.77 | 366M| | | |
| 1 | DELETE | DETALLE_PRODUCTOS_SERVICIOS | 1 | | 0 |00:27:00.77 | 366M| | | |
|* 2 | HASH JOIN RIGHT SEMI | | 1 | 86765 | 85620 |00:00:00.89 | 992 | 2601K| 2601K| 2204K (0)|
| 3 | VIEW | VW_NSO_1 | 1 | 17353 | 17124 |00:00:00.03 | 529 | | | |
|* 4 | HASH JOIN SEMI | | 1 | 17353 | 17124 |00:00:00.03 | 529 | 2213K| 1864K| 2185K (0)|
| 5 | VIEW | index$_join$_003 | 1 | 17353 | 17353 |00:00:00.01 | 156 | | | |
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|* 6 | HASH JOIN | | 1 | | 17353 |00:00:00.01 | 156 | 2227K| 2096K| 2217K (0)|
| 7 | INDEX FAST FULL SCAN| PK_ENCABEZADOS_B2B | 1 | 17353 | 17353 |00:00:00.01 | 78 | | | |
| 8 | INDEX FAST FULL SCAN| IX_FK_ENC_ENCB2B | 1 | 17353 | 17353 |00:00:00.01 | 78 | | | |
|* 9 | TABLE ACCESS FULL | ENCABEZADOS | 1 | 17461 | 17461 |00:00:00.01 | 373 | | | |
| 10 | INDEX FAST FULL SCAN | IX_FK_ENCB2B_DETAPRODSERV | 1 | 86765 | 86765 |00:00:00.27 | 463 | | | |
-----------------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("D"."ENCABEZADO_B2B_ID"="ENCABEZADO_B2B_ID")
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 - access("E"."ENCABEZADO_ID"="EB"."ENCABEZADO_ID")
6 - access(ROWID=ROWID)
9 - filter(("E"."RNC_EMISOR"='131880606' OR "E"."RNC_EMISOR"='131880657' OR "E"."RNC_EMISOR"='131880681' OR
"E"."RNC_EMISOR"='131880703' OR "E"."RNC_EMISOR"='131880711'))
38 rows selected.
July 25, 2019 - 3:08 am UTC
That plan looks fine to me, in that the estimated rows and actual rows are in close alignment.
But - notice how fast it managed to *get* the rows to delete. It was only when the DELETE starting firing that the time got huge. So things to look at:
- are there triggers on the table that are slowing things down?
- are there dozens of indexes on that table?
- is it being blocked by other sessions?
Your plan looks good - now its time to trace the session and see where the time is being lost.
Run dbms_monitor.session_trace_enable(waits=>true)
and run that delete again. THen look at your tkrof formatted file for answers.
Review
Geraldo Peralta, July 25, 2019 - 12:47 pm UTC
Ok.
There are no triggers. There are not dozens of indexes on the table. I have to check blockings.
I will trace the session as you told me.
Thanks for the answer.