Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: perl mysql question

by pg (Canon)
on Nov 06, 2005 at 02:45 UTC ( #506066=note: print w/ replies, xml ) Need Help??


in reply to Re: perl mysql question
in thread perl mysql question

By calling do(), you didn't actually benefit from prepared SQL statement. As every time you call do(), the statement is prepared on fly, if this do() is executed more than once, the SQL statement will be prepared every and each time.

do() is usually only used for non-repeated non-select SQL statement. The usual way is to prepare() the statement once, and execute() with parameters many times.


Comment on Re^2: perl mysql question
Re^3: perl mysql question
by Thilosophy (Curate) on Nov 06, 2005 at 07:00 UTC
    By calling do(), you didn't actually benefit from prepared SQL statement.

    While you do not get all the benefits of a properly prepared (and repeatedly re-executed) SQL statement, using placeholders still is a significant improvement even when using do, because the SQL is typically also cached in the DB server.

    So when you do the same SQL string the second time, it does not have to be reparsed from scratch (server-side). This even works when someone else connected to the same DB uses the same SQL, which is a good thing because you are probably using more than one connection at the same time.

    Conversely, not using bind variables can totally kill the scalability of a database application.

    Of course, re-using prepared statements where possible is the best way, but using bind variables is itself a great (I daresay necessary) improvement (and a good habit, for both performance and security reasons).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-07-24 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (158 votes), past polls