<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,0)">Hello, <br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,0)">Thanks for the info and work-around. Couple of questions more :<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,0)">Is there a way to programmatically achieve what is mentioned below ? i.e. Can I inject / intercept the sql queries of &quot;interest&quot; so that I can append an arbitrary SQL  comment to actual SQL queries to make sure that the request will go the primary only ? Reason - I&#39;m aware of &quot;heavy write tables&quot; but I cannot possibly instruct the app developers to attach a SQL comment to such tables.<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,0)"><br>&quot; A workaround for the problem is using an SQL comment.<br>
If &quot;allow_sql_comments&quot; is off,<br>
<br>
/*a comment*/select * from table1;<br>
<br>
will be always redirected to primary (inside /* and */ is an arbitrary<br>
string). Also you can use:<br>
<br>
pgpool set allow_sql_comments to off;<br>
<br>
to set the configuration variable temporarily. &quot;<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,0)">Regards, Dinesh<br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(0,0,0)">
<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 2, 2017 at 5:24 AM, Tatsuo Ishii <span dir="ltr">&lt;<a href="mailto:ishii@sraoss.co.jp" target="_blank">ishii@sraoss.co.jp</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt; Hello,<br>
&gt;<br>
&gt; I would like to know whether it is possible to configure load balancing<br>
&gt; module in pgpool II so that it will be possible to redirect requests on the<br>
&gt; basis of tables (in the sql query) as well. For e.g., configurations like<br>
&gt; database_redirect_preference_<wbr>list and app_name_redirect_preference_<wbr>list<br>
&gt; gives us the granularity to redirect on the basis of database / clients.<br>
&gt; I&#39;m looking for something like<br>
&gt;<br>
&gt; table_name_redirect_<wbr>preference_list =<br>
&gt; &#39;table1:primary;table2:1,<wbr>table3:standby&#39;.<br>
&gt;<br>
&gt;<br>
&gt; I couldn&#39;t find any such configurations<br>
<br>
</span>That is not supported in Pgpool-II.<br>
<span class=""><br>
&gt; - Is it possible to write some<br>
&gt; extensions (custom code to do the stuff mentioned above ) and attach it to<br>
&gt; pgpool II<br>
<br>
</span>No.<br>
<span class=""><br>
&gt; or will it be required to branch and add that piece of code to<br>
&gt; pgpool source and do a build / install ?<br>
<br>
</span>Yes. BTW I think you should decide what to do if table1 and table2 are<br>
used in a SELECT.<br>
<span class=""><br>
&gt; Reason : - I have set up a postgres cluster with SR (Streaming<br>
&gt; Replication). Due to inherent design, things are asynchronous and there<br>
&gt; will be a read miss if a recently inserted row in master was read from the<br>
&gt; slave. I went through the configuration sr_check_period and<br>
&gt; delay_threshold. What will happen to requests (insert row; read same row;)<br>
&gt; which was done under 1 second (lowest possible value for sr_check_period).<br>
&gt; I do not want to opt for sync replication due to performance reasons and<br>
&gt; also due to the fact that majority of the queries are &quot;reads&quot;.<br>
&gt;<br>
&gt; I&#39;m aware of tables with heavy writes - Hence such a configuration / module<br>
&gt; (if available in runtime - even better) will help me to circumvent the<br>
&gt; problem. Of course, I&#39;m pretty much new to pgpool II - Please correct me<br>
&gt; I&#39;ve got it completely wrong.<br>
<br>
</span>A workaround for the problem is using an SQL comment.<br>
If &quot;allow_sql_comments&quot; is off,<br>
<br>
/*a comment*/select * from table1;<br>
<br>
will be always redirected to primary (inside /* and */ is an arbitrary<br>
string). Also you can use:<br>
<br>
pgpool set allow_sql_comments to off;<br>
<br>
to set the configuration variable temporarily.<br>
<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_<wbr>en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.<wbr>jp</a><br>
</blockquote></div><br></div>