Re: PL/PgSQL Index Usage with Trigger Variables

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: PL/PgSQL Index Usage with Trigger Variables
Дата
Msg-id 20050119045732.GA56463@winnie.fuhr.org
обсуждение исходный текст
Ответ на PL/PgSQL Index Usage with Trigger Variables  (Thomas F.O'Connell <tfo@sitening.com>)
Список pgsql-general
On Tue, Jan 18, 2005 at 10:53:40AM -0600, Thomas F.O'Connell wrote:

> UPDATE mytable SET mybigintcol = somevalue WHERE mybigintcol =
> NEW.myotherbigintcol;
>
> This shows up in the logs with the NEW variable converted to unquoted
> constant data. Is PL/PgSQL smart enough to help the planner figure out
> that it can use an index on mybigintcol based on the fact that the type
> of myotherbigintcol can be discerned from the record of NEW?

Start a new session and try this:

SET debug_print_plan TO on;
SET client_min_messages TO debug1;
<some statement that invokes the trigger>

I did some tests in 7.4.6 and 8.0.0 and an UPDATE statement like
the one above did appear to be using an index from a trigger.  Note
that the plan for the UPDATE is logged only the first time it's
executed in a session, presumably because subsequent calls to the
function use a cached plan.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Jamie Deppeler
Дата:
Сообщение: update in triggers
Следующее
От: Ken Tozier
Дата:
Сообщение: Getting table metadata