Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The key to understand your problem is to understand how statements are executed. DELETE is a relatively expensive operation and often leads to performance problems. So here is how Oracle executes a DML statement:</p> <ol> <li>The first step in executing DML is to find the required blocks in the database buffer cache (if they are already there) or copy them into the buffer cache from the datafiles (slow). In addition to that, an empty block of an undo segment is also copied into the buffer cache.</li> <li>Then, locks are placed on the affected rows and indices.</li> <li>After that, redo is generated: Change vectors describing all the changes done to the data block and undo block are generated. For a DELETE, the change vector to be written to the undo block is the entire row.</li> <li>Then, the DELETE is carried out. The whole row is copied from the data block to the undo block and the row in the data block is deleted. DELETE generates much more undo data than an INSERT for example, because the contents of the whole row are copied (so other sessions can read the original data or the deletion can be rolled back).</li> </ol> <p>Your query almost certainly runs faster the second time <strong>because all the relevant blocks are already in the database buffer cache</strong>. Of course, the more blocks can be held in the database buffer cache, the less I/O is needed. <strong>Make sure your SGA is sized appropriately.</strong></p> <p>So for your problem, we have to look at the following points:</p> <ul> <li>Most importantly, <strong>does your query use your index?</strong> Is the index VALID? Run the EXPLAIN PLAN for your DELETE query and check if the index for ORDER_NUM is used and how your data is accessed.</li> <li>Are there any <strong>CONSTRAINTS</strong> on the table? If there are CONSTRAINTS with "ON DELETE CASCADE", there might be other tables affected by your DELETE.</li> </ul> <p>So for your problem, looking at the Execution Plan (EXPLAIN PLAN) might be your best bet.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload