"Create Table from select Query" Vs "Insert into"

Hi
Schenaio:
My Select Query returns more than 10 million records, these records needs to be inserted into another table.
Approach 1:
I created table called TABLE1, and inserted the records using INSERT statement as a batch (batch size is 5000).
Approach 2:
I create table like,
CREATE TABLE TABLE1 AS <SELECT QUERY>
Here Apporach-1 took almost 40 minutes to complete the insert but Approach-2 took only 6 minutes.
If anybody knows why it is? And is there any way to improve the performance of Approach-1?.
Thanks
Nidhi

Most "batch" methods execute the same query multiple times. Row filtering is done after the rows are fetched from the source. The process of fetching all the rows could be a FullTableScan.
Therefore, a FullTableScan is executed for each batch of 5000 rows.
However, your query and batch definitions may well be different. We haven't seen the query and the execution plan.
Another point : How are you "filtering" the rows (i.e the second execution inserts rows 5001 to 10000 and does not attempt to reinsert rows 1 to 5000) ?
What is the overhead imposed by the filter ? (does the third execution have to exclude rows 1 to 10000 and inserts rows 10001 to 15000 and so on)
Hemant K Chitale

Similar Messages

  • Using select query to insert into a field

    Hi,
    I am working with a jdbc-to-jdbc scenario, in which on source side iam geting data from 2 tables t1 & t2 and inserting this data into two tables tb1 & tb2 on target side.A field in tb2 has to be inserted with a value which is equal to the number of records inserted into the table tb1 i.e with the number equal to 'how many records from the table t1 has been retrieved inorder to insert into table tb1'.
    Can anybody please suggest me.....
    Thanks & Regards,
    Radhika.

    consider ur strucutre
    <Data>
    <id> 1 </id> 0..1
    <id> 2 </id>
    <id> 3 </id>
    <id> 4 </id>
    </Data>
    here i meant context to <id>. Mapping id > count > target will give the nunmber of records in Data i.e. 4
    note: here u have change the context of <id> to <data>
    Message was edited by:
            Prabhu  S

  • Help! Create Table with SDO_RELATE query ignores indexes!

    Hi, I have a SQL statement like:
    select ...
    from a, b where sdo_relate(a.loc,b.loc,'querytype=join mask=anyinteract');
    When I run this as is, it runs quickly, <10 seconds, and doing an expalin on it shows it is using the spatial indexes.
    However if I try:
    create table tabl as <select statement>
    or
    insert into tab1 <select statement>
    then it takes over 30 minutes. Examining the trace file shows:
    Rows Execution Plan
    0 CREATE TABLE STATEMENT GOAL: CHOOSE
    0 LOAD AS SELECT
    0 NESTED LOOPS
    0 TABLE ACCESS (FULL) OF 'AC1'
    0 TABLE ACCESS (FULL) OF 'AC2'
    I've tried using querytype=WINDOW, I've tried optimizer_mode=RULE and CHOOSE, but nothing forces these create/insert statements to work effectively!
    Is this a bug, a documented limitation or is there something I'm missing?
    On Oracle 8.1.7, tried on both Linux and Sun Solaris.
    Thanks,
    Andrew

    Andrew,
    This is a bug in the optimizer and extensible
    indexing for Oracle 8i.
    This is fixed in 9i.
    Sorry, I don't have a better answer for
    this problem.
    null

  • Identify tablspace in create table as select

    I am trying to run a create table as select query that specifies which tablspace to create the table in. When I run the query below I get an error, any ideas?
    create table roi_call_record_backup as (select * from prod.roi_call_record)
    tablespace roi_data01;
    null

    Try this ...
    create table roi_call_record_backup
    tablespace roi_data01
    as
    (select * from prod.roi_call_record)
    null

  • Question on Creating Table From Insert statement

    Hi,
    I want to create a table using a DBlink from another database using the create/insert statement. Will it also transfer the constraints or do I have to do it manually afterwards? Thanks.
    Create table T1
    SELECT a,b,c from T2 from DB@dblink;

    As discussed above, the constraints, indexes, triggers are not copied. Only NOT NULL constraints are copied.
    Look at this thread Re: Copying table structure.
    for copying triggers/indexes from source table to destination table.
    Thanks,
    Navaneeth

  • DB Link Create table as select

    I ve a query which starts with create table as select ..
    When I run the select part of the query, it runs in 2 sec.
    But the whole query runs in 10min. It is fetching data from dblink.
    I think if select can finish in 2 sec. All is left to do is create table and insert.
    Why is takin so long?
    Oracle DB version 9.2.0.8

    When I run the select part of the query, it runs in 2 sec.Does the select finish in 2 seconds or does it start returning rows in 2 seconds?
    Big difference.

  • I am using Photoshop Elements 11.  Do all .jpg formatted file have to be retangular in shape?  I want to create an oval .jpg picture to insert into a book.  Haven't been able to do so.  It would work if I could make the area outside the oval completely tr

    I am using Photoshop Elements 11.  Do all .jpg formatted file have to be retangular in shape?  I want to create an oval .jpg picture to insert into a book.  Haven't been able to do so.  It would work if I could make the area outside the oval completely transparent.  Can anyone help me here?

    JPG does not support transparency, so even if you create an oval with transparent background, the saved JPG will have white background. Instead, save it as a PNG, TIFF, or GIF which preserve the transparency.
    Here is one of many ways to create your oval:
    Create a new file the approximate size of the oval. Add the oval with the Custom Shape Ellipse tool, and simplify the shape layer.
    In the Layers Palette, Ctrl-click the oval to select it and copy the selection to the clipboard (Edit > Copy).
    Then do File > New from Clipboard. This creates the oval with transparent background cropped to the oval size.
    Then save it as one of the file types that support transparency (and also supported by the application where you are sending the picture to).
    Note:  Is is not even necessary to do step 2. That is only if some reason you want the oval to be tightly cropped. It is sufficient to delete the Background layer in step 1 (or turn off its visibility) and save the file. The oval will appear correctly in the book with either version.

  • Create table as select (CTAS)statement is taking very long time.

    Hi All,
    One of my procedure run a create table as select statement every month.
    Usually it finishes in 20 mins. for 6172063 records and 1 hour in 13699067.
    But this time it is taking forever even for 38076 records.
    When I checked all it is doing is CPU usage. No I/O.
    I did a count(*) using the query it brought results fine.
    BUT CTAS keeps going on.
    I'm using Oracle 10.2.0.4 .
    main table temp_ip has 38076
    table nhs_opcs_hier has 26769 records.
    and table nhs_icd10_hier has 49551 records.
    Query is as follows:
    create table analytic_hes.temp_ip_hier as
    select b.*, (select nvl(max(hierarchy), 0)
    from ref_hd.nhs_opcs_hier a
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_PROCEDURE, secondary_procedure_1, secondary_procedure_2,
    secondary_procedure_3, secondary_procedure_4, secondary_procedure_5,
    secondary_procedure_6, secondary_procedure_7, secondary_procedure_8,
    secondary_procedure_9, secondary_procedure_10,
    secondary_procedure_11, secondary_procedure_12)) as hd_procedure_hierarchy,
    (select nvl(max(hierarchy), 0) from ref_hd.nhs_icd10_hier a
    where fiscal_year = b.hd_spell_fiscal_year
    and a.code in
    (primary_diagnosis, secondary_diagnosis_1,
    secondary_diagnosis_2, secondary_diagnosis_3,
    secondary_diagnosis_4, secondary_diagnosis_5,
    secondary_diagnosis_6, secondary_diagnosis_7,
    secondary_diagnosis_8, secondary_diagnosis_9,
    secondary_diagnosis_10, secondary_diagnosis_11,
    secondary_diagnosis_12, secondary_diagnosis_13,
    secondary_diagnosis_14)) as hd_diagnosis_hierarchy
    from analytic_hes.temp_ip b
    Any help would be greatly appreciated

    Hello
    This is a bit of a wild card I think because it's going to require 14 fill scans of the temp_ip table to unpivot the diagnosis and procedure codes, so it's lilkely this will run slower than the original. However, as this is a temporary table, I'm guessing you might have some control over its structure, or at least have the ability to sack it and try something else. If you are able to alter this table structure, you could make the query much simpler and most likely much quicker. I think you need to have a list of procedure codes for the fiscal year and a list of diagnosis codes for the fiscal year. I'm doing that through the big list of UNION ALL statements, but you may have a more efficient way to do it based on the core tables you're populating temp_ip from. Anyway, here it is (as far as I can tell this will do the same job)
    WITH codes AS
    (   SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            primary_PROCEDURE       procedure_code,
            primary_diagnosis       diagnosis_code,
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_1    procedure_code,
            secondary_diagnosis_1    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_2    procedure_code ,
            secondary_diagnosis_2    diagnosis_code     
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_3    procedure_code,
            secondary_diagnosis_3    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_4    procedure_code,
            secondary_diagnosis_4    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_5    procedure_code,
            secondary_diagnosis_5    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_6    procedure_code,
            secondary_diagnosis_6    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_7    procedure_code,
            secondary_diagnosis_7    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_8    procedure_code,
            secondary_diagnosis_8    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_9    procedure_code,
            secondary_diagnosis_9    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_10  procedure_code,
            secondary_diagnosis_10    diagnosis_code
        FROM
            temp_ip
        UNION ALL
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_11  procedure_code,
            secondary_diagnosis_11    diagnosis_code
        FROM
            temp_ip    
        SELECT
            bd.primary_key_column_s,
            hd_spell_fiscal_year,
            secondary_procedure_12  procedure_code,
            secondary_diagnosis_12    diagnosis_code
        FROM
            temp_ip
    ), hd_procedure_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_procedure_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_opcs_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.procedure_code
        GROUP BY
            a.fiscal_year
    ),hd_diagnosis_hierarchy AS
    (   SELECT
            NVL (MAX (a.hierarchy), 0) hd_diagnosis_hierarchy,
            a.fiscal_year
        FROM
            ref_hd.nhs_icd10_hier a,
            codes pc
        WHERE
            a.fiscal_year = pc.hd_spell_fiscal_year
        AND
            a.code = pc.diagnosis_code
        GROUP BY
            a.fiscal_year
    SELECT b.*, a.hd_procedure_hierarchy, c.hd_diagnosis_hierarchy
      FROM analytic_hes.temp_ip b,
           LEFT OUTER JOIN hd_procedure_hierarchy a
              ON (a.fiscal_year = b.hd_spell_fiscal_year)
           LEFT OUTER JOIN hd_diagnosis_hierarchy c
              ON (c.fiscal_year = b.hd_spell_fiscal_year)HTH
    David

  • How to read the data from XML file and insert into oracle DB

    Hi All,
    I have below require ment.
    I will receive data in the XML file. then i need to read that data and insert into oracle tables. please let me know how this can be handled.
    Many Thanks.

    Sounds a lot like this question, only with less details.
    how to read data from XML  variable and insert into table variable
    We can only help if you provide us details to help as we cannot see what you are doing and only know what you tell us.  Plenty of examples abound on the forums that cover the topics you seek as well.

  • Create table from another db

    Basically, I need to create a table from a query that runs against another db on a separate box. Is this possible?
    Thanks

    If you're able to create a database link to the other server you could then use the query(modifying the tables in the from clause to use the dblink) in a create table statement.

  • Hi, extract data from xml file and insert into another exiting xml file

    i am searching code to extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
    1st xml file which has two lines(text1.xml)
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xs:PrintDataRequest xmlns:xs="http://com.unisys.com/Anid"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
    <xs:Person>
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://com.unisys.com/Anid file:ANIDWS.xsd">
    These two lines has to be inserted in the existing another xml(text 2.xml) file(at line 3 and 4)
    Regards,
    bubbly

    Jadz_Core wrote:
    RandomAccessFile? If you know where you want to insert it.Are you sure about this? If using this, the receiving file would have to have bytes inserted that exactly match the number of bytes replaced. I'm thinking that you'll likely have to stream through the second XML with a SAX parser and copy information (or insert new information) as you stream with an XML writer of some sort.

  • Extract data from xml file and insert into another exiting xml fil

    hello,
    i am searching extract data from xml file and insert into another exiting xml file by a java program. I understood it is easy to extract data from a xml file, and how ever without creating another xml file. We want to insert the extracted data into another exiting xml file. Suggestions?
    Regards,
    Zhuozhi

    If the files are small, you can load the target file in a DOM document, insert the data from the source file and persist the DOM.
    If the files are large, you probably want to use a StAX or SAX.

  • Is it possible to copy tables from another application or excel into forms

    I wasnt to insert tables from another application or excel into forms. currently it copies over the information from the table but doesnt keep it in a table format? Is it possible to do this?

    Dear try67
    I just forwarded him to a page (by Adobe Expert) where I had hoped this will help him.
    It could also be your side.
    I don't think that it took a comment from another. Unless it is a personal good advice. I just wanted to help and free of charge
    Sometimes we overlook a detail by quick reading. Is this never happened to you ?

  • Message:execute non-query failure(insert into EDCSESSIONSTOREENTITY

    Hi , my error is
    Adobe Reader Extensions ES2
    ERROR.....
    [com.adobe.idp.common.errors.exception.IDPLoggedException] UserM:GENERIC_WARNING: [Thread Hashcode: 975924454] com.adobe.idp.common.errors.exception.IDPLoggedException| [com.adobe.idp.storeprovider.jdbc.DBStatement] errorCode:12290 errorCodeHEX:0x3002 message:execute non-query failure(insert into EDCSESSIONSTOREENTITY ( id , sequencenumber , renewalcount , sessiondata , sessionendtime) values(?, ?, ?, ?, ?)) chainedException:java.sql.SQLException: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'chainedExceptionMessage:Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' chainedException trace:java.sql.SQLException: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'.
    why????

    Hello,
    Theproblem seems to be with isolation level, the below post may help here.
    https://confluence.atlassian.com/pages/viewpage.action?pageId=251724630
    -Vijay

Maybe you are looking for

  • Tabular form validation(Checkbox) is not working for Interactive report

    Hi, I am using the oracle apex 4.0 and oracle 11g. I have written a below select query on interactive report as select apex_item.checkbox(1,RESIDD)||apex_item.hidden(2,RESIDD) row_selector, apex_item.text(3,RESNUM) as resnum from "PDRRES" and written

  • How can i speak to an iTunes tech person immediately 24/7

    I purchased a new iMac desktop a few days ago and have been spending countless hours figuring everything out.  I just tried to purchase an app on app store.  Entered apple id, password....all good.  Then it asked for answers to security questions fro

  • How to remove duplicate emails in Mail

    Does anyone know if a good app that works in Lion that will help me remove duplicate emails in Mail?  There are some options on the web that I've found but they don't seem to work with Lion.

  • How To Restore Windows XP BKF File in Windows 8

    Hi Friends, I have purchased new laptop with newest Windows 8 operating system. Furthermore, I want to restore my all Windows backup file in windows 8 but I don't know any software that transfer BKF file in new windows 8 OS.  If anyone has know about

  • Hi, bought Photoshop Elements 5.0 (money problems) its windows version need mac?

    Help, bought the windows version by mistake or didn't notice ... anyway, I have a Mac and not enough money to buy anything else right now, can anyone help get a Mac version running.  Would really appreciate any help!!!