• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Reply to: Slow Insert

Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Slow Insert"

Collapse

  • SallyAnne
    replied
    Originally posted by Ivor1
    Hi,

    Got a Oracle proc that just selects 50 rows and inserts them into a table. If I run the SQL manually the select takes 30secs and the insert takes 5 secs. The select uses a DB link.

    If I run the same SQL as a procedure I can see it doing the select but then its sits there for 12hrs to do the insert (I left it overnight).

    No locks on the table, nothing waiting to commit. In Toad I can see it shows it waiting for a response from the DB link, but its done the select so doesnt need anything else via the DB link. Seems to be db link related,
    If you send your procedure through I'll have a look at it? It might be something stupid in the procedure that you just cant see anymore.

    Leave a comment:


  • TheMonkey
    replied
    Originally posted by DimPrawn
    Upgrade to Microsoft SQL Server or something else that actually works.

    HTH

    Yeah even MySQL 3 was better than that.

    I remember having to patch Oracle on a Solaris machine once. God that was painful.

    Leave a comment:


  • DimPrawn
    replied
    Upgrade to Microsoft SQL Server or something else that actually works.

    HTH

    Leave a comment:


  • Ivor1
    replied
    Tried the APPEND before and no luck, needed quick fix so created table on the fly in the proc and now dont have the problem

    Leave a comment:


  • EqualOpportunities
    replied
    Originally posted by Ivor1
    To big to get on here, the difference is though as soon as I add the INSERT INTO, I see the following on the explain plan, also other changes.

    Operation Rows Cost
    INSERT STATEMENT optimizer Mode=CHOOSE 12k 27M

    What I dont understand is how a INSERT can change the plan totally.

    Ahh **** it Im going to lunch
    It is, clearly, to do with the table you are inserting into - I don't know what without looking more closely. Try doing your INSERT with the APPEND hint - that'll most likely speed it up.

    Leave a comment:


  • Ivor1
    replied
    To big to get on here, the difference is though as soon as I add the INSERT INTO, I see the following on the explain plan, also other changes.

    Operation Rows Cost
    INSERT STATEMENT optimizer Mode=CHOOSE 12k 27M

    What I dont understand is how a INSERT can change the plan totally.

    Ahh **** it Im going to lunch
    Last edited by Ivor1; 14 November 2006, 12:40.

    Leave a comment:


  • EqualOpportunities
    replied
    Originally posted by Ivor1
    The table being inserted into is empty, for some reason adding the INSERT INTO totally changes the explain plan from something that takes 2mins to run to 12hrs. Ive analysied the indexes, the tables on the source tables etc but its defo the INSERT statement that causes the problem. Its sods law as some of my daily inserts are millions of rows in one batch they run fine, yet when I want to insert 50 rows it has a fecking paddy.
    If you want to send over the two explain plans, and anything else pertinent, I can tell you what's going on...

    Leave a comment:


  • Ivor1
    replied
    The table being inserted into is empty, for some reason adding the INSERT INTO totally changes the explain plan from something that takes 2mins to run to 12hrs. Ive analysied the indexes, the tables on the source tables etc but its defo the INSERT statement that causes the problem. Its sods law as some of my daily inserts are millions of rows in one batch they run fine, yet when I want to insert 50 rows it has a fecking paddy.

    Leave a comment:


  • Spacecadet
    replied
    how big are the tables?

    DBlinks can be a pain, typically whats happening in your case is that the server running the query will be importing the entire contents of the destination table to run the query on.

    Probably a lot quick to force it to run one insert at a time using the actual values (ie use dynamic SQL) instead of doing the insert into... select from... as i guess you're trying to do.

    Leave a comment:


  • Ivor1
    started a topic Slow Insert

    Slow Insert

    Hi,

    Got a Oracle proc that just selects 50 rows and inserts them into a table. If I run the SQL manually the select takes 30secs and the insert takes 5 secs. The select uses a DB link.

    If I run the same SQL as a procedure I can see it doing the select but then its sits there for 12hrs to do the insert (I left it overnight).

    No locks on the table, nothing waiting to commit. In Toad I can see it shows it waiting for a response from the DB link, but its done the select so doesnt need anything else via the DB link. Seems to be db link related,

Working...
X