<div dir="ltr"><div dir="ltr"><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><br><div><span style="color:rgb(153,153,153)">Rick Morris | Managing Consultant, Professional Services &amp; Training (EMEA) | M</span><span style="color:rgb(153,153,153);font-size:12.8px">: +1 954 224 8682 | </span><span style="color:rgb(153,153,153);font-size:12.8px">Skype: rycamor</span><br></div></div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 26, 2020 at 11:23 PM Tatsuo Ishii &lt;<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; In testing the in-memory query cache, I find that auto cache invalidation<br>
&gt; works for UPDATE and INSERT queries, but does not work when calling plpgsql<br>
&gt; functions.<br>
&gt; <br>
&gt; Is there any way to auto-invalidate cache for UPDATE/INSERTs within<br>
&gt; functions? If not, is there any way to explicitly invalidate the cache with<br>
&gt; additional code in a function?<br>
&gt; <br>
&gt; Using PgPool 4.1.1, with the following relevant settings:<br>
&gt; <br>
&gt; memqcache_auto_cache_invalidation = on<br>
&gt; memqcache_expire = 0<br>
&gt; relcache_expire = 0<br>
&gt; enable_shared_relcache = on<br>
&gt; memory_cache_enabled = on<br>
&gt; black_function_list = &#39;test_update_function,test_insert_function&#39;<br>
<br>
Currently there&#39;s no such functionality in Pgpool-II. It&#39;s a technical<br>
challenge for Pgpool-II because there&#39;s no way for Pgpool-II to know<br>
what table(s) are modified inside the function. </blockquote><div><br></div><div>Yes, I figured that was a serious challenge.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">To implement such<br>
functionality, Pgpool-II needs to know:<br>
<br>
1) whether the SELECT modifies tables or not.<br>
<br>
2) if #1 is yes, what table(s) will be modified in the SELECT<br>
<br>
For this purpose we need to invent a new parameter to provide the<br>
information above. Suggestions, or even better, patches are welcome.<br></blockquote><div><br></div><div>I was thinking in terms of an explicit function in PgPool-II to invalidate cache on chosen tables.<br><br>For example if I call a function <b>SELECT func_that_updates_table_a();</b>, could I then call a function something like <b>SELECT pgpool_cache_invalidate(&#39;table_a&#39;);</b> and have the cache for that table explicitly invalidated? Or would it be possible to put that sort of function call inside a function, so the function might do something like (pseudocode):<br><br><b>BEGIN</b></div></div><b><br></b><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_quote"><div><b>INSERT INTO table_a VALUES(&#39;value1&#39;,&#39;value2&#39;);<br>UPDATE table_b SET value_a=&#39;something&#39; WHERE value_b=&#39;something&#39;;<br><br>PERFORM pgpool_cache_invalidate(&#39;table_a&#39;);<br>PERFORM pgpool_cache_invalidate(&#39;table_b&#39;);<br><br></b></div></div></blockquote><b>END;<br></b><div class="gmail_quote"><div><br>Does something like this seem worth investigating?<br><br>Thanks,</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Best regards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
</blockquote></div></div>