Happening to have a mod-perl enabled Apache 2 handy, I tried the following script:

#! x:/xampp/perl/bin/perl.exe use strict; use DBI; use CGI qw/:standard/; use Benchmark qw/timethese/; my $dbh=DBI->connect("DBI:mysql:pandirecords",); my $cgi = new CGI; print $cgi->header; print $cgi->start_html('DBI & mod-perl'); print '<pre>'; timethese( 10000, { inline => 'xinline', bind => 'xbind', }); print '</pre>'; print end_html; sub xbind { my $parameter='0000284364'; my $sql = 'SELECT insured_name FROM claims WHERE ref_underwriter = ?' +; my $sth = $dbh->prepare( $sql ); $sth->execute( $parameter ); my @res = $sth->fetchrow_array; } sub xinline { my $parameter='0000284364'; my $sql = 'SELECT insured_name FROM claims WHERE ref_underwriter ="' +. $parameter .'"'; my $sth = $dbh->prepare( $sql ); $sth->execute; my @res = $sth->fetchrow_array; }

It had the following result:

cgi-bin Benchmark: timing 10000 iterations of bind, inline... bind: 7 wallclock secs ( 2.56 usr + 0.65 sys = 3.21 CPU) @ 31 +12.36/s (n=10000) inline: 7 wallclock secs ( 2.60 usr + 0.50 sys = 3.11 CPU) @ 32 +20.61/s (n=10000)

and

mod-perl Benchmark: timing 10000 iterations of bind, inline... bind: 7 wallclock secs ( 3.02 usr + 0.61 sys = 3.63 CPU) @ 27 +51.03/s (n=10000) inline: 8 wallclock secs ( 3.10 usr + 0.62 sys = 3.72 CPU) @ 26 +91.07/s (n=10000)

The results are a bit unexpected in that the mod-perl script seems to run a bit slower than the cgi-bin script. I guess this is due to the fact that both the browser, Apache and MySQL were running on the same machine and that the major part of the time was anyhow spent in fetching the records, rather than executing the perl-script.

Anyhow, I could not find any significant slowdown between the 'bind' and the 'inline' version of the script, so I must conclude that the huge difference you found must come from somewhere else.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


In reply to Re: mod_perl was hosed by a bind variable by CountZero
in thread mod_perl was hosed by a bind variable by phildog

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.