Best way to insert millions of records into the table

Hi,
Performance point of view, I am looking for the suggestion to choose best way to insert millions of records into the table.
Also guide me How to implement in easier way to make better performance.
Thanks,
Orahar.

Orahar wrote:
Its Distributed data. No. of clients and N no. of Transaction data fetching from the database based on the different conditions and insert into another transaction table which is like batch process.Sounds contradictory.
If the source data is already in the database, it is centralised.
In that case you ideally do not want the overhead of shipping that data to a client, the client processing it, and the client shipping the results back to the database to be stored (inserted).
It is must faster and more scalable for the client to instruct the database (via a stored proc or package) what to do, and that code (running on the database) to process the data.
For a stored proc, the same principle applies. It is faster for it to instruct the SQL engine what to do (via an INSERT..SELECT statement), then pulling the data from the SQL engine using a cursor fetch loop, and then pushing that data again to the SQL engine using an insert statement.
An INSERT..SELECT can also be done as a direct path insert. This introduces some limitations, but is faster than a normal insert.
If the data processing is too complex for an INSERT..SELECT, then pulling the data into PL/SQL, processing it there, and pushing it back into the database is the next best option. This should be done using bulk processing though in order to optimise the data transfer process between the PL/SQL and SQL engines.
Other performance considerations are the constraints on the insert table, the triggers, the indexes and so on. Make sure that data integrity is guaranteed (e.g. via PKs and FKs), and optimal (e.g. FKs should be indexes on the referenced table). Using triggers - well, that may not be the best approach (like for exampling using a trigger to assign a sequence value when it can be faster done in the insert SQL itself). Personally, I avoid using triggers - I rather have that code residing in a PL/SQL API for manipulating data in that table.
The type of table also plays a role. Make sure that the decision about the table structure, hashed, indexed, partitioned, etc, is the optimal one for the data structure that is to reside in that table.

Similar Messages

  • What's the best way to insert/update thousands records in multiple tables

    Can anyone give an example of how to insert/update thousands records in multiple tables on performance wise? or what should I do to improve the performance?
    Thanks
    jim

    You can see a set of sample applications in various scenarious available at
    http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/content.html

  • Inserting millions of records into new table based on condition

    Hi All,
    We have a range partitioned table that contains 950,000,000 records (since from 2004) which is again list sub-partitioned on status. Possible values of stauts are 0,1,2,3 and 4.
    The requirement is to get all the rows with status 1 and date less than 24-Aug 2011. (Oracle 11g R2).
    I trying below code
    CREATE TABLE RECONCILIATION_TAB PARALLEL 3 NOLOGGING  
    AS SELECT /*+ INDEX(CARDS_TAB STATUS_IDX) */ ID,STATUS,DATE_D
    FROM CARDS_TAB
    WHERE DATE_D < TO_DATE('24-AUG-2011','DD-MON-YYYY')
    AND STATUS=1; CARDS_TAB has tow global indexes one on status and another on date_d.
    Above query is running for last 28Hrs! Is this the right approach?
    With Regards,
    Farooq Abdulla

    You said the table was range partitioned but you didn't say by what. I'm guessing the table is range partitioned by DATE_D. Is that a valid assumption?
    You said that the table was subpartitioned by status. If the table is subpartitioned by status, what do you mean that the data is randomly distributed? Surely it's confined to particular subpartitions, right?
    What is the query plan without the hint?
    What is the query plan with the hint?
    Why do you believe that adding the hint will be beneficial?
    Justin

  • Inserting new input record into the table through screen

    Hi,
    Example UserTable and PaymentTable
    UserTable - UserID - Primary Key
    PaymentTable - containg couple of fields and UserId is foreign Key.
    I designed the page for to insert the new input record using the steps given in the doc "http://download-uk.oracle.com/docs/cd/B32110_01/web.1013/b28967/web_adv007.htm".
    When i click the persistEntity method its throws TopLink error cannot insert null value into UserId column in PaymentTable.
    Currently i am posting this reply from home... that's why i mentioning the scenario rather than posting the error.
    Please tell how to populate the values from the screen to PaymentTable.
    Thanks & Regards
    Vimalan Balan

    Hi Vimalan,
    Did you find an answer for you question?
    Regards,
    Phil

  • What is the best approach to insert millions of records?

    Hi,
    What is the best approach to insert millions of record in table.
    If error occurred while inserting the record then how to know which record has failed.
    Thanks & Regards,
    Sunita

    Hello 942793
    There isn't a best approach if you do not provide us the requirements and the environment...
    It depends on what for you is the best.
    Questions:
    1.) Can you disable the Constraints / unique Indexes on the table?
    2.) Is there a possibility to run parallel queries?
    3.) Do you need to know the rows which can not be inserted if the constraints are enabled? Or it is not necessary?
    4.) Do you need it fast or you have time to do it?
    What does "best approach" mean for you?
    Regards,
    David

  • To add new record into the table Data Service client

    When I am trying to add new record into the table Employeedetails using Data Service client it is giving a sql exception: "java.sql.SQLException: Violation of PRIMARY KEY constraint 'PK__EmployeeDetails__6383C8BA'. Cannot insert duplicate key in object 'EmployeeDetails'. Severity 14, State 1, Procedure 'PC-P41403 null', Line 1."
    Code:
    DataService ds=DataServiceFactory.newDataService(getInitialContext(),"EmplDetApp","ld:EmplDetAppDataServices/EmployeeDetails");
    EmployeeDetailsDocument edoc=EmployeeDetailsDocument.Factory.newInstance();
    edoc.addNewEmployeeDetails();
    //here I set the primary key value empid
    edet.setEmpid("1212");
    edet.setEmpname("manu");
    ds.submit(edoc);
    Error
    EmpName 5 java.sql.SQLException: Violation of PRIMARY KEY constraint 'PK__EmployeeDetails__6383C8BA'. Cannot insert duplicate key in object 'EmployeeDetails'. Severity 14, State 1, Procedure 'PC-P41403 null', Line 1
    com.bea.ld.dsmediator.DataServiceException: java.sql.SQLException: Violation of PRIMARY KEY constraint 'PK__EmployeeDetails__6383C8BA'. Cannot insert duplicate key in object 'EmployeeDetails'. Severity 14, State 1, Procedure 'PC-P41403 null', Line 1
         at com.bea.ld.dsmediator.update.JDBCAdaptor.save(JDBCAdaptor.java:247)
         at com.bea.ld.dsmediator.update.DataServiceMediator.submit(DataServiceMediator.java:528)
         at com.bea.ld.dsmediator.update.DataServiceMediator.submit(DataServiceMediator.java:245)
         at com.bea.ld.ServerBean.submit(ServerBean.java:529)
         at com.bea.ld.Server_ydm4ie_EOImpl.submit(Server_ydm4ie_EOImpl.java:910)
         at com.bea.ld.Server_ydm4ie_EOImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:492)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:435)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:430)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
         at java.lang.Thread.startThreadFromVM(Unknown Source)
    Caused by: java.sql.SQLException: Violation of PRIMARY KEY constraint 'PK__EmployeeDetails__6383C8BA'. Cannot insert duplicate key in object 'EmployeeDetails'. Severity 14, State 1, Procedure 'PC-P41403 null', Line 1
         at weblogic.jdbc.mssqlserver4.TdsStatement.processWarning(TdsStatement.java:1178)
         at weblogic.jdbc.mssqlserver4.TdsStatement.parseMsWarning(TdsStatement.java:1089)
         at weblogic.jdbc.mssqlserver4.TdsStatement.getMoreResults(TdsStatement.java:756)
         at weblogic.jdbc.mssqlserver4.TdsStatement.execute(TdsStatement.java:210)
         at weblogic.jdbc.mssqlserver4.TdsStatement.executeUpdate(TdsStatement.java:97)
         at weblogic.jdbc.mssqlserver4.TdsStatement.executeUpdate(TdsStatement.java:1455)
         at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:147)
         at com.bea.ld.dsmediator.update.JDBCAdaptor.save(JDBCAdaptor.java:151)
         ... 15 more
    But I am not sure why it is giving an exception as Violation of PRIMARY KEY.
    The update method works fine for the same client.
    The exception only happens when I am trying to insert a new record.
    Please help me to figure out this problem.

    If you are absolutely sure that you do not have such a row already in your table, open a case with customer support and reference CR321312. I believe the work-around is to put ld-server-core.jar in your client classpath.
    Correction: put ld-server-app.jar in the client classpath
    Edited by mreiche at 09/17/2007 3:28 PM

  • Best way to insert 300dpi photo's into Ilustrator file for print

    I am creating a 5.5 X 8 postcard style card for print.  I need to place 15 photographs that are aprox. 1.5 X 2.5 each.  What is the best way to insert these files so that my file doesn't become too large?  I will be making a PDF of the final artwork to send to the printer.  Your guidance is much appreciated!!

    Link don't embed the images. Use a layered format such as .psd, .tif, or .pdf. Psd is not lossy, .tif can be lossy if you modify the default settings, .pdf you choose how much compression you want, and a small amount of compression can make a much smaller file size.
    I would recomend using .psd, in cmyk color space. When you make your pdf for printing is when you will decide how much compression and which pdf preset you will use(press ready or PDF X should be a good choice). That will be your important choice.

  • Different methods involved in insertion of records into the table

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production)
    Oracle Database 10g Release 10.2.0.1.0 - Production
    i have parameters like emp_code(optional) and year(mandatory field-four digit year).
    Based on the parameter i have to get the details from one table and those records should be inserted into other table along with additions columns(by hardcoding the additional columns).
    To acheive this i am planning to get a cursor by selecting the necessay fields from the table passing the parameters in the where clause of the cursor.
    by looping through the cursor i will insert the records into the other table.
    here the thing is the data is going to be huge (since year is the parameter).
    so is my approach leads to the performance issue.
    i heard that there are different method of insetions,
    can anybody suggest me the better way(peformance wise) other than what i have mentioned (if you are aware of)..
    Thanks..

    This is not really a Forms issue, so you'd better go to the sql and pl/sql forum. Here, this question has been asked many times: how do I insert large volumes of data in a table?
    insert into ...
    select ....
    or CTAS (create table as select ....)
    by looping through the cursor i will insert the records into the other table.That is really the worst idea. If you can do it in sql (insert into ... select ...) DON'T do it in pl/sql.

  • How to restrict the number of Records into the Table?

    Is there any way that I can restrict the number of records can be entered into the table?
    For example I have created a table TAB1 with size category 0( zero).
    User dont want to enter more than 100 values, How to restrict the number entries? Whether Basis can do it?
    Regards,
    Prathap

    Hi Prathap,
    You can write a code in table maintenance events to restrict the number of Records added into the Table to constant.
    Solution:
    Se11 -> enter table name (TAB1) -> F6 -> Utlities -> Table maint. generator -> Envirnment -> modification -> events -> write here the form routine name.
    Double click on routine name. You will get into include section of the code. Write here code like:
    IF current_rec_num > 100.
       messgae error 'Entry restriceted to 100'
    ENDIF.
    Somewhat this way you can achieve your target.
    Regards,
    Sachin

  • INSERTION OF XML DATA INTO THE TABLE USING XMLDOM

    hello,
    i am using XMLDOM to insert the data into the table
    i am using different function of it.
    but i am facing the problem to retrive the the multiple entry.
    like in my example i have two entry of the ' po number '
    & i am using the function
    dbms_xmldom.item(l_nodelist, 0)
    i which i have to pass index no.
    & through this i am getting only single entry according to the index no.
    Example on which i am working is
    declare
    l_xml_data CLOB;
    l_xml_doc dbms_xmldom.domdocument;
    l_nodelist dbms_xmldom.DOMNodeList;
    l_node dbms_xmldom.domnode;
    l_xmltype XMLTYPE;
    l_po_num VARCHAR2(30);
    l_cust_ord VARCHAR2(30);
    l_item_code VARCHAR2(30);
    begin
    l_xml_data := '<?xml version="1.0" encoding="UTF-8"?>
    <!--DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd"-->
    <MobileInventoryResponse>
         <message>
              <message-header>
                   <message-id>16244182</message-id>
                   <transaction-name>ship-advice</transaction-name>
                   <partner-name>cbeyond</partner-name>
                   <source-url>http://www.brightpoint.com</source-url>
                   <create-timestamp>20080826150709</create-timestamp>
                   <response-request>1</response-request>
              </message-header>
              <ship-advice>
                   <header>
                        <customer-id>297859</customer-id>
                        <shipment-information>
                             <ship-first-name>RA_13Aug_1</ship-first-name>
                             <ship-last-name>MIND</ship-last-name>
                             <ship-address1>test</ship-address1>
                             <ship-city>test</ship-city>
                             <ship-state>VA</ship-state>
                             <ship-post-code>22102-4931</ship-post-code>
                             <ship-country-code>US</ship-country-code>
    <ship-phone1>0040726335068</ship-phone1>
    <ship-email>[email protected]</ship-email>
    <ship-via>FX01</ship-via>
    <ship-request-date>20080826</ship-request-date>
    <ship-request-warehouse>CBY1</ship-request-warehouse>
    </shipment-information>
    <purchase-order-information>
    <purchase-order-number>380928</purchase-order-number>
    <purchase-order-number>380929</purchase-order-number> ----modi by Ananda Dubey
    <account-description/>
    <purchase-order-amount>0.0</purchase-order-amount>
    <currency-code>USD</currency-code>
    </purchase-order-information>
    <order-header>
    <customer-order-number>0002759</customer-order-number>
    <customer-order-date>20080826</customer-order-date>
    <order-sub-total>19.0</order-sub-total>
    <order-discount>0.0</order-discount>
    <order-tax1>0.0</order-tax1>
    <order-tax2>0.0</order-tax2>
    <order-tax3>0.0</order-tax3>
    <order-shipment-charge>18.0</order-shipment-charge>
    <order-total-net>0.0</order-total-net>
    <order-status>Completed</order-status>
    <order-type/>
    <brightpoint-order-number>35028788</brightpoint-order-number>
    <warehouse-id>CBY1</warehouse-id>
    <ship-date>20080826</ship-date>
    </order-header>
    </header>
    <detail>
    <line-item>
    <line-no>1</line-no>
    <item-code>SKU1</item-code>
    <universal-product-code>0</universal-product-code>
    <ship-quantity>1.0</ship-quantity>
    <unit-of-measure>EA</unit-of-measure>
    <serial-list>
    <serial-numbers>
    <esn>TIMI000013</esn>
    </serial-numbers>
    </serial-list>
    <line-status/>
    <base-price>0.0</base-price>
    <line-discount>0.0</line-discount>
    <line-tax1>0.0</line-tax1>
    <line-tax2>0.0</line-tax2>
    <line-tax3>0.0</line-tax3>
    <bill-of-lading>929406733828</bill-of-lading>
    <scac>FX01</scac>
    </line-item>
    </detail>
    </ship-advice>
    <transactionInfo>
                   <eventID>16244182</eventID>
              </transactionInfo>
         </message>
    </MobileInventoryResponse>';
    l_xml_doc := dbms_xmldom.newDomDocument(l_xml_data);
    -- Method 1 to get data
    l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
    l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
    l_po_num := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
    dbms_output.put_line(l_po_num);
    l_nodelist := dbms_xslprocessor.selectnodes(dbms_xmldom.makenode(l_xml_doc),
    '/MobileInventoryResponse/message/ship-advice/detail/line-item/item-code');
    l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
    l_item_code := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
    dbms_output.put_line(l_item_code);
    l_xmltype := XMLTYPE(l_xml_data);
    l_cust_ord := l_xmltype.extract('/MobileInventoryResponse/message/ship-advice/header/order-header/customer-order-number/text()').getStringVal();
    dbms_output.put_line(l_cust_ord);
    dbms_xmldom.freeDocument(l_xml_doc);
    end;
    /

    In the following code
    l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
    l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from listYou need to understand what the second parm on the .item call does. See [dbms_xmldom.item|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_xmldom.htm#i1126138]
    The nodelist is a 0 based array of information and you are only requesting to pull the node info in the first array position. So to get the info in the second array position, you need to use ", 1)". You can also use .getLength and a loop to parse through everything in the node list.

  • Best way to Insert Millions records in SQL Azure on daily basis?

    I am maintaining millions of records in Sql Server 2008 R2 and now i am intended to migrate these on SQL Azure.
    In existing system with SQL Server 2008 R2, few SSIS packages and Stored Procedures are firstly truncate the existing records and then perform Insert operation on the table which holds
    approx 26 Million records in 30 mins. on Daily basis (as system demands).
    When i migrate these on SQL Azure, i am unable to perform these operations in a
    faster way as i did in SQL 2008. Sometimes i got Request timeout error.
    While searching for faster way, many of them suggest for Batch process or BCP. But Batch processing is NOT suitable in my case because it takes much time to insert those records. I required some faster and efficient way on SQL Azure.
    Hoping for some good suggestions.
    Thanks in advance :)
    Ashish Narnoli

    +1 to Frank's advice.
    Also, please upgrade your Azure SQL Database server to
    V12 as you will receive higher performance on the premium tiers.  As you scale-up your database for your bulk insert, remember that
    SQL Database charges by the hour. To minimize costs, scale back down when the inserts have completed.

  • Best way to load old historical records into sc2 type 2 dimesnion

    Hi,
    We have scd type 2 diemsnion and have history dating form early 2012 in there but wish to add extra older historical episodes of recoprds for 2011 into it.
    What is the best way to do this?
    Thoughts?
    Considering some pl/sql but 5 levels in the dimesnion.
    Can't reload as need existing records due to integirty with facts.
    Thnaks

    Are you using OWB's dimension operator and it's SCD functionality?
    Cheers
    David

  • How to speed insert my 1000000 records into the database?

    my code like:
    <cfloop from="1" to="#inserteddb.getrecordcount()#"
    index="x">
    <!----
    Here make the InsertFieldList and InsertValueList
    --->
    <cfquery datasource="#cfdsn#" name="insertdata">
    insert into inputtest (#InsertFieldList#)
    values (
    <cfqueryparam value="#InsertValueList#"
    cfsqltype="cf_sql_varchar" list="yes">
    </cfquery>
    </cfloop>
    The test inserts 100,000 records, has spend I 30 minutes
    time,but I have 1,000,000 record to insert , is there any way to
    enhance the insertion speed?
    Thanks a lot.

    By removing ColdFusion from the process as much as possible.
    Where is the 'insertedDB' data coming from? It looks to be a
    record set?
    Are you moving data from one data source to another? If so,
    some DBMS
    have the ability to insert an entire record set in one step.
    I do not
    have the exact syntax at my finger tips, but I have done
    something like
    this in the past with Oracle. INSERT INTO aTable SELECT FROM
    bTable.
    Are you building a record set from a text file such as CSV?
    If so, many
    DBMS have the ability to do 'bulk' inserts from such text
    files and CF
    does not even need to be involved.
    As you can see, knowing exactly what are you working with
    will help us
    provide suggestions an how to improve your process.

  • How to insert records into the Table?

    Dear Sir,
    I'm new to JDeveloper. Now I managed to create a Frame in JDeveloper with many Text fields and a button. In the back end, I have a procedure to insert records to a table, to which I pass the values of the fields as parameters. Now I'm not getting the steps to call the PL/SQL Stored procedure when I click on the button. I'm using Oracle 9i JDeveloper version 9.0.3.1. and Oracle 9i Database.
    Please give me the complete steps to achieve my task - it is quite urgent.
    Thanking You in advance.
    Regards,
    Senthil .A. Perumal.

    The JDBC tutorial will show you how to call a stored procedure from Java:
    http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm
    One more thing, why are you using such an old version of JDeveloper? any reason not to upgrade to the 10.1.3 version of JDeveloper?
    Also you might want to look into ADF and how it makes these type of database interactions easier.
    See this demo:
    http://www.oracle.com/technology/obe/obe1013jdev/adf_swing/master_detail_page_adfswing_bc.htm

  • How can i use BAPI to insert a few records  into standard table

    Can anyone help me with how can i use BAPI to insert some records into a standard table from an internal table?

    Hi,
    First of All try to Explain your Question first.
    This is a general question without mentioning the Table you want to Update.
    Please give the details before posting a question  so it will help people to understand your Problem.
    Regards
    Sandipan

Maybe you are looking for

  • Keyboard q-o and 1-9 don't work

    The top two rows of keys stopped responding on my 3 month old MacBook Air. The keys q through o and 1 through 9 don't

  • Problems with VSS and RoboHelp on second machine

    Hi all, We chose to use Visual Source Safe as our source control tool to use with RoboHelp. To build the VSS database containing the help project on the server, we successfully used the version of our help project on my machine. I have had no problem

  • Third Party Payment in EBS HRMS 11.5.10.2

    Dears, How to set up third party payments in HRMS ? for example I have a payroll element BANK_LOAN_DEDUCTION of type Involuntary Deduction, I want the pay value of this element should be paid to the particular bank Please advise how the issue can be

  • My MBP won't detect a projector even when I reboot the system.

    I can connect to a monitor, so I know the adapter and cable are working, and my old HP will connect to the projector so I know it's not the projector, but my MBP will not even detect that a projector is connected..  I have tried multiple projectors a

  • Worried About My Mini

    "After reading this: Memory available to Mac OS X may vary depending on graphics needs. Minimum graphics memory usage is 80MB, resulting in 432MB of system memory available." I'm getting worried about my upcomming mini. I'm planning to purchase a mac