Re: [HACKERS] question about the _SPI_save_plan() and plan cache

2009-08-03 Thread Tao Ma
Tom Lane t...@sss.pgh.pa.us writes: Tao Ma feng_e...@163.com writes: I knew that the delete_function() will reclaim the memory context allocated for the function. But I did not find any code for removing the plan(SPI plan memory context), saved by calling _SPI_save_plan. Hmmm ... good point,

Re: [HACKERS] question about the _SPI_save_plan() and plan cache

2009-07-29 Thread Tom Lane
Tao Ma feng_e...@163.com writes: I knew that the delete_function() will reclaim the memory context allocated for the function. But I did not find any code for removing the plan(SPI plan memory context), saved by calling _SPI_save_plan. Hmmm ... good point, those probably won't get cleaned up.

[HACKERS] question about the _SPI_save_plan() and plan cache

2009-07-28 Thread Tao Ma
Hi, It seems postgres cache the plan under CacheMemoryContext during the plpgsql executing. If there is a function with lots of variables and every one of them got a default value, postgres will allocate lots of memory for caching the default value plan(we have to run the function at least

Re: [HACKERS] question about the _SPI_save_plan() and plan cache

2009-07-28 Thread Tom Lane
Tao Ma feng_e...@163.com writes: Once we DROP the function, the memory consumed by the plan will be leak. I'm pretty unconcerned about DROP FUNCTION. The case that seems worth worrying about is CREATE OR REPLACE FUNCTION, and in that case we'll reclaim the storage on the next call of the

Re: [HACKERS] question about the _SPI_save_plan() and plan cache

2009-07-28 Thread Tao Ma
I knew that the delete_function() will reclaim the memory context allocated for the function. But I did not find any code for removing the plan(SPI plan memory context), saved by calling _SPI_save_plan. Is the plan memory context freed when someone issued CREATE OR REPLACE FUNCTION? Thanks. Tom