I would second the advice in the previous reply: you're better off sticking with a simple prepared statement with suitable placeholders to insert one row per execution, and just execute the statement in a loop over the rows of data to be inserted.

If you're worried about the relative overhead of many execution calls (one row at a time) versus one execution call (with many rows at once), bear in mind that if you turn off auto_commit, and explicitly commit after all the row executions have been done, there shouldn't be any serious difference in run-time, relative to doing many rows in one execute call.

I could be wrong about that - I've never tried a multi-row insert via DBI, so I haven't had occasion to benchmark it. But I do know that when doing lots of single-row executions (for inserts or updates), it can make a BIG difference (orders of magnitude) if you commit just once at the end -- or, if you're doing 10's or 100's of thousands of row inserts, do a commit every few thousand rows, just to keep the transaction size from getting out of hand.


In reply to Re: Proper Syntax for DBI multiple row insert by graff
in thread Proper Syntax for DBI multiple row insert by Rodster001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.