Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6970875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:45:57+00:00 2026-05-27T16:45:57+00:00

Is cascade delete on a table more efficient than individual delete statements (executed in

  • 0

Is cascade delete on a table more efficient than individual delete statements (executed in a single plsql block) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:45:57+00:00Added an answer on May 27, 2026 at 4:45 pm

    What cascade delete does is issue individual delete statements.

    Examine the following test case:

    create table parent 
     (parent_id number, 
      parent_name varchar2(30), 
      constraint parent_pk primary key (parent_id) using index);
    
    create table child 
     (child_id   number,
      parent_id  number,
      child_name varchar2(30),
      constraint child_pk primary key (parent_id, child_id) using index,
      constraint child_fk01 foreign key (parent_id) 
        references parent (parent_id) 
          on delete cascade;
     );
    
    
    insert into parent
     (parent_id, parent_name)
    select object_id, object_name from dba_objects where rownum <= 10000;
    
    begin
      for i in 1..10
      loop
        insert into child
          (child_id, parent_id, child_name)
        select i, parent_id, parent_name
          from parent;
      end loop;
    end;
    /
    
    exec dbms_stats.gather_table_stats (tabname => 'PARENT', cascade => true);
    exec dbms_stats.gather_table_stats (tabname => 'CHILD', cascade => true);
    
    exec dbms_monitor.session_trace_enable;
    alter table child drop constraint child_fk01;
    alter table child add constraint child_fk01 foreign key (parent_id)
      references parent (parent_id) on delete cascade enable novalidate ;
    delete from parent;
    rollback;
    

    In the trace file, you will find a line like this:

      delete from "<MY_SCHEMA_NAME>"."CHILD" where "PARENT_ID" = :1
    END OF STMT
    PARSE #6:c=0,e=182,p=0,cr=0,cu=0,mis=1,r=0,dep=1,og=4,tim=1293353992514766
    EXEC #6:c=0,e=545,p=0,cr=2,cu=32,mis=1,r=10,dep=1,og=4,tim=1293353992515354
    EXEC #6:c=0,e=233,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992515644
    EXEC #6:c=0,e=238,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992515931
    EXEC #6:c=0,e=252,p=0,cr=2,cu=32,mis=0,r=10,dep=1,og=4,tim=1293353992516229
    EXEC #6:c=0,e=231,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992516507
    EXEC #6:c=0,e=227,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992516782
    EXEC #6:c=0,e=244,p=0,cr=2,cu=32,mis=0,r=10,dep=1,og=4,tim=1293353992517072
    EXEC #6:c=0,e=219,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992517337
    EXEC #6:c=0,e=236,p=0,cr=3,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992517622
    EXEC #6:c=0,e=235,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992517921
    EXEC #6:c=0,e=229,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992518196
    EXEC #6:c=0,e=246,p=0,cr=2,cu=32,mis=0,r=10,dep=1,og=4,tim=1293353992518487
    EXEC #6:c=0,e=234,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992518767
    EXEC #6:c=6999,e=570,p=0,cr=2,cu=30,mis=0,r=10,dep=1,og=4,tim=1293353992519383
    

    That is Oracle issuing a delete statement against CHILD for each record it’s deleting in PARENT.

    A different question would be which of the two are more efficient:

    DELETE FROM CHILD WHERE PARENT_ID = 1;
    DELETE FROM PARENT WHERE PARENT_ID = 1;
    

    vs

    DELETE FROM PARENT WHERE PARENT_ID = 1;
    

    both with on delete cascade enabled. Suprisingly enough, in the first case above, Oracle will probe the foreign key index on the child table to see if any rows exist which would require a cascade. If no rows exist, Oracle does not execute the cascaded delete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to perform an ON DELETE CASCADE on my table named CATEGORY, which
Can hibernate resolve mapping across more than one table. Here is example: Class Manufacturer,
I want to perform cascade delete for some tables in my database, but I'm
I have two tables without any cascade deleting. I want to delete parent object
I'm trying to use ON CASCADE DELETE in mysql db but I can't make
can any one provide me full 2 mapping file which implements cascade delete. measn
How to delete a child row (on delete cascade ?) when setting a null
Will I suffer consequences later if I add FKs with ON DELETE CASCADE and
I've been trying to get a delete to cascade and it just doesn't seem
Here is source code: @OneToOne(fetch = FetchType.LAZY) @Cascade({SAVE_UPDATE, EVICT, DELETE}) @JoinColumn(name = A_ID, nullable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.