Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: Dynamic SQL (prepare)

by tye (Sage)
on Apr 07, 2015 at 03:47 UTC ( [id://1122654]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Dynamic SQL
in thread Dynamic SQL

prepared statements with placeholders will likely be faster than constructing queries on the fly
I rather doubt this is generally true. It would be nice to see it demonstrated.

Running a ton of nearly identical queries can get a rather slight performance improvement from only having to prepare the statement once. But this is not particularly significant in the most extreme case and is of no significance at all if your queries are not rather trivial.

On the other hand, in all 3 of my most recent jobs I've had to basically disable the "prepare" step as the poor query optimization that is done in the absence of the actual values is often horrible and can result in queries taking several orders of magnitude longer.

So I've heard that newer versions of databases that I haven't used recently end up doing query planning twice, once at "prepare" time and then again once the values are known. I don't know how much that impacts the oft-touted "efficiency" of separate prepare/execute, but it surely means it has become even more insignificant.

But the documentation says that it is faster so everybody repeats that, usually with much more emphasis than is warranted (and completely ignoring the much, much worse performance problems that can result).

- tye        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-18 18:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found