Re: Q: explain on delete

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Q: explain on delete
Дата
Msg-id 14824.1044375843@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Q: explain on delete  (Andrew Sullivan <andrew@libertyrms.info>)
Ответы Re: Q: explain on delete
Re: Q: explain on delete
Список pgsql-general
Andrew Sullivan <andrew@libertyrms.info> writes:
> On Mon, Feb 03, 2003 at 05:01:17PM -0500, Tom Lane wrote:
>> mechanism.  It's not great, particularly because you can't conveniently
>> see the associated plans, but it's better than nothing ...

> But you can take the thereby-discovered queries and pass them to
> EXPLAIN manually.  It's a bit of a pain, but this is how I have found
> some real performance problems.

Actually, the problem with looking at the plan for an FK query is that
the query will involve parameters ($n), and so you can't just stick it
into EXPLAIN as-is.  (Substituting constants for the $n symbols does
*not* necessarily give the same plan, although it may be close enough
to give you a clue about major problems like needing to add an index.)

As of CVS tip there's finally a real solution: you can PREPARE the
parameterized query and then EXPLAIN EXECUTE it.  For example,
given something like

    SELECT * FROM foo WHERE col = $1

you could do

    PREPARE q1(int) AS SELECT * FROM foo WHERE col = $1
    EXPLAIN EXECUTE q1(42)

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: UNION problem
Следующее
От: Greg Stark
Дата:
Сообщение: Tuning Question sort_mem vs pgsql_tmp