rbuckner has asked for the wisdom of the Perl Monks concerning the following question:
Ran some test and it takes almost 2 min to execute the loop 4 times. I rewrote the script and prepared the statement inside the loop by concatenating a string with variable values. e.g.my $sth = $dbh->prepare("select ... where fld1 = ? and fld2 = ? and fld3 = ?"); for ($i=0; $i<800; $i++0){ ... $sth->execute($var2, $var2, $var4); ... }
Same loop executes in less than 10 seconds. All the documentation I can find says the placeholder code should be more efficient and run faster than the concatenated code. Any idea what's going on?for ($i=0; $i<800; $i++){ ... my $sql = "select ... where fld1=" . $var1 . " and fld2=" .$var2 . " and fld3=" . $var3; my $sth=$dbh->prepare($sql); $sth->execute(); ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI placeholders less efficient?
by dragonchild (Archbishop) on Mar 08, 2005 at 15:53 UTC | |
|
Re: DBI placeholders less efficient?
by JediWizard (Deacon) on Mar 08, 2005 at 15:46 UTC | |
|
Re: DBI placeholders less efficient?
by cfreak (Chaplain) on Mar 08, 2005 at 17:34 UTC | |
|
Re: DBI placeholders less efficient?
by Anonymous Monk on Mar 08, 2005 at 17:12 UTC | |
|
Re: DBI placeholders less efficient?
by Thilosophy (Curate) on Mar 09, 2005 at 07:32 UTC |