Обсуждение: explain with placeholders?

Поиск
Список
Период
Сортировка

explain with placeholders?

От
Dan Sugalski
Дата:
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

Re: explain with placeholders?

От
Tom Lane
Дата:
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

Re: explain with placeholders?

От
Dan Sugalski
Дата:
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