<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">wt., 22 lis 2022, 03:28 użytkownik Tatsuo Ishii <<a href="mailto:ishii@sraoss.co.jp">ishii@sraoss.co.jp</a>> napisał:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> Hi,<br>
> <br>
> is possible to send the selected queries directly to specific slave node ?<br>
> <br>
> For example, if we have a master and two slaves (slave01 and slave02)  I<br>
> would like direct one SELECT to slave slave02.<br>
> OR if we have a master and one slave (slave01)  I would like direct one<br>
> SELECT to slave not to master and others select should be load balanced to<br>
> master and slave.<br>
<br>
If the SELECT can only be issued in a particular session, you can use<br>
app_name_redirect_preference_list for the purpose.<br>
<br>
Set following to pgppol.conf and restart or reload pgpool.<br>
<br>
app_name_redirect_preference_list = 'foo:1'<br>
<br>
Here, 'foo' is an application name you want to use. '1' means<br>
PostgreSQL node number. We suppose that node 0 is primary and 1 is<br>
slave.<br>
<br>
Start psql with the application name 'foo' and connect to pgpool.<br>
<br>
PGAPPNAME=foo psql test<br>
<br>
Issue a read only SELECT query you want to send to PostgreSQL node 1.<br>
<br>
SELECT 1;<br>
<br>
The SELECT should be forwarded to node 1.<br>
<br>
Note that all read only SELECTs in the session will be forwarded to<br>
node 1. If you want to forward SELECT to other than node 1, you need to<br>
disconnect to pgpool and connect again. For example if you want to forward a SELECT to node 2, you can set:<br>
<br>
app_name_redirect_preference_list = 'foo:1,bar:2'<br>
<br>
and start psql:<br>
<br>
PGAPPNAME=bar psql test<br>
<br>
See manual for mode details.<br>
<br>
<a href="https://www.pgpool.net/docs/latest/en/html/runtime-config-load-balancing.html#RUNTIME-CONFIG-LOAD-BALANCING-SETTINGS" rel="noreferrer noreferrer" target="_blank">https://www.pgpool.net/docs/latest/en/html/runtime-config-load-balancing.html#RUNTIME-CONFIG-LOAD-BALANCING-SETTINGS</a><br>
<br>
Best reagards,<br>
--<br>
Tatsuo Ishii<br>
SRA OSS LLC<br>
English: <a href="http://www.sraoss.co.jp/index_en/" rel="noreferrer noreferrer" target="_blank">http://www.sraoss.co.jp/index_en/</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer noreferrer" target="_blank">http://www.sraoss.co.jp</a></blockquote></div></div><div dir="auto"><br></div><div dir="auto">There is no other way ?</div><div dir="auto"><br></div><div dir="auto">I have only one application name and I would like to route a selected query to a selected node, not all queries using application name.</div><div dir="auto"><br></div><div dir="auto"></div></div>