Like perrin I very much doubt that batching your requests is really going to improve things for the MS-SQL side of things.

You are using placeholders, which with MS-SQL means that only the data for each parameter is actually sent for each execute. The number of replies from the database server will always be the same whether you send a bunch of inserts as a single buffer or not as at the protocol level you'll get one reply for each inserted row.

For MySql the situation may be a little bit different as I believe that DBD::MySQL emulates placeholders (that is it does the equivalent of interpolating the values in the SQL string before sending it to the server for each row).
But I don't really know MySQL - so I don't know if there is a way around that.

Finally - when you say that DBD::MySQL dies on multiple statements separated by ';' then that is perfectly normal. What you have to realize is that SQL clients that use the ; character to separate SQL commands in reality send each command to the server separately, essentially doing something like

@cmds = split(/;/, $sql); # yes I know - that regexp won't do the ri +ght thing! foreach (@cmds) { $sth = $dbh->prepare($_); $sth->execute; etc... }

Hopefully this little explanation will help :-)

Michael


In reply to Re: Batch DB query -- implementation? by mpeppler
in thread Batch DB query -- implementation? by zaimoni

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.