Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Fork a new process for inserting a record in DB (Oracle)

by sundialsvc4 (Monsignor)
on Nov 07, 2013 at 14:30 UTC ( #1061589=note: print w/ replies, xml ) Need Help??


in reply to Fork a new process for inserting a record in DB (Oracle)

I cordially advise that you are going about this the wrong way ... that “parallel tasks/threads” will not make things go faster, but substantially slower.   You should be using the bulk-loading tool that Oracle provides for this purpose, since it is optimized to do exactly this.

If you find that for whatever reason you do need to load large amounts of data into an SQL database (of any sort) by conventional means, there are several things that I suggest you consider:

  1. Parallelism is probably not your friend, probably will not help, because it just makes more work for the SQL engine at the other end of the wire.
  2. You must do the work within a transaction, and you should carefully choose that transaction’s “isolation level.”   (This sort of work needs to push other concurrent work aside as much as possible, through an aggressive choice of isolation level, which is why it is often done in the wee hours...)   Post a few thousand records, say, then commit, then open up another one.   (This will allow the database to do “lazy writing.”)   prepare the statement-handle, with placeholders, and use it repeatedly.
  3. Consider how the process can be made restartable.   Once you have successfully committed, record where you are in the input-file so that you could potentially restart at that checkpoint if the program should unexpec...   ;-)

But, once again, there are “bulk loader” programs that are specifically designed to do this.


Comment on Re: Fork a new process for inserting a record in DB (Oracle)
Re^2: Fork a new process for inserting a record in DB (Oracle)
by monx (Novice) on Nov 07, 2013 at 16:20 UTC
    I'd look into what these two guys said above...
    To avoid changing your code too much, just do all your data preparation as you currently do, but rather than executing the resutling INSERT SQL through the handle, append it to a file(s) or print it to STDOUT (and redirect it to a file) then push the resulting SQL files to your DB's buck loader.

    Hope that gives you some ideas...

      "then push the resulting SQL files to your DB's buck loader."

      A minor point, bulk loaders don't take sql files as input. They load text formatted files, for example CSV.

        Thanks for pointing that symantic out, I agree, however there are loaders I've used in Sybase that process SQL files and they are optimized by the DB's manufacturer to handle "large loads"
      Thanx monx... This will definitely help me to tackle my situation.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061589]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-07-13 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (248 votes), past polls