Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: how to speed up querys to mysql

by ptum (Priest)
on Oct 19, 2006 at 13:51 UTC ( [id://579366]=note: print w/replies, xml ) Need Help??


in reply to Re^2: how to speed up querys to mysql
in thread how to speed up querys to mysql

No, look again at the answers you've been given above. You want to prepare the SQL statement outside your two foreach blocks, and use bind parameters to substitute the $c1 and $c2 variables on the fly:

use strict; my $sth = $dbh->prepare("SELECT blah from blah1 where blah1.field = ?" +); foreach my $c1(@c1) { $sth->execute($c1); # do stuff }

Your SQL statements are identical, so if (for some reason) you want to spin through two levels of bind parameters, you still only need to prepare the statement once outside the loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://579366]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-19 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found