Index: sgml/plpython.sgml =================================================================== RCS file: /projects/cvsroot/pgsql-server/doc/src/sgml/plpython.sgml,v retrieving revision 1.14 diff -u -r1.14 plpython.sgml --- sgml/plpython.sgml 2002/09/23 01:51:02 1.14 +++ sgml/plpython.sgml 2002/10/20 23:13:20 @@ -198,15 +198,24 @@ When you prepare a plan using the PL/Python module it is automatically saved. Read the SPI documentation () for a description of what this means. The take - home message is if you do + linkend="spi">) for a description of what this means. + + + + In order to make effective use of this across function calls + one needs to use one of the persistent storage dictionaries + SD or GD, see + . For example: -plan = plpy.prepare("SOME QUERY") -plan = plpy.prepare("SOME OTHER QUERY") +CREATE FUNCTION usesavedplan ( ) RETURNS TRIGGER AS ' + if SD.has_key("plan"): + plan = SD["plan"] + else: + plan = plpy.prepare("SELECT 1") + SD["plan"] = plan + # rest of function +' LANGUAGE 'plpython'; - you are leaking memory, as I know of no way to free a saved plan. - The alternative of using unsaved plans it even more painful (for - me).