Jeremy Zawodny wrote: > On Sat, Oct 20, 2001 at 05:02:22PM +0100, Mark Maunder wrote: > > > > The only time you'll see a real performance increase is where you're > > repeadedly calling execute() on the same statement handle with > > different values for the placeholders - usually this occurs in a > > loop. This will save you having to do a repeated prepare() > > Right. > > > so the database server can reuse the old execution plan. Let me know > > if you want a example. > > That's true for some database servers but not MySQL (yet).
I wasn't aware of that - thanks Jeremy. Any ETA as to when this might be implemented? (part of version 4?) Also just out of curiousity, how much of a performance hit does mysql take in compiling an execution plan? tnx! ps: Here's that example anyway for future ref: use DBI; open(FH, "<emails.txt") || die "couldnt open file\n"; my $content; { local $/; $content = <FH>; #slurp } close(FH); $content =~ s/\r\n/\n/g; #in case it's a dos file my @email_list = split("\n", $content); #assumes 1 email addr per line my $dbh = DBI->connect("DBI:mysql:dbname:hostname:3306, 'root' ,'password'); my $sth = $dbh->prepare("select (name, address1) from users where email=?"); foreach my $email (@email_list) #email_list loaded from file or something { $sth->execute($email); #shorthand for bind_param, same effect my ($name, $addr1) = $sth->fetchrow(); print "$name - $addr1\n"; } $sth->finish(); $dbh->disconnect(); #Something like that anyway. #Creating the initial DB connection has a higher performance impact than creating an execution plan, so # something else (more significant) you should look at is optimising your code by either # using a global $DBH that everyone shares, or you could # use something like Apache::DBI for persistent connections under mod_perl if you're writing a web app which # will give you a major performance increase. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php