Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: same query, different execution, different performance (server-side--)

by tye (Cardinal)
on Feb 14, 2012 at 01:30 UTC ( #953581=note: print w/ replies, xml ) Need Help??


in reply to same query, different execution, different performance

The one with a placeholder is "more efficient" in that it pre-plans the execution before knowing what value will be stuffed into the placeholder. Unfortunately, without that information, the resulting plan sucks. [By pre-planning at prepare() time, it doesn't have to waste time re-planning every time you execute() the same prepared query.]

I have yet to run into a situation where I had and actually kept "server-side prepare" enabled, despite lots of people wanting to crow about how prepare + placeholders can be such a performance "win".

Luckily, it is easy to disable server-side prepare so that you can still use place-holders while still getting "late" query planning every time you execute(). See pg_server_prepare since we are talking Postgresql.

- tye        


Comment on Re: same query, different execution, different performance (server-side--)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2015-07-29 01:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls