Optimize delete in a very big database table

Hi,
For delete entries in database table i use instruction:
Delete from <table> where <zone> = 'X'.
The delete take seven hours (the table is very big and  <zone> isn't an index)
How can i optimize for reduce the delete time.
Thanks in advance for your response.
Regards.

what is the size of the table and how many lines are you going to delete?
I would recommend you to delete only up to 5000 or 10000 records in one step.
do 100 times.
select *
          from
          into table itab.
          where
          up to 10.000 records.
if ( itab is initial )
  exit.
endif.
delete ... from table itab.
commit work.
If this is still too slow, than you should create a secondary index with zone.
You can drop the index after the deletion is finished.
Siegfried

Similar Messages

  • Delete all content in a database table

    i want to initialize a database table just before my specific program terminate.
    can i use the
    delete databasetable
    Edited by: Matt on Nov 7, 2008 8:04 AM

    Hi,
    If you want to delete all the contents of database table, use the following code:
    data itab type standard table of dbtab.
    select * from dbtab into table itab.
    delete dbtab from table itab.
    Hope this will help.
    Regards,
    Nitin.

  • I want to delete the transactional record from database table

    Hai,
    I want to delete the transactional data from database table with out using the dialog programming is it there any trancation for this.
    for master data we have the transaction code for delete the records. The t.code is 'OBR2'.
    Plz help in that cse.
    Thanks and regards,
    P.Naganjana Reddy

    Hai,
    Plz help me urgent.
    I am asking i want to delete transactional data from database table without using the dialog programming.
    Thanks and Regards,
    P.Naganjana

  • Dynamic JCombobox for a very big database resulset

    I want to use a JCombobox or similar for selecting values from a big database resultset. I'm using an editable one with SwingX autocomplete decorator. My strategy is:
    * show only first Xs regs.
    * let the user to enter some text in the combobox and refine the search reloading the model.
    Someone have some sample code or know some components that do that.
    Or can point me to some implementation details?�
    A lot of thanks in advance,
    PD:
    I need something efficient that don't query database to much.

    what is the size of the table and how many lines are you going to delete?
    I would recommend you to delete only up to 5000 or 10000 records in one step.
    do 100 times.
    select *
              from
              into table itab.
              where
              up to 10.000 records.
    if ( itab is initial )
      exit.
    endif.
    delete ... from table itab.
    commit work.
    If this is still too slow, than you should create a secondary index with zone.
    You can drop the index after the deletion is finished.
    Siegfried

  • How to delete the complete contents of database table ? should be empty !!

    Hi Guys,
    I have requirement where i have delete the contents of database table..i have make it empty (no records at all) and then i have to fill it with the records from the excel sheet.
    I can upload data from the excel sheet.
    Please tell me how to delete the complete contents of the database table ??
    Regards
    Rahul

    hi ,
    just write like this,
    delete from <database table>.
    commit work.
    sample code, here edpar is database table.
    delete from edpar." FROM TABLE g_tab_delete.
      call function 'DB_COMMIT'.
      loop at g_tab_edpar into g_wa_edpar.
        insert into edpar values g_wa_edpar.
        if sy-subrc  eq 0.
          move-corresponding g_wa_edpar to g_wa_edpar1.
          append g_wa_edpar1 to g_tab_edpar1.
        else.
          move-corresponding g_wa_edpar to g_wa_edpar2.
          append g_wa_edpar2 to g_tab_edpar2.
        endif.
      endloop.
    that's all it works.
    reward points if helpful.
    regards,
    seshu.

  • Delete restrict for ABAP Dictionary database table

    Hi,
    I defined two database tables in ABAP dictionary, one with master data, and one with records referencing the master data.
    I also defined a foreign key relationship in the second table, so that new entries in the second table are checked against the master data table.
    In addition to this behaviour, I also want the Dicitionary to perform a check the other way round. In other words, if I try to delete a record in the master data table, this should not be possible if there are records in the second table referencing this record. Thats how foreign key relationships work in Oracle databases.
    Is there a way to force this behaviour for ABAP Dictionary tables, too? Or is it possible to make the table maintenance view perform this check?
    Thanks for your help!
    Kind regards,
    Tobias

    Hello Tobias,
    I can delete records in the master table which have dependent entries in the second table without an error or a warning.
    How are you deleting the entries, via SM30?
    If yes, you can use the [Event 03: Before Deleting the Display Data|http://help.sap.com/saphelp_nw04s/helpdata/en/91/ca9f14a9d111d1a5690000e82deaaa/content.htm]. In this TMG event you can check if the entry can be deleted at all!
    If you're using Open SQL statements to delete the records, i don't think DB layer implicitly checks the dependency. You can always put an explicit check though
    Btw, out-of-curiosity, is this a custom or standard table?
    BR,
    Suhas

  • Export very big database.

    Hello,
    I have 9i database on Linux. This database is very big in tera bytes.I want to shift the database to other server.
    export backup is taking too much time. Can you please suggest me how can i shift my database in few hours?
    Thanks in advance.
    Anand.

    Tricky. Especially since you don't say if the new server is running Linux, too. And you also don't say (which makes a big difference) if the new server will be running 10g.
    But you might be able to do a transportable tablespace migration. That involves exporting only the contents of your existing data dictionary (a matter of a few minutes at most, usually); copying the DBF files to the new server; and then plugging them in by importing your data dictionary export. The major time factor in that lot is the physical act of copying the datafiles between servers. But at least you're not extracting terabytes of data and then trying to re-insert the same terabytes!
    If your new server is not running Linux, forget it, basically, because cross-platform tablespaces are only do-able in 10g and with lots of restrictions and caveats (but you might get lucky... you'd have to read tahiti.oracle.com to find out if you could get away with it).
    If your new server is running 10g, you're also going to be in for tricky times, though it's not impossible to transport between 9i and 10g. Easiest thing, if possible, is to create your 10g database with COMPATIBLE set to 9.x.x, do the transport and then increase your compatible parameter afterwards.

  • Can I restore the deleted statistical data from the database tables?

    Hi all,
       I have deleted the statistical data from the database tables like(Ex: RSDDSTAT, RSDDSTATWHM,..) by mistake through RSA1> Tools> BW Statistics for Infoproviders--> Delete.
    Is there any way to restore the deleted data back? Thanks in advance.

    Now I'm really confused-
    Your first post said
    "<b>I have deleted the statistical data from the database tables like(Ex: RSDDSTAT, RSDDSTATWHM</b>,..) by mistake through RSA1> Tools> BW Statistics for Infoproviders--> Delete."
    but your last respsonse said
    "I have deleted the BW Statistics data, <b>not the actual data in RSDDSTAT tables</b> through
    RSA1 -> Tools -> BW Statistics for InfoProviders -> clicked 'Delete' bin to delete data."
    If you used the RSA1 -> Tools -> BW Statistics for InfoProviders -> clicked 'Delete' - <b>then you deleted the data from the RSDDSTAT tables</b>. This assumes you accepted the default date range that would have popped up after the clicking on the Delete button which specified to delete thru the current date.  If this is what you did, the data is gone.  Your only hope is be to recover from a DB backup.  
    The data in the RSDDSTAT tables is what is used to feed the BW Statistics cubes, generally on a daily basis.

  • Deletion of data within the database tables

    The user is trying to clean up the 2014 data within the database tables. He is running a delete function which keeps causing the log files
    to exceed their limit. The tables are large and he is unable to delete the data in one command due to available size and logging. What is the best way to approach this?
    Thanks,

    Hi venkatesh1985,
    According to your description, the user fails to delete data in tables due to the limited space of log file. Based on my research, this issue could occur when you use the delete statement(DELETE FROM ExampleTable) in a single transaction and consume all
    available space on your transaction log disk.
    To avoid this issue, you could use the two methods below to delete the data.
    1. Use a loop combined with TOP and delete rows in smaller transactions as the following example. This method requires you to delete all the tables one by one.
    SELECT 1
    WHILE @@ROWCOUNT > 0
    BEGIN
    DELETE TOP (1000)
    FROM LargeTable
    END
    For more information about the process, please refer to the article:
    http://dbadiaries.com/how-to-delete-millions-of-rows-using-t-sql-with-reduced-impact
    2. If you want to delete all the data from all tables in the specific database, you could script the entire database and all database objects. Then drop the database and recreate it using the script as the steps below.
    a. In Object Explorer, expand the node for the instance containing the database to be scripted.
    b. Point to Tasks, and then click Generate Scripts and click Next.
    c. Select the option of 'Script the entire database and all database objects'.
    d. Specify how scripts should be saved. You could save the script to a file or new query window. Click Next, then click ok.
    e. Drop the database, and run the script in the query window to recreate it. For more information, please refer to the article:
    http://msdn.microsoft.com/en-us/library/bb895179.aspx#Introduction
    In addition, if possible, please increase the size of the log file or move the log file to a different disk with more disk space.
    Regards,
    Michelle Li

  • Deleteing the contents from the database table

    The aim of this code is to delete the whole contents from these 12 tables.  Is there any way to write the code more efficiently.
    TABLES: ZFFMCTL_AP, ZFFMHDR_AP, ZFFM_CHANGE_LOG, ZFFMDTL_AR, ZFFMHDR_AR,        ZFFMDTL_JV, ZFFMHDR_JV, ZFFMDTL_SKF,ZFFMHDR_SKF,ZFINVOICE_DETAIL,       ZFFMMASTER, ZFFMLOGREAD_CLUS, ZFFMCTL.
    DELETE ZFFMCTL_AP.
    IF SY-SUBRC = 0.
       DELETE ZFFMMHDR_AP.
       IF SY-SUBRC = 0.
          DELETE ZFFM_CHANGE_LOG.
          IF SY-SUBRC = 0.
             DELETE ZFFMDTL_AR.
             IF SY-SUBRC = 0.
                DELETE ZFFMHDR_AR.
                IF SY-SUBRC = 0.
                   DELETE ZFFMDTL_JV.
                   IF SY-SUBRC = 0.
                      DELETE ZFFMHDR_JV.
                      IF SY-SUBRC = 0.
                         DELETE ZFFMDTL_SKF.
                         IF SY-SUBRC = 0.
                            DELETE ZFFMHDR_SKF.
                            IF SY-SUBRC = 0.
                               DELETE ZFINVOICE_DETAIL.
                               IF SY-SUBRC = 0.
                                  DELETE ZFFMMASTER.
                                  IF SY-SUBRC = 0.
                                     DELETE ZFFMLOGREAD_CLUS.
                                     IF SY-SUBRC = 0.
                                        DELETE ZFFMCTL.
                                     ENDIF.
                                   ENDIF.
                                 ENDIF.
                              ENDIF.
                           ENDIF.
                        ENDIF.
                    ENDIF.
                 ENDIF.
               ENDIF.
            ENDIF.
         ENDIF.
    ENDIF.
    This is very urgent,
    Thanks in advance
    John

    Hi ,
    One more thing , Deleting conents of all table in single Loop may cause program .
    This depends on How much data you have in you Table . IF the data is Huge you can split the tables to be deleted . Check for Entry Exists in Table , if not go for Deletion  in the same pre-requisite order.
    Regards,
    sudhi

  • Hoa to delete data from the SE11 database table

    Hi Friends,
    Need some urgent help.
    While uploading data to infotype 6 (addresses) in subtype 4(emergency address), I have uploaded the data twice and it has created a duplicate record now in table PA0006.
    I have done this in the quality server. Will this effect the user acceptance testing(UAT) in anyway and how can I delete this data from table PA0006
    Pls help me urgently.
    Bye
    Naveen

    Hi  Naveen ,
    1 .Check what is the time constraint for address infotype .
    2.If it is 2 , it would have delimited the record , if it is 3 it would have created another record , if it is one there will be no problem as it would have deleted the recored provided u have given the dates into consideration .
    3.It will not be  a problem for UAT . If it is not required do  a scat for deletion of records .
    Regards
    Gajalakshmi

  • After compressed the database table affect the system performance

    There is a very big database table in my system called MSEG. It is about 910G and the wasted tablespace is about 330G. I want to compress the table, but the table is written and deleted frequently. will it affect the system performance if I compress the table. Or I can only select reorganize the dababase table avoid it affect the system performance? Thanks.

    Hi Huiyong,
    If you talk about table compression, it cannot be done online. we need to do this with a planned downtime. Table compression has some percentage of overhead on CPU. Refer SAP note for
    1289494
    FAQ: Oracle compression
    1436352
    Oracle Database 11g Advanced Compression for SAP Systems
    If you talk about online table reorg, yes definitely there would be impact on user performance.
    As the table size is very big it may take some days or hours to perform online Reorg.
    Other faster method is to perform table export import which is faster than online reorg. But it will again require downtime .
    Hope this helps.
    Regards,
    Deepak Kori

  • Delete entry from Database table

    Hi,
    I configured one PCR scenerio in SPRO node -> business Packakes/ funtional packages-> Manager self service-> Personal Change request -> Group Change request scenerio.
    later I deleted that entry in backend, but still the same entry exist in db table "TWPC_PCR_Groups" .
    How can we delete that entry?
    thanks

    Hi,
    If you just want to delete a single entry from database table then you have to it in debug mode .
    go to se11->Give table name->Press F7( ie: display table entries)-> Goto the table contents (CTRLSHIFTF10)->Select the entry you want to delete->Give /H in the command bar ->enter into debug mode-> Give code as DELE -> save it. and press enter. Your entry will be deleted from database.
    Hope this helps..

  • Case issue in Database table

    Hi All,
    We have an issue of lowercase in database table and we want to convert that lowercase data to upper case. The code for doing this operation is as follows:
    SELECT * FROM zehs_volumes INTO TABLE i_volumes_temp.
    LOOP AT i_volumes_temp.
    DELETE zehs_volumes FROM i_volumes_temp.
    IF sy-subrc is INITIAL.
      COMMIT WORK.
    ELSE.
      ROLLBACK WORK.
    ENDIF.
    TRANSLATE i_volumes_temp-zehs_business TO UPPER CASE.
    MODIFY i_volumes_temp.
    CLEAR i_volumes_temp.
    ENDLOOP.
    SORT i_volumes_temp BY SUBID ZEHS_BUSINESS ZEHS_SITE ZEHS_ROLE
                           ZST_DATE ZED_DATE.
    DELETE ADJACENT DUPLICATES
    FROM i_volumes_temp COMPARING SUBID ZEHS_BUSINESS ZEHS_SITE
                                  ZEHS_ROLE ZST_DATE ZED_DATE.
    MODIFY zehs_volumes FROM TABLE i_volumes_temp.
    IF sy-subrc is INITIAL.
      COMMIT WORK.
    ELSE.
      ROLLBACK WORK.
    ENDIF.
    The problem wid the above code is that it first clears the entire database table and then fills it with the modified data from the internal table. But we do not want to take risk of emptying the database table. Is there any way out to perform the above operation?
    Thanks in advance
    Regards,
    Yogesh Sharma

    Hi Karthik,
    Thanks for replying.
    In our case the scenario is we need to delete wrong entires in the database table based on the primary input fields. There is already a utility to do so. But in the table some of the entries are present in the lower case.
    For eg. Suppose we need to delete entry with field zehs_business = "Pioneer". When we input this SAP interpret it as PIONEER and we get an error message "No data exist".
    So the code should we in such a way that all the value in field zehs_business should be translated to upper case otherwise SAP will give an error message of non-existence of data.
    The code which you gave adds one more entry in database table with zehs_business = "PIONEER". Now the database table have two records one with "Pioneer" and other with "PIONEER". After the execution of DELETE statement only the record with zehs_business = PIONEER gets deleted....and the other record still exist.
    Is there any way to avoid above situation....

  • How to get Deleted File details from Content DataBase?

    Hi,
    I have uploaded one pdf document in to SharePoint Document Library. After some days i have removed it.
    File has removed from Site.
    Does record available in Content Data Base for the deleted file? Which table should i refer?
    Thanks & Regards
    Poomani Sankaran

    Hi,
    According to your description, my understanding is that you want to get the deleted file record in sql database table.
    If you have backed up the Content Data Base, then you can find the deleted file information in AllDocs andAllDocStreams  table. You need to use "inner join" to get the whole information.
    More information:
    How to recover SharePoint document once deleted from recycle bin
    Thanks
    Best Regards,
    Jerry Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

Maybe you are looking for