explain with placeholders?

Started by Dan Sugalskiover 21 years ago3 messagesgeneral
Jump to latest
#1Dan Sugalski
dan@sidhe.org

Is there any way to convince explain to go do its thing when given a
query with placeholders in it?

I'm trying to do some performance checking of some of the queries
built into a system I'm building. The SQL's all done with
placeholders, for safety and ease of twiddling, but EXPLAIN...
EXPLAIN doesn't like them. Trying throws an "ERROR: there is no
parameter $1" which is somewhat sub-optimal.

Any way, short of hand-replacing the placeholders with real values
(which makes me nervous since the optimizer may do things that
wouldn't be doable in the system when it was running), to get a
meaningful check on these things?
--
Dan

--------------------------------------it's like this-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dan Sugalski (#1)
Re: explain with placeholders?

Dan Sugalski <dan@sidhe.org> writes:

Is there any way to convince explain to go do its thing when given a
query with placeholders in it?

PREPARE foo(...) AS SELECT ...

EXPLAIN EXECUTE foo(...)

EXPLAIN EXECUTE is a relatively recent addition, but I'm sure it's in
7.4 at least.

regards, tom lane

#3Dan Sugalski
dan@sidhe.org
In reply to: Tom Lane (#2)
Re: explain with placeholders?

At 10:39 AM -0400 9/7/04, Tom Lane wrote:

Dan Sugalski <dan@sidhe.org> writes:

Is there any way to convince explain to go do its thing when given a
query with placeholders in it?

PREPARE foo(...) AS SELECT ...

EXPLAIN EXECUTE foo(...)

EXPLAIN EXECUTE is a relatively recent addition, but I'm sure it's in
7.4 at least.

Ah, cool. Thanks.
--
Dan

--------------------------------------it's like this-------------------
Dan Sugalski even samurai
dan@sidhe.org have teddy bears and even
teddy bears get drunk