Re: When deleting the plpgsql function, release the CachedPlan of the function

From: 章晨曦 <zhangchenxi(at)halodbtech(dot)com>
To: Vladlen Popolitov <v(dot)popolitov(at)postgrespro(dot)ru>
Cc: 曾满 <zengman(at)halodbtech(dot)com>, 陈天 <chentian(at)halodbtech(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: When deleting the plpgsql function, release the CachedPlan of the function
Date: 2025-08-19 09:31:06
Message-ID: tencent_6B09B39444F8D8965F9AB805@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Vladlen Popolitov 2025-08-19 08:39:50 wrote:&gt; Hi!
&gt;
&gt; &nbsp; In your example function will be compiled (the tree is created in the
&gt; memory)
&gt; and executed.
&gt; &nbsp; During execution this function creates a plan for very simple query 1
&gt; and stores it in the cache, than it creates a plan for query 10 and
&gt; store
&gt; in in the cache. There is no other queries, no more plans in the cache.
&gt; After execution function releases the tree (own code) from memory,
&gt; but cached queries are remains in the memory, it is why this cache is
&gt; created -
&gt; for usage by other queries.
&gt;
&gt; &nbsp; I do not know, what other cache of the stored procedure do you mean. I
&gt; suppose,
&gt; a stored procedure creates cached plans only for queries inside of the
&gt; procedure,
&gt; not for itself.
&gt;
&gt; --
&gt; Best regards,
&gt;
&gt; Vladlen Popolitov.

I think you misunderstand Man's meaning. In Man's example, the func cache
neither dropped (will cause memory leak) nor reused. So the question here:

1.&nbsp;Drop the cache when func dropped
2.&nbsp;Keep the cache and reused when func recreate

I prefer the 2ed solution.

Regards,

Jet C.X. ZHANG

Halo Tech (www.halodbtech.com)
openHalo (www.openhalo.org)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2025-08-19 09:31:28 Re: New commitfest app release on August 19th
Previous Message John Naylor 2025-08-19 09:30:02 Re: New commitfest app release on August 19th