Search Postgresql Archives

Re: PL/PgSQL Index Usage with Trigger Variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux