Search Postgresql Archives

PL/PgSQL Index Usage with Trigger Variables

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

 



I've got a question about how PL/PgSQL passes things to the planner based on statement logging.

E.g., I have a statement like this in PL/PgSQL:

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? Or is type information not available as the record variable is interpolated and passed to the planner?

As in, should I rewrite the above statement as:

UPDATE mytable SET mybigintcol = somevalue WHERE mybigintcol = '''''' || NEW.myotherbigintcol || '''''';

in order to help the planner understand that it can use an index?

-tfo

--
Thomas F. O'Connell
Co-Founder, Information Architect
Sitening, LLC
http://www.sitening.com/
110 30th Avenue North, Suite 6
Nashville, TN 37203-6320
615-260-0005


---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

[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