in reply to mod_perl was hosed by a bind variable
#! 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: mod_perl was hosed by a bind variable
by dws (Chancellor) on Jan 31, 2004 at 02:41 UTC | |
by CountZero (Bishop) on Jan 31, 2004 at 08:16 UTC | |
|
Re: Re: mod_perl was hosed by a bind variable
by CountZero (Bishop) on Jan 31, 2004 at 08:09 UTC |