Best way to parallelize ddl statements

The short story:
We have a file of ddl statements (output from datapump metadata_only) that we want to run in parallel as fast as possible. We have paresh working pretty well, but for large files, it goes rather slow. We have been working on a procedure to read the file in as an external table with really good results.
What we have now is the external table with some additional columns that identify the ddl (owner, object_name, statement type, an order id based on statement type, a unique statement id). The idea is that we want to do all the Primary Keys first, then normal indexes, followed by foreign keys and index/table stats. Right now, I grab the next statement and mark all statements for that object_name so that no other worker processes can work on that object (reduces contention). Unfortunately, we have introduced contention on the external table (doing a select .. for update). I can think of a couple ideas to try, but wondering if any experts out there had a slick way of accomplishing this.
Feel free to ask questions. I do not think it matters, but we are working with an export from 10.2.0.2, import into 10.2.0.3.
Here is a snippet of the current code:
   -- c2 Fetches the next sql statement to be worked on. To reduce contention,
   -- we avoid working on objects that are currently INPROGRESS. The objects
   -- are also ordered such that we work on Primary keys first, then normal indexes,
   -- with foreign keys and statistics last.
   -- The "FOR UPDATE" will keep the records locked until the transaction is committed,
   -- thereby guaranteeing that we are only working on one object at a time.
   CURSOR c2 is
    SELECT p1.STMNT_ID, p1.object_name
      FROM ORACLE.PARESH_SQL_STMNT p1
      WHERE p1.STATUS ='READY'
       and p1.ORDER_PREF > 0
       -- and p1.object_type is not null
       and p1.STMNT_ID||p1.object_name = (
         SELECT max(STMNT_ID||object_name) keep (dense_rank first order by order_pref, stmnt_id)
           FROM ORACLE.PARESH_SQL_STMNT
           WHERE STATUS ='READY'
            and ORDER_PREF > 0
            -- and object_type is not null
    for update of p1.object_name;
BEGIN
  i_status:='';
  open c2;
  -- fetch only one row (highest order_pref)
  fetch c2 into l_stmnt_id, l_object_name;
  -- Set the status INPROGRESS so no other statements for this object are run
  update oracle.paresh_sql_stmnt
  set status='INPROGRESS'
  where object_name=l_object_name
  and status='READY';
  close c2;
  commit;

I would look at an o/s based solution and not PL/SQL (but SQL*Plus).
I would make it generic as the basic idea is to give a process a table-to-go and have it do the end-to-end steps for you.. and then run multiple of these in parallel.
The process can be a shell script (Linux/bash - sorry, I am very biased ;-) ). It uses the data dictionary to determine the indexes, constraints and triggers and what not that needs to be DDL'ed. It runs DBMS_METADATA via a SQL*Plus script to create the DDLs.
It only applies the create DDL to the destination. Next it creates a FIFO pipe. It starts SQL*Loader (parallel/direct/whatever options being fancied) on this pipe as a background process.
With SQL*Loader hungrily waiting for data, the process fires up SQL*Plus again, set array size large, etc - and run a SELECT on the source table. It does not use SQL*Plus' spool feature. It has SQL*Plus writing the data it is fetching direct to STDOUT.
However, when the process started SQL*Plus, it redirected STDOUT to the FIFO pipe.
A block is written by SQL*Plus into the pipe. That same block is then read by SQL*Loader and loaded into the destination database.
Reading and writing essentially are thus basically done in parallel - and not serial. Once the SQL*Plus completed unloading the data into the pipe, the rest of the DDLs are applied - indexes created, etc. (constraints created as disabled of course - these will need to be enabled all over the destination database after all the load processes have completed)
And as mentioned, I will have multiple of the scripts running, one per table to process.
Many years ago, I did exactly this. Only a tad more complex. Went something like this. Process unloads data into a pipe. Compression process read that pipe and write compress/zipped data into a "compression" pipe. FTP process reads that pipe, sends the compressed data across the network, where the FTP server writes in into yet another pipe. There a decompression process reads the ftp pipe, unzips the data, and write the decompressed data into a "decompression" pipe. Where SQL*Loader does the rest - reading the now unzipped data and chucking it into the database.
It work pretty well. And fast. Faster than any commercial ELT tool that 3rd party vendors tried to sell me to "do the job". :-)

Similar Messages

  • Hi just want to know where is the best way to type the statement?

    just to ask you what is the best way to write the statement please

    Could you please explain what the topic and statement is about?
    Helps to narrow the focus, down to a specific hardware or software
    question pertaining to the Apple products involved, where applicable.
    Basic word processing can be accomplished in TextEdit, if you do
    not have Pages or any other software to write with, for example.
    Yet, there is no indication of the purpose, direction, or problem.
    Good luck & happy computing!

  • How is the best way to manage the stats table?

    Hello!
    I have the Integration 2.1 working with an Oracle 8.1.7 db. I noticed that the table
    STATS is growing pretty fast.
    How is the best way to manage this table?... I haven't found something related with
    this issue in the documentation, but at least I want to know how to safely delete
    records from this table.
    For example, if I know the minimal time I have to keep in the table, is quite simple
    to create a shell script and/or Oracle pl/sql job to trim the table.
    I hope somebody can help me!!!!
    Thank you!
    Ulises Sandoval

    Write an app people want to buy and rate highly.

  • Best way to write SELECT statement

    Hi,
    I am selecting fields from one table, and need to use two fields on that table to look up additional fields in two other tables.
    I do not want to use a VIEW to do this. 
    I need to keep all records in the original selection, yet I've been told that it's not good practice to use LEFT OUTER joins.  What I really need to do is multiple LEFT OUTER joins.
    What is the best way to write this?  Please reply with actual code.
    I could use 3 internal tables, where the second 2 use "FOR ALL ENTRIES" to obtain the additional data.  But then how do I append the 2 internal tables back to the first?  I've been told it's bad practice to use nested loops as well.
    Thanks.

    Hi,
    in your case having 2 internal table to update the one internal tables.
    do the following steps:
    *get the records from tables
    sort: itab1 by key field,  "Sorting by key is very important
          itab2 by key field.  "Same key which is used for where condition is used here
    loop at itab1 into wa_tab1.
      read itab2 into wa_tab2     " This sets the sy-tabix
           with key key field = wa_tab1-key field
           binary search.
      if sy-subrc = 0.              "Does not enter the inner loop
        v_kna1_index = sy-tabix.
        loop at itab2 into wa_tab2 from v_kna1_index. "Avoiding Where clause
          if wa_tab2-keyfield <> wa_tab1-key field.  "This checks whether to exit out of loop
            exit.
          endif.
    ****** Your Actual logic within inner loop ******
       endloop. "itab2 Loop
      endif.
    endloop.  " itab1 Loop
    Refer the link also you can get idea about the Parallel Cursor - Loop Processing.
    http://wiki.sdn.sap.com/wiki/display/Snippets/CopyofABAPCodeforParallelCursor-Loop+Processing
    Regards,
    Dhina..

  • Best way to do state machine transitions?

    I have a 7-state state machine that uses an enum case statement to go from state to state. The first state INTIALIZE has only two transitions. This is easily solved by using the Select VI to output either IDLE or ERROR as the next state depending on if an error occurs or not. My qustion to you is what is the best way to accomodate a state that has 3 or more possible tranistions? For example, the IDLE state can go back to itself or to either the RUN or STOP states. Since I now have 3 possible transitions the Select VI is no longer useful.
    The next state logic is dependant on two boolean controls, namely GO and HALT. If HALT is true, go to the STOP state. If HALT is false and GO is true, go to the RUN state. And if both
    HALT and GO are false, go back to the IDLE state.
    My idea was to create a formula node, and have HALT and GO be the two inputs. This is when I noticed I couldn't use booleans as inputs to a formula node (not sure why) but this was easily fixed by using the boolean->0:1 conversion. Also since I cannot have an enum be an ouput, I would assign the value 0,1,or 2 to the output depending on the (now numerical) values of HALT and GO. I would then use the output as the index to the "Index Array" VI which would have a 3-element enum array connected to it; the three elements being IDLE, RUN, STOP. Am I on the right path or am I missing some real easy way to do this? Thanks

    SiegeX wrote:
    > I have a 7-state state machine that uses an enum case statement to go
    > from state to state. The first state INTIALIZE has only two
    > transitions. This is easily solved by using the Select VI to output
    > either IDLE or ERROR as the next state depending on if an error occurs
    > or not. My qustion to you is what is the best way to accomodate a
    > state that has 3 or more possible tranistions? For example, the IDLE
    > state can go back to itself or to either the RUN or STOP states. Since
    > I now have 3 possible transitions the Select VI is no longer useful.
    >
    > The next state logic is dependant on two boolean controls, namely GO
    > and HALT. If HALT is true, go to the STOP state. If HALT is false and
    > GO is true, go to the RUN state. And if both HALT and GO are false, go
    > back to the IDLE state.
    >
    > My idea was to create a formula node, and have HALT and GO be the two
    > inputs. This is when I noticed I couldn't use booleans as inputs to a
    > formula node (not sure why) but this was easily fixed by using the
    > boolean->0:1 conversion. Also since I cannot have an enum be an ouput,
    > I would assign the value 0,1,or 2 to the output depending on the (now
    > numerical) values of HALT and GO. I would then use the output as the
    > index to the "Index Array" VI which would have a 3-element enum array
    > connected to it; the three elements being IDLE, RUN, STOP. Am I on
    > the right path or am I missing some real easy way to do this? Thanks
    The State Machine Toolkit generates a state machine framework that has a
    case statement inside a while loop for each state's transistion test.
    The case statement is indexed by the while loop interation counter, so
    the most important tests for state transistion are programmed into the
    lower numbered cases. A positive test frame will stop the while loop and
    output the next step of the state machine. The last frame of the case
    statement is the default and will always stop the while loop though it
    is up to you to decide what a default state transistion is. Someday
    hopefully, they will role the State Machine Toolkit into the full
    development release of LabVIEW.

  • DDL statements and dynamic  sql  in stored procedure

    I created a stored procedure to create and drop tables, using dynamic sql.
    When I try to do the inserts using dynamic sql, i.e
    v_string := 'INSERT statement';
    EXECUTE IMMEDIATE v_string;
    I get the following error message:
    ERROR at line 1:
    ORA-00942: table or view does not exist
    ORA-06512: at line 63
    Line 63 happens to be the line that the EXECUTE IMMEDIATE v_string; statement is in.
    I am able to describe the table that the inserts are being made into, so I know that the table exists.
    Any idea why I'm getting this error message would be appreciated.

    Yes I do and I have been able to create other tables using dynamic sql.
    The table that I am having problems with SELECTs data from another table to get its column values; within the SELECT statement, the CAST function is used:
    ie. CAST(CASE SUBSTR(CAST(E_MOD AS VARCHAR(7)),2,3)
    WHEN 'AAA' THEN 'A55'
    ELSE ............
    I get the following error message:
    ERROR at line 18: (this line starts the CAST statement)
    ORA-06550: line 18, column 13:
    PLS-00103: Encountered the symbol "AAA" when expecting one of the following:
    . ( * @ % & = - + ; < / > at in is mod not rem return
    returning <an exponent (**)> <> or != or ~= >= <= <> and or
    like between into using || bulk
    When I remove the quotes or add another single quote, the same error cascades to 'A55'.
    After doing the same for the next error, I get the error message below:
    ERROR at line 1: (this line has the EXECUTE IMMEDIATE statement)
    ORA-00936: missing expression
    ORA-06512: at line 6
    Any idea what the problem could be?
    Also is there another way to have DDL statements as stored procedures other than using dynamic sql or the DBMS_SQL package?

  • What is the best way to partitioning Macbook Air 13" 2012 solid state drive

    What is the best way to partitioning Macbook Air 13" 2012 solid state drive.

    Tech,
    You don't provide enough information onto which anyone could reasonably formulate an answer.
    As mentioned, you don't indicate the circumstances that would warrant consideration of multiple partitions. Moreover, you also don't indoicate the size of the SSD in question.
    Like Fred said, ordinarily you leave it alone as one. Some people like to keep data and the OS/apps separate, but it is for specific reasons.

  • Best way to give tablename in create table statement

    hi all,
    what's the best way to give table name while "create statement" in case of performance.. 
    for eg:
    create table tablename(id int,name varchar(20))
    a.) tablename
    b.) [tablename]
    c.) (tablename)
    d.) "tablename"
    pls its urgent..
    thanks in advance..
    lucky

    >b.) [tablename]
    As Naomi pointed it out, the above is dangerous because unintentionally special characters or space can be included and accepted by SQL Server.
    Once you introduce special characters in the table name, you have to use [....] forever.
    Related QUOTENAME:
    http://technet.microsoft.com/en-us/library/ms176114.aspx
    a is the best choice.
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • The best way to do paging and get total rows count given a sql statement

    Hi,
    Just got a quick question.... what is the best way to do paging as well as the total rows count given by a sql statement.
    e.g. "select * from emp"
    1. I need to know the total row count for this statement.
    2. I also need to do a 10 rows per page....
    Is there a way to do it in a SINGLE statement for best performance?
    Thanks experts.

    Sounds more like a "formatting" problem...
    If Sql*plus is your reporting tool, check out the guide:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a90842/toc.htm

  • What is the best way to maintain state in Java web apps?

    Hi,
    been looking at best way to maintain state between requests in JSP.
    Ive been trying to use URL rewriting but been getting problems. I understand I can also achieve this using cookies.
    Are there any other better ways of doing this.
    I don�t know if the problem is with JBuilder4 or something in the Tomcat server?
    Any suggestions would be appreciated.
    thanks.

    I think if you use JavaBeans that implements Serializable , it might maintain state (but not sure of this).
    HttpSession is one option but , sessions have limitations - they timeout, they don't work when the page is cached by the browser and they don't work if Cookies are disabled in the browser.
    Database is always an option, and there are two types of DBs , in-memory like HSQLDB etc , or the regular RDBMS like MySQL , Oracle etc.
    If you only want to maintain state between HttpRequests, then use the request object which is implicit in JSPs.
    I think your URL Encoding is not working most likely because you have disabled Cookies in your browser and that's why you see jsessionid.
    If you enable Cookies in your browser then, the jsessionid should not appear.
    There are other options I'm sure, but I'm only aware of the above at this time.... may be someone else might know more.

  • Best way to get switch/router interface stats remotely and periodically

    Team:
    I am not sure if this is really needed; however, I am looking at methods or solutions that I can get interfaces stats from my switches and routers. Looking for errors: CRC, Frame, Overruns, Collisions, etc; however, I am not sure the best way to do this on my devices.
    Currently looking into Expect; however, I do not see away that I can save the output of the ‘show interface’ command to a file, clear the counters, and upload the interface stats to a tftp site. The idea was to use a cron job and ‘grep’ to dig though the files once on my server, but again, I am not sure I can do this.
    I am looking for suggestions on how I can do this, or something similar, or even a better solution.
    Thanks
    JJ

    Hi John,
    Thanks for the insight. I am currently learning Python, which is slow going, but I am pushing through. This is production, and last Friday I did a router and switch count. It will be over 200 devices distributed globally. In addition, these resources/devices are linked to as many different circuit types. The business is small, and I cannot get the budget for Solarwinds, so I was trying to be creative. I looked into Python, but I am just learning, yet I have started with the Apress ‘Beginning Python’ by Hetland, so the skill set is not there YET.

  • Best way to use OR in a select statement

    HIya,
    I have  list of G/L accounts(HKONT) that I want to get some fields for and just wanted to ask what the best way to do that would be...
    I was thinking of doing this:
    SELECT dmbtr shkzg hkont prctr FROM bseg
    INTO table itab_bseg
    WHERE  bukrs  = it_vbap-bukrs2
    AND    belnr  = it_vbap-belnr2
    AND    gjahr  = it_vbap-gjahr2
    AND    prctr  = it_vbap-prctr
    AND   ( hkont  =  '0000310010' or hkont  = '0000310011' or hkont  = '0000310012' or hkont  = '0000310013').
    But then I read about range tables and I thought maybe I should add the g/l accounts to a range table and then use that in my select?
    Would anyone have any useful advice/guidance?
    Thanks in advance!

    Dear Robert,
    You can use the below query also
    SELECT dmbtr shkzg hkont prctr FROM bseg
    INTO table itab_bseg
    WHERE  bukrs  = it_vbap-bukrs2
    AND    belnr  = it_vbap-belnr2
    AND    gjahr  = it_vbap-gjahr2
    AND    prctr  = it_vbap-prctr
    AND   hkont  in ( '0000310010' , '0000310011' , '0000310012' , '0000310013').
    and create range table for HKONT.
    data lr_range type range of HKONT.
    data ls_Range like line of lr_range.
    ls_range-low = '0000310010' .
    ls_range-sign = 'I'.
    ls_range-option = 'EQ'.
    append ls_Range to lr_range.
    pass all the value one by one.
    and use the same in select.
    Thanks and Regards,
    Nishant bansal

  • Best way to run about 200,000 update statements?

    Just throw them all in SSMS all at once? That doesn't seem like the best way especially since something may fail part way through. What would you suggest? Do it in code?

    Some samples:
    update XC01_CLME_MEMBER set CLME_LAST_NAME='BRAINARD' where RUN_DATE_KEY=287 and CLMS_CLCL_KEY=483584 and CLME_LAST_NAME = 'OFTEDAHL'
    update XC01_CLME_MEMBER set CLME_LAST_NAME='BRAINARD' where RUN_DATE_KEY=297 and CLMS_CLCL_KEY=796073 and CLME_LAST_NAME = 'OFTEDAHL'
    update XC01_CLME_MEMBER set CLME_LAST_NAME='BRAINARD' where RUN_DATE_KEY=297 and CLMS_CLCL_KEY=796074 and CLME_LAST_NAME = 'OFTEDAHL'
    update XC01_CLCL_CLAIM set MEME_CK=6652504 where RUN_DATE_KEY=461 and CLMS_CLCL_KEY=1645516 and MEME_CK = 6652503
    update XC01_CLCL_CLAIM set MEME_CK=6652504 where RUN_DATE_KEY=461 and CLMS_CLCL_KEY=1645517 and MEME_CK = 6652503
    update XC01_CLCL_CLAIM set MEME_CK=6652504 where RUN_DATE_KEY=461 and CLMS_CLCL_KEY=1645518 and MEME_CK = 6652503
    update XC01_CLCL_CLAIM set MEME_CK=6652502 where RUN_DATE_KEY=921 and CLMS_CLCL_KEY=2413143 and MEME_CK = 6652503
    update XC01_CLCL_CLAIM set MEME_CK=3334351 where RUN_DATE_KEY=297 and CLMS_CLCL_KEY=819206 and MEME_CK = 3334352

  • Best way to remove apostrophe from string when loadiing

    Hi using an insert statement to load data some apostrophe's in string .
    We need to ensure all aposrophe's removed from such strings on loading/.
    What is best way to achive ethis.
    Uisng 11.2.0.3
    Thanks

    Use replace fucntion
    Please post ur DDL and DML for the table
    For examples you can see this
    how do i replace  single quotes in a string with say  ''  or null
    select replace('ab''''''''cd','''',' ') from dual;
    CREATE TABLE my_table
         istrng  varchar2(33)
    insert into my_table
    select replace('ab''''''''cd','''',' ') from dual;Please mark your questions as answered
          user5716448     
    Handle:      user5716448 
    Status Level:      Newbie
    Registered:      Mar 16, 2010
    Total Posts:      343
    Total Questions:      131 (80 unresolved)Edited by: Rahul India on Jan 29, 2013 6:04 PM

  • Best way to transfer application from Test Environment to Dev. Environment

    Hi All,
    We are try to create an application on Hosted Environment similar to www.apex.oracle.com.
    We got two work space
    1. app_production
    2. app_test
    My application will have 200+ tables and many other supporting object.
    My question is in hosted environment what is the best way to copy application from test to production environment (P.S In hosted environment I can uses SQL Developer / TOAD or any other tool .. its similar to www.apex.oracle.com)
    With my present workaround I have to use
    Go to Utilites -> Generate DLL
    and then export this and application..
    The main problem is 200+ table and associated structures .. its very difficult to keep track ...
    Can anyone suggest me any good way for HOSTED ENVIRONMENT

    Hi,
    Just an idea:
    1 - Do a DDL export of the source env
    2 - Do a DDL export of the target env
    3 - Use some tool to compare those files and highlight the differences. There are even some tools that are smart enough to generate SQL statements to apply the differences in the target env.
    I hope this helps.
    Luis

Maybe you are looking for

  • FAILED: Solid State Hard Drive

    So bummed I've had the computer a year and just out of warantee.  I remember getting errors form the computer just after I got it but, my daughter was about to have a hemispherectomy (1/2 brain removed due to seizures) I hadn't had the time to get th

  • KM Document iview not working properly...

    Hi, I am in EP6SP2 P4HF8 for Portal and KM. Based on my user requirment, I need to link a document from KM directly to my detail Navigation under my Portal roles. I have done the following. 1) Create a KM Document iview. 2) Gave the KM Document path

  • Final Cut Express Manual printing issue

    Hi I'm recently purchased an IMac and don't have a lot of experience with the Apple operating system and Apple products. So if this question is more appropriate to another forum, please don't get mad. I want to start using Final Cut Express. The Help

  • Time delay for Images

    I'm full of questions tonight -- I was also wondering is there an application or code that allows you to time delay images, text or music? I would like to upload, let's say 4 images that rotate with the time (based on whatever clock I set) - i.e. sun

  • Definition for job ZACU_MC_MATNR_MODEL1 is incomplete. Job cannot be releas

    Hello Friends, When I checking the status in SM37, my job is remain sheduled. It is not getting finished. On selecting job, when I click on spool, I receive a error message. Definition for job ZACU_MC_MATNR_MODEL1 is incomplete. Job cannot be release