Which is fast bulk delete or id's in a table and a where exists ....?

I have some parent objects and that I use bulk collect with fetch limit and I currently store the primary keys of these parent objects to identify their child objects later by using where exists with a correlated subquery.
I'm essentially moving objects graphs that span partitions from table to table.
when I've done my SQL insert into select... I eventually do a delete.
currently the delete uses the parent objects in this working table to identify the children to delete later.
Q. What is likely to be faster?
using a "temporary" table to requery for child objects based on the parents that I have for each batch or
using returning clause from my insert into select so that I have rowid's or primary keys to work with later on
when I want to perform my delete operation?
I essentially have A's that have child B's which in tern have child C's.
I store a batch of A pk's in a table and use those to identify the B's
currently I don't store the B's pk but use the A pk's again to identify the B's which in turn are used to identify the C's later.
I'm thinking if I remember the pk's I'm using at each level I can then use those later when it comes to the deletes.
typically that's done in a returning clause and using a bulk delete from that collection later.
thoughts?

Parallel DML is one option. Another is to ceate a procedure (or package) that does a discreet unit of work (e.g. process parent and its children as a single business transaction). And then write a "+thread manager+" that runs x number copies of these at the same time (via DBMS_JOB for example).
Let's say the procedure's signature is as follows:
create or replace procedure ProcessFamily( parentID number ) is ..
--// processes a family (parent and children)
..Using DBMS_JOB is pretty easy - when you start a job you get a job number for it. Looking at USER_JOBS will tell you whether that job is still in the job queue, or has completed (once off jobs are removed from the queue). The core of the this code will be a loop that checks how many jobs (threads) are running, and if less than the ceiling (e.g. it may only use 20 threads), start more ProcessFamily jobs.
If the total number of threads/jobs to execute are known up front, then this ThreadManager can manually create a long operation entry. Such an entry contains the number of unit of works to do and then is updated with the number of units done thus far. Oracle provides time estimates for completion and percentage progress. This long operation can be tracked by most Oracle-based monitoring software and provide visibility as to what the progress is of the processing.
The ProcessFamly procedure can also use parallel DML (if that makes sense). Or bulk processing (if needed). This approach is also scalable as h/w increases (server upgrades, new server h/w), so too does your ability to run more threads (aka jobs) at the same time.
Now I'm not suggesting that you write a ProcessFamily() proc - I do not know the actual data and problem you're trying to solve. What I'm trying to convey is the basic principle for writing multi-thread/parallel processing software using PL/SQL. And it is not that complex. The critical thing is simply that the parallel procedure or thread be entirely thread safe - meaning that multiple copies of the same code can be started and these copies will not cause serialisation, dead locking, and other (application designed) problems.

Similar Messages

  • I am trying to download a form to fill in and it appears in Windows wordpad and there are milions of random characters which |I have to delete before I get to the text and then the test isn't in the format of a form to fill in. Help!!!

    when ever I try to download a form to fill in, the default is windows wordpad and then it appears with millions of characters which I have to delete before getting to the text which is not in the style of a form to fill in.
    How can i get it to download the form as it is?

    What kind of code do you see?
    Is that an HTML file or a PDF file for the Adobe Reader?
    *https://support.mozilla.com/kb/Using+the+Adobe+Reader+plugin+with+Firefox

  • Deletion of data from change log table and PSA

    Hi,
    For a DSO  I want to delete data from "Chnage log table"  and " PSA Tabel".
    For the DSO manage screen I have seen " Environment-> " Delete changelog table" from this we can delete chnage log table data as per my understanding.
    at PSA Level Mange screen also I have seen " Environment-> " Delete changelog table" from this option also it deletes the data from change log table or it deletes data from PSA table?.
    if this option also deletes data from changelog table then how we can delete data from PSA table?
    Please clarify me

    Hi,
      I am not sure what are you referring to from your point "PSA Level Mange screen also I have seen " Environment-> " Delete changelog table". When ever you click on manage for your psa you will be routed to a popup where you can see all your requests in the PSA table & there after if you click on any single request you will get Environment menu option but there wotn be any change log deletion option available. Please check again? Right clicking on your data source will take you to the manage requests for PSA. You can selectively delete the requests as required.
    For DSO when you right click on manage you can directly find Delete change log data option in the Environment tab. there you can select the requests you want to delete.
    Also if you want to automate the deletion process then you can simply create a chain and include the steps for PSA deletion & change Log deletion accordingly.
    Also it is recommended to keep on clearing the PSA table & Chage log data at regular intervals as it saves the disk space & thus helping in performance optimization
    Please refer the below doc at SDN, it will be helpful for you in automating the process of change log deletion & PSA deletion.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a02ba9e7-bb6f-2c10-09b4-e86b9fcbad41?QuickLink=index&overridelayout=true
    Hope it clears your doubts
    Thanks

  • How do I delete a column for just one table and not all the others?

    I have multiple tabels in a Pages document. I want to delete some columns on some of the tables but keep them on the other tables. When I delete the columns it deletes all of them on all of the tabels and I dont want that.

    No. To do what you are asking for would require a separate table on each page.
    Of course you can always move blocks of cells around manually, but I can't imagine how you would manage that.
    Jerry

  • Why do I have two versions of lightroom on my desktop and which one should I delete/uninstall

    Why do I have two versions of lightroom on my desktop and which one should I delete/uninstall?

    Hi,
    Lightroom 5.x and CC will be installed side by side. You may uninstall the prior version one you’re comfortable in the new version of Lightroom.
    Lightroom CC/Camera Raw FAQ
    Regards,
    Sumit Singh

  • How can I bulk delete contacts from my iPhone 4S? I've imported contacts from gmail and hotmail, many of which I don't need. Deleting them individually will take ages, there must be a quicker way. Also, are my contacts taking up space on my iPhone or

    How can I bulk delete contacts from my iPhone 4S? I've imported them from gmail and hotmail and there are many more than I need. Deleting them one by one will take ages, there must be a quicker way! Also, do contacts take up space on the phone or are they stored remotely?
    Thanks.. J

    You should be syncing your contacts with an app on your computer or cloud service (iCloud, Gmail, Yahoo, etc), and not relying on a backup.  If you haven't been doing this, start now and then restore your old backup.  You will then be able to sync the new contacts back into the phone.  However, you will lose all messages, etc newer thant the backup.

  • Bulk delete of customer details after soft bounce

    Another item that has been requested time and time again over the years.
    Anyone have a solution of how to delete Leads after a soft bounce, which never came through as a hard bounce. (I won't call them customers as there is no other information on them or purchases - just an email address, so there is no issue)
    Nothing is easy in this system! Getting jack of it, and so are clients.
    You can pull up the problem soft bounces, and fantastic, you can open in a new tab, instead of the STUPID pop up box.
    But that is where the ease stops. I can not view the customer in a "New Tab" and then delete them.
    I can only click on the link and view the customer, which means my list of all the soft bounces disapears.
    After deletion, I have to go through the whole rigmarole again, of
    going to the email campaign
    Going to bounces
    changing the sort criteria
    waiing for the list
    viewing the customer
    deleting them
    and starting again
    There are over 200 bounces
    Seriously !!
    Again I point out this was on the wish list for years!!

    A row-by-row delete should function properly but will probably be slow for a couple of reasons. The index maintenance has already been mentioned, but the other reason is context switching - there can be overhead from switching back and forth between SQL and PL/SQL. Bulk SQL as John illustrated should be efficient. Also remember to do as few commits as possible, one if you can.
    If you are deleting a significant number of rows in the table you can try dropping non-critical indexes (not used for the delete) and rebuilding them when the delete is done - if other processes don't need to access the data during this time. Indexes used for the delete can be dropped and recreated afterwards.
    Another option suggested here on OTN that might help is to copy the rows you want to keep to a new table, recreate any indexes and constraints (this will take a bit of effort), drop the old table and rename the new table to the old name. This might help if you are deleting a lot of rows.
    The parallel query option might help if you can parallelize the deletion, or perhaps reading the list of rows to delete. I'm not sure about licensing on this option.
    Another option is to consider partitioning - if you have the license. If you can partition by the deletion key removing the rows by dropping the partiton can be very fast.

  • FORALL bulk delete statement requires lot of time even for 10 rows deletion

    Hi,
    when I execute FORALL bulk delete statement it requires lot of time even for 10 rows deletion.so how to avoid this problem? I checked SGA_TARGET and PGA_TARGET cureent_size and max_size are same for both. Is their memory problem?
    I execute following code
    DECLARE
    TYPE t_id_tab IS TABLE OF test.c1%TYPE;
    l_id_tab t_id_tab := t_id_tab();
    Begin
    select c1 bulk collect into l_id_tab from TEST where c1<=10;
    dbms_output.put_line(DBMS_UTILITY.get_time);
    FORALL i IN l_id_tab.first .. l_id_tab.last
    delete from TEST where c1= l_id_tab(i);
    dbms_output.put_line(DBMS_UTILITY.get_time);
    commit;
    End;
    thanks in advance
    Vaibhav
    Edited by: Vaibhav on Oct 10, 2011 10:47 PM

    hi
    i am working on oracle 11g. Actually i have to test which is the faster method to delete 150000 records.
    1st by using FOR Loop bunch of 10000 records
    2nd by using FORALL delete
    kindly find below FORALL delete code
    DECLARE
    TYPE t_id_tab IS TABLE OF test.c1%TYPE;
    l_id_tab t_id_tab := t_id_tab();
    Begin
    select c1 bulk collect into l_id_tab from TEST where c1<=10;
    dbms_output.put_line(DBMS_UTILITY.get_time);
    FORALL i IN l_id_tab.first .. l_id_tab.last
    delete from TEST where c1= l_id_tab(i);
    dbms_output.put_line(DBMS_UTILITY.get_time);
    commit;
    End;
    Edited by: Vaibhav on Oct 10, 2011 10:56 PM

  • Regarding bulk delete..

    Hi,
    I have areound 9400k reocrd should be deleted I am using for all delete with bulk collect . here i s the code for ref.
    declare
    2 type cust_array_type is table of number
    3 index by binary_integer;
    4 employee_array cust_array_type;
    5 v_index number;
    6 begin
    7 select empl_no bulk collect
    8 into employee_array from employee_history;
    9
    10 FORALL i IN employee_array.FIRST..employee_array.LAST
    11 delete from ord where empl_no = employee_array(i);
    12
    13 v_index := employee_array.FIRST;
    14 for i in employee_array.FIRST..employee_array.LAST loop
    15 dbms_output.put_line('delete for employee '
    16 ||employee_array(v_index)
    17 ||' deleted '
    18 ||SQL%BULK_ROWCOUNT(v_index)
    19 ||' rows.');
    20 v_index := employee_Array.NEXT(v_index);
    21 end loop;
    22 end;
    still data is not deleting pllease do advise

    user13301356 wrote:
    but normal delete is taking more time so to improve performance using bulk collect delete.
    so what is best approach to delete to go by bulk delete or normal delete.Look at it in simple terms...
    Method 1: Delete all Rows
    Method 2: Query all Rows then Delete all Rows
    which one, logically to you, is doing more work than the other?
    If your delete is taking a long time, that's because:-
    a) you haven't got suitable indexes to determine the records to be deleted on the target table
    b) you haven't designed the table to use parititions which could then simply be truncated (costed optional, licence required for partitioning)
    c) you are just deleting a lot of data and it's going to take time.
    No amount of PL/SQL coding around the basic SQL of a delete is going to improve the performance. You can't make any code delete the rows faster than a delete statement itself.

  • I borrowed a hard drive from a friend that contains many thousands of songs. Somehow when tranferring these to iTunes I managed to get several copies of each song. How can i do a bulk delete of all the copies leaving just one version of each song?

    I need help please. I borrowed a hard drive from a friend which contains many thousands of songs. When adding them to my iTunes library I somehow managed to make multiple copies of each song. Is there a way to do a bulk delete of all the duplicates? If I have to go one by one it will take a lifetime.

    I have the same problem. I keep backups on a home server and this is where my library pointed to. I changed it to the local drive and now I have two copies in the library. I need to either bulk delete or clear the library (without deleting the files) and then rebuild. How do I do either of these things?

  • Can emails be bulk deleted from Iphone 4s or does each have to be marked individually then deleted.  Trash can be bulk deleted.

    Can emails be bulk deleted from Iphone 4s or does each have to be marked individually then deleted.  Trash can be bulk deleted.

    Each has to be deleted.
    But it can go faster if the iPhone is held in the horizontal position, then on the left side listing tap Edit in the upper raight bar of that pane, and just tap each email to be deleted, then when you have a batch to delete, tap delete at the bottom left.  That is the fastest way I have found.

  • Is it possible to do a bulk delete in email?

    I got so discusted a couple of weeks a go at having to edit/highlight/ each individual email that I just stopped using my iPad for email. I now have over 700 emails in the inbox. Is there anyway to do a bulk delete without having to manually (activate the red dot)  check each email? I like to swipe and do a group delete.
    ie. empty the mailbox with one command.

    I just accidently found a way to delete all.  I went to search to find an app that I had buried in a folder.  When I typed it in, all references to it came up, including deleted emails.  I chose one of the deleted emails. It opened, but had Trash as the main folder, with an arrow to take me back to windstream (my POP account).  When I clicked the windstream option, Trash was one of the choices available. I chose trash, hit Edit at the top.  DELETE ALL was available at the bottom. I hope this helps.
    I apologize.  Your question was about deleting the inbox messages, which is what I was searching for when I found this.  Not only that, but you can get to trash much easier by just going down to your accounts. Duh!  Sorry I jumped the gun.  I hope you find a way to mass delete your inbox. If you do, please share!

  • Bulk deletion of photos - where is the "Select All"?

    This is a question for Apple after a couple of years of frustration and work-arounds
    Using the camera connection kit I frequently suck in hundreds of photos to the iPad for viewing in the field. These go into the 'All Imported' folder
    In a short period of time, this folder grows to a monster (currently I have some 4000 photos in it) and I need to clear it out as it stuffs up my tiny 64gb iPad.
    ALL methods I have read to do this are frankly awkward and kludgy.  'Image Capture" has stopped recognising the iPad". I don't always have access to a 3rd device which doesn't already have these photos imported (thus blocking the 'delete after importation' approach). Furthermore it has taken me over a year to grok that you need to use TWO fingers to swipe multiple photos (in any case an ugly process when dealing with 1000s) not ONE as in previous version. Like most iPad/Apple users I had assumed that this 'feature' had quietly been dropped
    The addition of a simple 'select ALL' button would save me and thousands of users countless grief. There are a number of other applications in which this would be useful (music) but it is the photos which most affect me.  it is a generic solution and compatible with the standard Applu UI metaphor.  Why in earth would you not put this in place?
    -gordon
    [email protected]

    On a Mac, you can use the Apple Image Capture utility to bulk process your iPad photos.
    On a Windows PC, there is no Apple Image Capture utility. However, you can follow this procedure to bulk-delete photos from your iPad:
    connect your iPad to your PC using the USB-cable that came with your iPad
    open Windows Explorer, and open the DCIM-folder on your iPad
    you will see a list of folders with "weird" names, which look like this example:Computer\iPad\Internal Storage\DCIM\838CPLYO
    for each folder, open it, select all photos in it, and press the delete-keynote: you cannot delete the entire folder itself, you have to go in and delete the photos in it
    A bunch of empty folders will remain after this procedure, which you cannot delete manually, but they will be automatically cleaned-up after you restart your Photo app on your iPad.

  • Suggestions needed in a huge bulk delete operation

    Hi ,
    I have the following scenario.
    begin
    open c1;
    fetch c1 bulk collect into L_item ; cursor fetch -- 20,000(x) rows
    forall i in 1..L_item.count
    delete tab7 where col1= L_item(i); delete 900*x rows
    forall i in 1..L_item.count
    delete tab1 where item = tem(i); delete 900*x rows
    forall i in 1..L_item.count
    delete tab2 where col1= L_item(i); delete 900*x rows
    forall i in 1..L_item.count
    delete tab3 where col1= L_item(i); delete 4*x rows
    forall i in 1..L_item.count
    delete tab4 where col1= L_item(i); delete 4*x rows
    forall i in 1..L_item.count
    update tab5 set col1='N' where col2 = L_item(i); update 1*x rows
    forall i in 1..L_item.count
    insert into tab6 values (L_item(i),sysdate); insert 1*x rows
    if i do commit here redo buffer may overflow .
    In this above scenario please suggest me what way i will follow or this way is the best way to do so.
    My database version is below
    Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
    PL/SQL Release 9.2.0.4.0 - Production
    CORE 9.2.0.3.0 Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.4.0 - Production
    NLSRTL Version 9.2.0.4.0 - Production
    Thanks in advance
    Edited by: bp on Mar 24, 2009 10:29 PM

    If it is feasible as per your requirement, instead of deleting data from your table take the backup of data that is to be retained in a temp table, then truncate your main table and reload it from the temp table.This will be faster and will prevent the problem of high watermark.

  • How to bulk delete email - not 5 or 10 by selecting all the emails one by one but "delete before..." or similar

    Hi Cimmunity
    as you often traval and as you say have a lot of emails: how do you delete them in masses like bulk delete? on my old blackberry (newstes except z10) I had the option to "delete all before (...) date" in the context menu and could delete 1500 emails with one tap. do you know how to do this now? there is no such function, one have to tap and mark every single email, even if there are 2000!!!!! crazy!!
    thanks a lot!!
    BB: please urgently add the feature again...!!!! I have a imap account with about 200 emails a day which are just copies of enterprise mail and need to delete hundreds every day. I can not tap and select all the single mails one by one and then delete.
    Solved!
    Go to Solution.

    Go into the hub, select email account, Just under the blue email account, click and hold the date bellow it , slider pops on the right, click on Trash can(delete prior).

Maybe you are looking for

  • Where is Free Goods Indicator Stored?

    Hi All, Looking at the PO screen, Free Goods Indicator, Free Item Indicator is stored in UMSON, but I can't find that in any table. Does anybody know what table this is in? Please help Thanks, Thang

  • Default text in Sales orders

    Dear all, We are having a problem in which some default texts are appearing while creating a sales order. This is due to the problem when the sales order is being created the sales order number is XXXXXXXXXX. When we execute the function module SE37

  • Connection Limits

    Hi, I was searching online for limit on the service and there are multiple different version on the answer accross 2 years of posting. Is there a maximum number of concurrent connection on a single account? Is there a maximum number of groups? My app

  • Laser printer for Mac OS X 10.7.3 airprint

    Need a laser printer for iMac and Macbook Air enable airprint. Thank you

  • Starting Credit Rating Service

    Hi, I am going through order booking tutorial,in that i want to start credit rating service.In BPEL developer prompt ,on giving commands as mentioned in the tutorial i get error, BUILD FAILED,Authentication failed for user oc4jadmin. Please help me w