Re: Tuning queries inside a function

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Tuning queries inside a function
Дата
Msg-id 42773282.8040507@archonet.com
обсуждение исходный текст
Ответ на Re: Tuning queries inside a function  (Mike Nolan <nolan@gw.tssi.com>)
Список pgsql-general
Mike Nolan wrote:
>>>Maybe you could return a refcursor pointing to the EXPLAIN ANALYZE of
>>>the query inside the function.
>>
>>The raw materials exist to do this: if you know which elements of a
>>query will be replaced by plpgsql variables, you can duplicate the
>>results via
>>
>>    PREPARE foo(...) AS ...
>>    EXPLAIN EXECUTE foo(...)
>>
>>Certainly there is a lot more that we can and must do about making
>>it easier to debug and tune plpgsql functions.  But you can fix 'em
>>with a little determination even now...
>
>
> If I know which elements of a query will be replaced by variables, I can
> enter the query in psql, which I've done.  (I can always output the variables
> to the log from inside the function.)

Be aware that if you're pasting values in the place of the variables
then PG can come up with a different plan.

--
   Richard Huxton
   Archonet Ltd

В списке pgsql-general по дате отправления:

Предыдущее
От: "Rolf Østvik"
Дата:
Сообщение: Re: scripts in Postgres
Следующее
От: Sean Davis
Дата:
Сообщение: Re: scripts in Postgres