Your UNDO
tablespace seems to be the bottleneck in this case.
Check how long it takes to make a ROLLBACK
after you delete the data. If it takes time comparable to the time of the query itself (within 50%
), then this certainly is the case.
When you perform a DML
query, your data (both original and changed) are written into redo logs and then applied to the datafiles and to the UNDO
tablespace.
Deleting millions of CLOB
rows takes copying several hundreds of megabytes, if not gigabytes, to the UNDO
tablespace, which takes tens of seconds itself.
What can you do about this?
- Create a faster
UNDO
: put it onto a separate disk, make it less sparse (create a larger datafile).
- Use
ROLLBACK SEGMENTS
instead of managed UNDO
, assign a ROLLBACK SEGMENT
for this very query and issue SET TRANSACTION USE ROLLBACK SEGMENT
before running the query.
If it's not the case, i. e. ROLLBACK
executes much faster that the query itself, then try to play with you REDO
parameters:
- Increase your
REDO
buffer size using LOG_BUFFER
parameter.
- Increate the size of your logfiles.
- Create your logfiles on separate disks so that reading from a first datafile does not hinder writing to a second an so on.
Note that UNDO
operations also generate REDO
, so it's useful to do all this anyway.
NOLOGGING
adviced before is useless, as it is applied only to certain set of operations listed here, DELETE
not being one of those operations.