1<!-- doc/src/sgml/config.sgml -->
2
3<sect1 id="runtime-config-load-balancing">
4 <!--
5 <title>Load Balancing</title>
6 -->
7 <title>負荷分散</title>
8
9 <para>
10  <!--
11  <productname>Pgpool-II</productname> load balancing of SELECT queries
12  works with Master Slave mode (<xref linkend="runtime-config-master-slave-mode">)
13  and Replication mode (<xref linkend="runtime-config-replication-mode">). When enabled
14  <productname>Pgpool-II</productname> sends the writing queries to the
15  <acronym>primay node</acronym> in Master Slave mode, all of the backend nodes
16  in Replication mode, and other queries get load balanced among all backend nodes.
17  To which node
18  the load balancing mechanism sends read queries is decided at the
19  session start time and will not be changed until the session
20  ends. The only exception is by writing special SQL comments. See
21  below for more details.
22  -->
23  <productname>Pgpool-II</productname>のSELECTクエリの負荷分散はマスタースレーブモード(<xref linkend="runtime-config-master-slave-mode">)とレプリケーションモード(<xref linkend="runtime-config-replication-mode">)で動作します。
24    有効時、<productname>Pgpool-II</productname>は更新を伴うクエリを、マスタースレーブモードでは<acronym>プライマリノード</acronym>に、レプリケーションモードでは全てのバックエンドノードに対し送信します。
25    そして、その他のクエリは全てのバックエンドの間で負荷分散されます。
26    負荷分散メカニズムが参照クエリをどのノードに送信するかはセッション開始時に決められ、セッションの終了まで変更されません。
27    唯一の例外は特別なSQLコマンドが発行されたときです。
28    詳細については以下をご覧ください。
29 </para>
30 <note>
31  <para>
32   <!--
33   Queries which are sent to primary node or all backend nodes because they cannot be balanced are
34   also accounted for in the load balancing algorithm.
35   -->
36   負荷分散ができないためにプライマリノードまたは全バックエンドノードに送られるクエリもまた、
37   負荷分散アルゴリズムの考慮に入れられます。
38  </para>
39 </note>
40 <note>
41  <para>
42   <!--
43   If you don't want a query that qualifies for the load balancing to be
44   load balanced by <productname>Pgpool-II</productname>, you can put
45   <emphasis>/*NO LOAD BALANCE*/</emphasis> comment before the <acronym>SELECT
46  </acronym> statement. This will disable the load balance of the particular query
47   and <productname>Pgpool-II</productname> will send it to the master node (the primary node in Master Slave mode).
48   -->
49   もし負荷分散対象のクエリを<productname>Pgpool-II</productname>に負荷分散してほしくない場合には、<acronym>SELECT</acronym>文の前の<emphasis>/*NO LOAD BALANCE*/</emphasis>コメントを付与することができます。
50   これにより、そのクエリの負荷分散は無効となり、<productname>Pgpool-II</productname>はこれをマスターノード(マスタースレーブモードではプライマリノード)に送信します。
51  </para>
52 </note>
53
54 <note>
55  <para>
56   <!--
57   You can check which DB node is assigned as the load balancing
58   node by using <xref linkend="sql-show-pool-nodes">.
59   -->
60   どのDBノードが負荷分散ノードになっているかは、<xref linkend="sql-show-pool-nodes">を利用して確認できます。
61  </para>
62 </note>
63
64 <sect2 id="runtime-config-load-balancing-condition">
65  <!--
66  <title>Condition for Load Balancing</title>
67  -->
68  <title>負荷分散の条件について</title>
69
70  <para>
71   <!--
72   For a query to be load balanced, all the following requirements
73   must be met:
74   -->
75   クエリが負荷分散されるためには、以下の全ての条件を満たす必要があります:
76   <itemizedlist>
77    <listitem>
78     <para>
79      <!--
80      <productname>PostgreSQL</> version 7.4 or later
81      -->
82      <productname>PostgreSQL</>のバージョンが7.4以降である
83     </para>
84    </listitem>
85    <listitem>
86     <para>
87      <!--
88      either in replication mode or master slave mode
89      -->
90      レプリケーションモードまたはマスタースレーブモードである
91     </para>
92    </listitem>
93    <listitem>
94     <para>
95      <!--
96      the query must not be in an explicitly declared transaction
97      (i.e. not in a BEGIN ~ END block)
98      -->
99      問い合わせが明示的なトランクザションブロックの内側にない(つまり、BEGINを発行していない)
100     </para>
101     <itemizedlist>
102      <listitem>
103       <para>
104	<!--
105	However, if following conditions are met, load balance is possible
106	even if in an explicit transaction
107	-->
108	ただし、以下の条件が満たされればトランザクションブロックの内側であっても負荷分散の対象となります。
109	<itemizedlist>
110	 <listitem>
111	  <para>
112	   <!--
113	   transaction isolation level is not SERIALIZABLE
114	   -->
115	   トランザクション分離レベルがSERIALIZABLEでない
116	  </para>
117	 </listitem>
118	 <listitem>
119	  <para>
120	   <!--
121	   transaction has not issued a write query yet (until a write
122	   query is issued, load balance is possible. Here "write query"
123	   means non SELECT DML or DDL. SELECTs having write functions as
124	   specified in black or white function list is not regarded as
125	   a write query. This may be changed in the future.)
126	   -->
127	   トランザクション内で更新を伴うクエリが実行されていない
128	   (更新を伴うクエリが実行されるまでは負荷分散されます。
129	   ここで「更新を伴うクエリ」とは、SELECT以外のDDLやDMLを指します。
130	   black/white function listで指定される更新関数を含むSELECTは更新を伴うクエリとは見なされません。
131	   この仕様は将来変更される可能性があります)
132	  </para>
133	 </listitem>
134	 <listitem>
135	  <para>
136	   <!--
137	   If black and white function list is empty, SELECTs having
138	   functions is regarded as a read only query.
139	   -->
140	   もしblack/white function listが空の場合は、関数を持つSELECTは、更新を伴うクエリとは見なされません。
141	  </para>
142	 </listitem>
143	</itemizedlist>
144       </para>
145      </listitem>
146     </itemizedlist>
147    </listitem>
148    <listitem>
149     <para>
150      <!--
151      it's not SELECT INTO
152      -->
153      SELECT INTO 文ではない
154     </para>
155    </listitem>
156    <listitem>
157     <para>
158      <!--
159      it's not SELECT FOR UPDATE nor FOR SHARE
160      -->
161      SELECT FOR UPDATE/SELECT FOR SHARE文ではない
162     </para>
163    </listitem>
164    <listitem>
165     <para>
166      <!--
167      it starts with "SELECT" or one of COPY TO STDOUT, EXPLAIN,
168      EXPLAIN ANALYZE SELECT... (Except for SELECTs using writing functions
169      specified in <xref linkend="guc-black-function-list"> or
170      <xref linkend="guc-white-function-list">)
171      <xref linkend="guc-ignore-leading-white-space"> = <literal>true</>
172      will ignore leading white space.
173      -->
174      SELECT または COPY TO STDOUT, EXPLAIN, EXPLAIN ANALYZE SELECT... から始まる。
175      (<xref linkend="guc-black-function-list">または<xref linkend="guc-white-function-list">で指定された書き込み関数を含むSELECTを除く)
176	<xref linkend="guc-ignore-leading-white-space"> = <literal>true</>の場合は最初の空白文字は無視されます。
177     </para>
178    </listitem>
179    <listitem>
180     <para>
181      <!--
182      in master slave mode, in addition to above, following conditions must be met:
183      -->
184      マスタースレーブモードの場合、更に以下の条件が満たされなければなりません。
185     </para>
186     <itemizedlist>
187      <listitem>
188       <para>
189	<!--
190	does not use temporary tables
191	-->
192	一時テーブルを使っていない
193       </para>
194      </listitem>
195      <listitem>
196       <para>
197	<!--
198	does not use unlogged tables
199	-->
200	unloggedテーブルを使っていない
201       </para>
202      </listitem>
203      <listitem>
204       <para>
205	<!--
206	does not use system catalogs
207	-->
208	システムカタログを使っていない
209       </para>
210      </listitem>
211     </itemizedlist>
212    </listitem>
213   </itemizedlist>
214  </para>
215
216  <note>
217   <para>
218    <!--
219    You could suppress load balancing by inserting arbitrary
220    comments just in front of the SELECT query:
221    -->
222    SELECTクエリの前に任意のコメントを挿入することにより負荷分散を抑制することができます。
223   </para>
224   <programlisting>
225    /*REPLICATION*/ SELECT ...
226   </programlisting>
227   <para>
228    <!--
229    If you want to use comments without supressing load balancing, you can set
230    <xref linkend="guc-allow-sql-comments"> to on.
231    Please refer to <xref linkend="guc-replicate-select"> as well.
232    -->
233    SQLコメントの記述が負荷分散に影響を与えないようにするには、<xref linkend="guc-allow-sql-comments">をonにします。
234     <xref linkend="guc-replicate-select">も参照してください。
235   </para>
236  </note>
237
238  <note>
239   <para>
240    <!--
241    The JDBC driver has an autocommit option. If the autocommit is false,
242    the JDBC driver sends "BEGIN" and "COMMIT" by itself, and an explicit
243    tranasacttion starts. In this case the same restriction above regarding
244    load balancing will be applied.
245    -->
246    JDBC ドライバにはautocommitオプションがあります。
247    autocommit を無効にすると、ドライバが内部でBEGINおよびCOMMITコマンドを実行し、明示的なトランザクションが開始されます。
248    この場合、トランザクション内における上記の負荷分散の制限事項が適用されます。
249   </para>
250  </note>
251
252 </sect2>
253
254 <sect2 id="runtime-config-load-balancing-in-streaming-raplication">
255
256  <!--
257  <title>Load Balancing in Streaming Replication</title>
258  -->
259  <title>ストリーミングレプリケーションにおける負荷分散</title>
260
261  <para>
262   <!--
263   While using Streaming replication and Hot Standby, it is important to
264   determine which query can be sent to the primary or the standby,
265   and which one should not be sent to the standby.
266   <productname>Pgpool-II</>'s Streaming Replication mode carefully
267   takes care of this.
268   -->
269   ストリーミングレプリケーションとHot Standbyを利用している環境では、プライマリノードに送ってよい問い合わせ、スタンバイに送ってもよい問い合わせ、両方に送らなければならない問い合わせを厳密に管理する必要があります。
270   <productname>Pgpool-II</>のストリーミングレプリケーションモードは、こうした振り分けを自動的に行ないます。
271  </para>
272
273  <para>
274   <!--
275   We distinguish which query should be sent to which node by looking
276   at the query itself.
277   -->
278   クエリそのものから、どのクエリがどのノードに送られるべきかを区別します。
279   <itemizedlist>
280    <listitem>
281     <para>
282      <!--
283      These queries should be sent to the primary node only
284      -->
285      プライマリノードにしか送られない問い合わせ
286      <itemizedlist>
287       <listitem>
288	<para>
289	 INSERT, UPDATE, DELETE, COPY FROM, TRUNCATE, CREATE, DROP, ALTER, COMMENT
290	</para>
291       </listitem>
292       <listitem>
293	<para>
294	 SELECT ... FOR SHARE | UPDATE
295	</para>
296       </listitem>
297       <listitem>
298	<para>
299	 <!--
300	 SELECT in transaction isolation level SERIALIZABLE
301	 -->
302	 トランザクションの分離レベルがSERIALIZABLEの場合のSELECT
303	</para>
304       </listitem>
305       <listitem>
306	<para>
307	 <!--
308	 LOCK command more strict than ROW EXCLUSIVE MODE
309	 -->
310	 ROW EXCLUSIVE MODEよりも強いLOCK
311	</para>
312       </listitem>
313       <listitem>
314	<para>
315	 DECLARE, FETCH, CLOSE
316	</para>
317       </listitem>
318       <listitem>
319	<para>
320	 SHOW
321	</para>
322       </listitem>
323       <listitem>
324	<para>
325	 <!--
326	 Some transactional commands:
327	 -->
328	 トランザクションコマンドの一部
329	 <itemizedlist>
330	  <listitem>
331	   <para>
332	    BEGIN READ WRITE, START TRANSACTION READ WRITE
333	   </para>
334	  </listitem>
335	  <listitem>
336	   <para>
337	    SET TRANSACTION READ WRITE, SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE
338	   </para>
339	  </listitem>
340	  <listitem>
341	   <para>
342	    SET transaction_read_only = off
343	   </para>
344	  </listitem>
345	 </itemizedlist>
346	</para>
347       </listitem>
348       <listitem>
349	<para>
350	 <!--
351	 Two phase commit commands: PREPARE TRANSACTION, COMMIT PREPARED, ROLLBACK PREPARED
352	 -->
353	 二相コミット関連のコマンド。PREPARE TRANSACTION, COMMIT PREPARED, ROLLBACK PREPARED
354	</para>
355       </listitem>
356       <listitem>
357	<para>
358	 LISTEN, UNLISTEN, NOTIFY
359	</para>
360       </listitem>
361       <listitem>
362	<para>
363	 VACUUM
364	</para>
365       </listitem>
366       <listitem>
367	<para>
368	 <!--
369	 Som sequence functions (nextval and setval)
370	 -->
371	 シーケンス関連の関数(nextvalやsetvalなど)の呼び出し
372	</para>
373       </listitem>
374       <listitem>
375	<para>
376	 <!--
377	 Large objects creation commands
378	 -->
379	 ラージオブジェクトの生成
380	</para>
381       </listitem>
382       <listitem>
383	<para>
384	 マルチステートメントSQL(1行の中に複数のSQLが含まれている)
385	</para>
386       </listitem>
387      </itemizedlist>
388     </para>
389    </listitem>
390    <listitem>
391     <para>
392      <!--
393      These queries can be sent to both the primary node and the standby node.
394      If load balancing is enabled, these types of queries can be sent to the standby node.
395      However, if delay_threshold is set and the replication delay is higher than
396      <xref linkend="guc-delay-threshold">, queries are sent to the primary node.
397      -->
398      プライマリノードとスタンバイノードのどちらにも送ることのできる問い合わせ。
399      負荷分散設定が有効ならば、スタンバイノードにも送信されます。
400      レプリケーションの遅延が<xref linkend="guc-delay-threshold">を上回っている場合は問い合わせはプライマリノードに送られます。
401
402       <itemizedlist>
403	<listitem>
404	 <para>
405	  SELECT (上記以外)
406	 </para>
407	</listitem>
408	<listitem>
409	 <para>
410	  COPY TO
411	 </para>
412	</listitem>
413       </itemizedlist>
414     </para>
415    </listitem>
416    <listitem>
417     <para>
418      <!--
419      These queries are sent to both the primary node and the standby node
420      -->
421      プライマリノードとスタンバイノードのどちらにも送られる問い合わせ
422      <itemizedlist>
423       <listitem>
424	<para>
425	 SET
426	</para>
427       </listitem>
428       <listitem>
429	<para>
430	 DISCARD
431	</para>
432       </listitem>
433       <listitem>
434	<para>
435	 DEALLOCATE ALL
436	</para>
437       </listitem>
438      </itemizedlist>
439     </para>
440    </listitem>
441   </itemizedlist>
442  </para>
443
444  <para>
445   <!--
446   In an explicit transaction:
447   -->
448   明示的なトランザクションでは、以下のようになります。
449   <itemizedlist>
450
451    <listitem>
452     <para>
453      <!--
454      Transaction starting commands such as BEGIN are sent to the primary node
455      and the standby node.
456      -->
457      BEGINなどのトランザクション開始コマンドは、プライマリノードとスタンバイノードの両方に送られます。
458     </para>
459    </listitem>
460    <listitem>
461     <para>
462      <!--
463      Following SELECT and some other queries that can be sent to both
464      primary or standby are executed in the transaction or on the standby node.
465      -->
466      続くSELECTなど、プライマリ/スタンバイのどちらにも送ることのできる問い合わせは、プライマリのトランザクション内でそのまま実行されるか、スタンバイノードで実行されます。
467     </para>
468    </listitem>
469    <listitem>
470     <para>
471      <!--
472      Commands which cannot be executed on the standby such as INSERT are sent
473      to the primary.
474      After one of these commands, even SELECTs are sent to the primary node,
475      This is because these SELECTs might want to see the result of an INSERT immediately.
476      This behavior continues until the transaction closes or aborts.
477      -->
478      INSERTなど、スタンバイに送ることのできない問い合わせが現われた場合はプライマリに送られます。
479      そういったコマンドの後は、SELECTであってもプライマリノードに送られます。
480      これは、INSERTなどの問い合わせの結果を SELECTが直ちに参照できるようにするためです。
481      この状態は、トランザクションが閉じるか、アボートするまで続きます。
482     </para>
483    </listitem>
484   </itemizedlist>
485  </para>
486
487  <para>
488   <!--
489   In the extended protocol, it is possible to determine if the query can
490   be sent to standby or not in load balance mode while parsing the query.
491   The rules are the same as for the non extended protocol.
492   For example, INSERTs are sent to the primary node.
493   Following bind, describe and execute will be sent to the primary node as well.
494   -->
495   問い合わせが、拡張問い合わせモードで実行される場合は、問い合わせのparse段階で、問い合わせがスタンバイに送信可能かが決まります。
496   その際の判断ルールは通常のSQLと同じです。
497   たとえば問い合わせがINSERTならば、プライマリノードに送られます。
498   それに後に続くbind, describe, executeも同じくプライマリに送られます。
499  </para>
500
501  <note>
502   <para>
503    <!--
504    If the parse of a SELECT statement is sent to the standby node due to load
505    balancing, and then a DML statement, such as an INSERT, is sent to <productname>Pgpool-II</>,
506    then the parsed SELECT will have to be executed on the primary node.
507    Therefore, we re-parse the SELECT on the primary node.
508    -->
509    負荷分散によりSELECT文のparseがスタンバイノードに送信され、その後INSERTなどのDML文が<productname>Pgpool-II</>に送られた場合、parse済のSELECTはプライマリノードで実行されなければなりません。
510    そのため、同じSELECTがプライマリノードで再度パースされることになります。
511   </para>
512  </note>
513
514  <para>
515   <!--
516   Lastly, queries that <productname>Pgpool-II</>'s parser thinks to be an
517   error are sent to the primary node.
518   -->
519   最後に、pgpool-IIのパーサが構文エラーと判断した問い合わせはプライマリノードだけに送られます。
520  </para>
521 </sect2>
522
523 <sect2 id="runtime-config-load-balancing-settings">
524
525  <!--
526  <title>Load Balancing Settings</title>
527  -->
528  <title>負荷分散の設定</title>
529
530  <variablelist>
531
532   <varlistentry id="guc-load-balance-mode" xreflabel="load_balance_mode">
533    <term><varname>load_balance_mode</varname> (<type>boolean</type>)
534     <indexterm>
535      <!--
536      <primary><varname>load_balance_mode</varname> configuration parameter</primary>
537      -->
538      <primary><varname>load_balance_mode</varname> 設定パラメータ</primary>
539     </indexterm>
540    </term>
541    <listitem>
542     <para>
543      <!--
544      When set to on, <productname>Pgpool-II</productname> enables the
545      load balancing on incoming <acronym>SELECT</acronym> queries.
546      i.e. <acronym>SELECT</acronym> queries from the clients gets distributed to
547      the configured <productname>PostgreSQL</> backends.
548      Default is off.
549      -->
550      onに設定すると、<productname>Pgpool-II</productname>は入ってきた<acronym>SELECT</acronym>クエリに対する負荷分散を有効にします。
551      すなわち、クライアントからの<acronym>SELECT</acronym>クエリは設定された<productname>PostgreSQL</>バックエンドに振り分けます。
552      デフォルトはoffです。
553     </para>
554     <para>
555      <!--
556      This parameter can only be set at server start.
557      -->
558      このパラメータはサーバ起動時にのみ設定可能です。
559     </para>
560    </listitem>
561   </varlistentry>
562
563   <varlistentry id="guc-ignore-leading-white-space" xreflabel="ignore_leading_white_space">
564    <term><varname>ignore_leading_white_space</varname> (<type>boolean</type>)
565     <indexterm>
566      <!--
567      <primary><varname>ignore_leading_white_space</varname> configuration parameter</primary>
568      -->
569      <primary><varname>ignore_leading_white_space</varname> 設定パラメータ</primary>
570     </indexterm>
571    </term>
572    <listitem>
573     <para>
574      <!--
575      When set to on, <productname>Pgpool-II</productname> ignores the
576      white spaces at the beginning of SQL queries in load balancing.
577      It is useful if used with APIs like DBI/DBD:Pg which adds
578      white spaces against the user's intention.
579      -->
580      onに設定すると、負荷分散の際にSQL文行頭の空白を無視します(全角スペースは無視されません)。
581      これは、DBI/DBD:Pgのように、ユーザの意図に反してに空白を追加するようなAPIを使っているときに有用です。
582     </para>
583     <para>
584      <!--
585      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
586      -->
587      このパラメータは<productname>Pgpool-II</>の設定を再読み込みすることで変更可能です。
588     </para>
589    </listitem>
590   </varlistentry>
591
592   <varlistentry id="guc-white-function-list" xreflabel="white_function_list">
593    <term><varname>white_function_list</varname> (<type>string</type>)
594     <indexterm>
595      <!--
596      <primary><varname>white_function_list</varname> configuration parameter</primary>
597      -->
598      <primary><varname>white_function_list</varname> 設定パラメータ</primary>
599     </indexterm>
600    </term>
601    <listitem>
602     <para>
603      <!--
604      Specifies a comma separated list of function names that
605      <emphasis>DO NOT</emphasis> update the database. SELECTs including
606      functions <emphasis>not specified </emphasis> in this list are not load balanced.
607      These are replicated among all the DB nodes in Replication mode,
608      sent to the primary node only in Maste Slave mode.
609      -->
610      データベースに対して更新を<emphasis>行なわない</emphasis>関数名をコンマ区切りで指定します。
611      このリストに<emphasis>指定されていない</emphasis>関数呼び出しを含むSELECTは負荷分散されません。
612      これらのクエリはレプリケーションモードにおいてはすべてのDBノードで複製され、マスタースレーブモードにおいてはプライマリノードにのみ送信されます。
613     </para>
614     <para>
615      <!--
616      You can use regular expression to match function names,
617      to which <literal>^</> and <literal>$</> are automatically added.
618      -->
619      関数名のマッチングに正規表現を使うことができます。
620      正規表現には自動的に<literal>^</literal>と<literal>$</literal>が付与されます。
621     </para>
622
623     <example id="example-white-function-list-1">
624      <!--
625      <title>Using regular expression</title>
626      -->
627      <title>正規表現の使用</title>
628      <para>
629       <!--
630       If you have prefixed all your read only function
631       with 'get_' or 'select_', You can
632       set the <xref linkend="guc-white-function-list"> like below:
633       -->
634       もし読み出しのみを行う関数が"get_"あるいは"select_"で始まるようにしてあるのであれば、<xref linkend="guc-white-function-list">を以下のように設定可能です。
635	<programlisting>
636	 white_function_list = 'get_.*,select_.*'
637	</programlisting>
638      </para>
639     </example>
640
641     <note>
642      <para>
643       <productname>Pgpool-II</productname>はリストを参照する際に、暗黙のうちに入力SQLの関数名からスキーマ修飾部分を削除するため、<xref linkend="guc-white-function-list">でスキーマ修飾を使えません。
644	その結果、リスト中のスキーマ修飾された関数名は、決して入力SQLの関数と一致しません。
645      </para>
646     </note>
647
648     <para>
649      <!--
650      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
651      -->
652      このパラメータは<productname>Pgpool-II</>の設定を再読み込みすることで変更可能です。
653     </para>
654    </listitem>
655   </varlistentry>
656
657   <varlistentry id="guc-black-function-list" xreflabel="black_function_list">
658    <term><varname>black_function_list</varname> (<type>string</type>)
659     <indexterm>
660      <!--
661      <primary><varname>black_function_list</varname> configuration parameter</primary>
662      -->
663      <primary><varname>black_function_list</varname> 設定パラメータ</primary>
664     </indexterm>
665    </term>
666    <listitem>
667     <para>
668      <!--
669      Specifies a comma separated list of function names that
670      <emphasis>DO</emphasis> update the database.
671      SELECTs including functions <emphasis>specified</emphasis> in this list are
672      not load balanced.
673      These are replicated among all the DB nodes in Replication mode,
674      sent to the primary node only in Maste Slave mode.
675      -->
676      データベースに対して更新を<emphasis>行う</emphasis>関数名をコンマ区切りで指定します。
677      このリストに<emphasis>指定された</emphasis>関数呼び出しを含むSELECTは負荷分散されません。
678      これらのクエリはレプリケーションモードにおいてはすべてのDBノードで複製され、マスタースレーブモードにおいてはプライマリノードにのみ送信されます。
679     </para>
680     <para>
681      <!--
682      You can use regular expression to match function names,
683      to which <literal>^</> and <literal>$</> are automatically added.
684      -->
685      関数名のマッチングに正規表現を使うことができます。
686      正規表現には自動的に<literal>^</literal>と<literal>$</literal>が付与されます。
687     </para>
688
689     <example id="example-black-function-list-1">
690      <!--
691      <title>Using regular expression</title>
692      -->
693      <title>正規表現の使用</title>
694      <para>
695       <!--
696       If you have prefixed all your updating functions
697       with 'set_', 'update_', 'delete_' or 'insert_', You can
698       set the <xref linkend="guc-black-function-list"> like below:
699       -->
700       もし更新を行う関数が"set_"、"update_"、"delete_"、あるいは"insert_"で始まるようにしてあるのであれば、<xref linkend="guc-black-function-list">を以下のように設定可能です。
701	<programlisting>
702	 black_function_list = 'nextval,setval,set_.*,update_.*,delete_.*,insert_.*'
703	</programlisting>
704      </para>
705     </example>
706
707     <note>
708      <para>
709       <productname>Pgpool-II</productname>はリストを参照する際に、暗黙のうちに入力SQLの関数名からスキーマ修飾部分を削除するため、<xref linkend="guc-black-function-list">でスキーマ修飾を使えません。
710	その結果、リスト中のスキーマ修飾された関数名は、決して入力SQLの関数と一致しません。
711      </para>
712     </note>
713
714     <note>
715      <para>
716       <!--
717       <xref linkend="guc-black-function-list"> and <xref linkend="guc-white-function-list">
718       are mutually exclusive and only one of the two lists can be set in the configuration.
719       -->
720       <xref linkend="guc-black-function-list">と<xref linkend="guc-white-function-list">は互いに排他的で、2つのリストの内、どちらか一方のみ設定することができます。
721      </para>
722     </note>
723
724     <example id="example-black-function-list-2">
725      <!--
726      <title>Configuring to send <literal>nextval()</literal> and <literal>setval()</literal> to the proper backend</title>
727      -->
728      <title><literal>nextval()</literal>と<literal>setval()</literal>を適切なバックエンドに送る設定</title>
729      <para>
730       <!--
731       Prior to <productname>Pgpool-II</productname><emphasis>V3.0</emphasis>,
732       <literal>nextval()</literal> and <literal>setval()</literal> were known as functions writing to the database.
733       You can configure this by setting <xref linkend="guc-black-function-list">
734       and <xref linkend="guc-white-function-list"> as follows
735       -->
736       <productname>Pgpool-II</productname> <emphasis>V3.0</emphasis>より前のバージョンでは、固定で<literal>nextval()</literal>と<literal>setval()</literal>がデータベースに書き込みを行なう関数であると認識されていました。
737       以下のように<xref linkend="guc-white-function-list">と<xref linkend="guc-black-function-list">を設定することで、それと同じように動作させることができます。
738	 <programlisting>
739	  white_function_list = ''
740	  black_function_list = 'nextval,setval,lastval,currval'
741	 </programlisting>
742      </para>
743     </example>
744
745     <note>
746      <para>
747       <!--
748       <productname>PostgreSQL</> also contains <literal>lastval()</literal> and
749       <literal>currval()</literal> in addition to
750       <literal>nextval()</literal> and <literal>setval()</literal>.
751       Though <literal>lastval()</literal> and <literal>currval()</literal>
752       are not writing function type, but it is advised to treat
753       <literal>lastval()</literal> and <literal>currval()</literal>
754       as writing functions to avoid errors which occur when
755       these functions are accidentally load balanced.
756       -->
757       <productname>PostgreSQL</>には<literal>nextval()</literal>と<literal>setval()</literal>に加え、<literal>lastval()</literal>と<literal>currval()</literal>があります。
758       <literal>lastval()</literal>と<literal>currval()</literal>は書き込みを行う関数ではありませんが、これらの関数が負荷分散されることで発生するエラーを防ぐため、<literal>lastval()</literal>と<literal>currval()</literal>を書き込みを行う関数として扱うのが望ましいです。
759      </para>
760     </note>
761     <para>
762      <!--
763      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
764      -->
765      このパラメータは<productname>Pgpool-II</>の設定を再読み込みすることで変更可能です。
766     </para>
767    </listitem>
768   </varlistentry>
769
770   <varlistentry id="guc-database-redirect-preference-list" xreflabel="database_redirect_preference_list">
771    <term><varname>database_redirect_preference_list</varname> (<type>string</type>)
772     <indexterm>
773      <!--
774      <primary><varname>database_redirect_preference_list</varname> configuration parameter</primary>
775      -->
776      <primary><varname>database_redirect_preference_list</varname> 設定パラメータ</primary>
777     </indexterm>
778    </term>
779    <listitem>
780     <para>
781      <!--
782      Specifies the list of <replaceable>"database-name:node id"</replaceable> pairs
783      to send <acronym>SELECT</acronym> queries to a particular backend
784      node for a particular database connection.
785      For example, by specifying "test:1", <productname>Pgpool-II</productname>
786      will redirect all <acronym>SELECT</acronym> queries to the backend node of ID 1 for
787      the connection to "test" database.
788      You can specify multiple <replaceable>"database name:node id"</replaceable> pair by separating them
789      using comma (,).
790      -->
791      特定のデータベース接続では<acronym>SELECT</acronym>クエリが特定のバックエンドノードに送信されるように、"<replaceable>データベース名:ノードID</replaceable>"ペアのリストを指定します。
792      たとえば"test:1"とした場合、"test"データベースへの接続においては、<productname>Pgpool-II</productname>は全ての<acronym>SELECT</acronym>クエリをIDが1のバックエンドノードに送信します。
793      複数の"<replaceable>データベース名:ノードID</replaceable>"のペアを カンマ(,)で区切って指定することができます。
794     </para>
795     <para>
796      <!--
797      Regular expressions are also accepted for database name.
798      You can use special keywords as <replaceable>node id</replaceable>.
799      If <emphasis>"primary"</emphasis> is specified, queries are sent to the primary node, and
800      if <emphasis>"standby"</emphasis> is specified, one of the standby nodes are selected randomly
801      based on weights.
802      -->
803      データベース名には正規表現を指定することできます。
804      <replaceable>ノードID</replaceable>には特別なキーワードを使うことができます。
805      "<emphasis>primary</emphasis>"が指定された場合にはクエリはプライマリノードに送られます。
806      また、"<emphasis>standby</emphasis>"が指定された場合はスタンバイノードのうちどれかをウェイトに応じてランダムに選択します。
807     </para>
808
809     <example id="example-database-redirect-list">
810      <!--
811      <title>Using database_redirect_preference_list</title>
812      -->
813      <title>database_redirect_preference_listの利用</title>
814      <para>
815       <!--
816       If you want to configure the following <acronym>SELECT</acronym> query routing rules:
817       -->
818       <acronym>SELECT</acronym>クエリのルーティングルールを以下のように設定したい場合:
819      </para>
820
821      <itemizedlist>
822       <listitem>
823	<para>
824	 <!--
825	 Route all <acronym>SELECT</acronym> queries on <literal>postgres</literal>
826	 database to the primary backend node.
827	 -->
828	 全ての<literal>postgres</literal>データベースにおける<acronym>SELECT</acronym>クエリはプライマリバックエンドノードに送る。
829	</para>
830       </listitem>
831       <listitem>
832	<para>
833	 <!--
834	 Route all <acronym>SELECT</acronym> queries on <literal>mydb0</literal> or on
835	 <literal>mydb1</literal> databases to backend node of ID 1.
836	 -->
837	 全ての<literal>mydb0</literal>または<literal>mydb1</literal>データベースにおける<acronym>SELECT</acronym>クエリはIDが1のバックエンドノードに送る。
838	</para>
839       </listitem>
840       <listitem>
841	<para>
842	 <!--
843	 Route all <acronym>SELECT</acronym> queries on <literal>mydb2</literal>
844	 database to standby backend nodes.
845	 -->
846	 全ての<literal>mydb2</literal>データベースにおける<acronym>SELECT</acronym>クエリはスタンバイバックエンドノードに送る。
847	</para>
848       </listitem>
849
850      </itemizedlist>
851      <para>
852       <!--
853       then the <xref linkend="guc-database-redirect-preference-list"> will be configured as follows:
854       -->
855       <xref linkend="guc-database-redirect-preference-list">は以下のように設定します。
856	<programlisting>
857	 database_redirect_preference_list = 'postgres:primary,mydb[01]:1,mydb2:standby'
858	</programlisting>
859      </para>
860     </example>
861
862     <para>
863      <!--
864      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
865      -->
866      このパラメータは<productname>Pgpool-II</>の設定を再読み込みすることで変更可能です。
867     </para>
868    </listitem>
869   </varlistentry>
870
871   <varlistentry id="guc-app-name-redirect-preference-list" xreflabel="app_name_redirect_preference_list">
872    <term><varname>app_name_redirect_preference_list</varname> (<type>string</type>)
873     <indexterm>
874      <!--
875      <primary><varname>app_name_redirect_preference_list</varname> configuration parameter</primary>
876      -->
877      <primary><varname>app_name_redirect_preference_list</varname> 設定パラメータ</primary>
878     </indexterm>
879    </term>
880    <listitem>
881
882     <para>
883      <!--
884      Specifies the list of <replaceable>"application-name:node id"</replaceable> pairs
885      to send <acronym>SELECT</acronym> queries to a particular backend
886      node for a particular client application connection.
887      -->
888      特定のクライアントアプリケーションの接続では<acronym>SELECT</acronym>クエリが特定のバックエンドノードに送信されるように、"<replaceable>アプリケーション名:ノードID</replaceable>"ペアのリストを指定します。
889     </para>
890
891     <note>
892      <para>
893       <!--
894       The "Application name" is a name specified by a client when it connects to database,
895       and is avalable in <productname>PostgreSQL</> <emphasis>V9.0</> or later.
896       -->
897       「アプリケーション名」とはクライアントがデータベースに接続する時に指定する名称で、<productname>PostgreSQL</> <emphasis>V9.0</>以降で利用可能です。
898      </para>
899     </note>
900
901     <para>
902      <!--
903      For example, application name of <command>psql</command> command is
904      <literal>"psql"</literal>
905      -->
906      たとえば、<command>psql</command>コマンドのアプリケーション名は"<literal>psql</literal>"です。
907     </para>
908
909     <note>
910      <para>
911       <!--
912       <productname>Pgpool-II</productname> recognizes the application name
913       only specified in the start-up packet sent from the client.
914       Although a client can provide the application name
915       later in the session, but that does not get considered by the
916       <productname>Pgpool-II</productname> for query routing.
917       -->
918       <productname>Pgpool-II</productname>は、クライアントから送信されたスタートアップパケットに含まれるアプリケーション名だけを認識します。
919       クライアントは事後にセッションの中でアプリケーション名を指定できますが、それは<productname>Pgpool-II</productname>のクエリルーティングでは考慮されません。
920      </para>
921     </note>
922
923     <para>
924      <!--
925      The notion of <xref linkend="guc-app-name-redirect-preference-list">
926      is same as the <xref linkend="guc-database-redirect-preference-list">
927      thus you can also use the regular expressions for application names.
928      Similarly special keyword <emphasis>"primary"</emphasis> indicates the primary node and
929      <emphasis>"standby"</emphasis> indicates one of standby nodes.
930      -->
931      <xref linkend="guc-app-name-redirect-preference-list">の記法は<xref linkend="guc-database-redirect-preference-list">と同じですので、アプリケーション名には正規表現も使用できます。
932	同様に特別なキーワード"<emphasis>primary</emphasis>"はプライマリノードを、"<emphasis>standby</emphasis>"はスタンバイサーバのいずれかを意味します。
933     </para>
934
935     <example id="example-app-name-redirect-list">
936      <!--
937      <title>Using app-name_redirect_preference_list</title>
938      -->
939      <title>app_name_redirect_preference_listの利用</title>
940      <para>
941       <!--
942       If you want to configure the following <acronym>SELECT</acronym> query routing rules:
943       -->
944       <acronym>SELECT</acronym>クエリのルーティングルールを以下のように設定したい場合:
945      </para>
946
947      <itemizedlist>
948       <listitem>
949	<para>
950	 <!--
951	 Route all <acronym>SELECT</acronym> from <literal>psql</literal>
952	 client to the primary backend node.
953	 -->
954	 全ての<literal>psql</literal>クライアントからの<acronym>SELECT</acronym>クエリはプライマリバックエンドノードに送る。
955	</para>
956       </listitem>
957       <listitem>
958	<para>
959	 <!--
960	 Route all <acronym>SELECT</acronym> queries from <literal>myapp1</literal>
961	 client to backend node of ID 1.
962	 -->
963	 全ての<literal>myapp1</literal>クライアントからの<acronym>SELECT</acronym>クエリはIDが1のバックエンドノードに送る。
964	</para>
965       </listitem>
966       <listitem>
967	<para>
968	 <!--
969	 Route all <acronym>SELECT</acronym> queries from <literal>myapp2</literal>
970	 client to standby backend nodes.
971	 -->
972	 全ての<literal>myapp2</literal>クライアントからの<acronym>SELECT</acronym>クエリはスタンバイバックエンドノードに送る。
973	</para>
974       </listitem>
975
976      </itemizedlist>
977      <para>
978       <!--
979       then the <xref linkend="guc-app-name-redirect-preference-list"> will be configured as follows:
980       -->
981       <xref linkend="guc-app-name-redirect-preference-list">は以下のように設定します。
982	<programlisting>
983	 app_name_redirect_preference_list = 'psql:primary,myapp1:1,myapp2:standby'
984	</programlisting>
985      </para>
986     </example>
987
988     <note>
989      <para>
990       <!--
991       <xref linkend="guc-app-name-redirect-preference-list"> takes precedence
992       over the <xref linkend="guc-database-redirect-preference-list">.
993       -->
994       <xref linkend="guc-app-name-redirect-preference-list">は、<xref linkend="guc-database-redirect-preference-list">よりも優先されます。
995      </para>
996     </note>
997
998     <caution>
999      <para>
1000       <!--
1001       <acronym>JDBC</acronym> driver postgreSQL-9.3 and earlier versions
1002       does not send the application name in the startup packet even if
1003       the application name is specified using the <acronym>JDBC</acronym>
1004       driver option <literal>"ApplicationName"</literal> and
1005       <literal>"assumeMinServerVersion=9.0"</literal>.
1006       If you want to use the <xref linkend="guc-app-name-redirect-preference-list">
1007       feature through <acronym>JDBC</acronym>, use postgreSQL-9.4 or later version of the driver.
1008       -->
1009       <acronym>JDBC</acronym>ドライバのpostgresql-9.3以前のバージョンでは、<acronym>JDBC</acronym>ドライバの"<literal>ApplicationName</literal>" と "<literal>assumeMinServerVersion=9.0</literal>"オプションを指定してもスタートアップパケットの中にアプリケーション名を含ません。
1010       <acronym>JDBC</acronym>から<xref linkend="guc-app-name-redirect-preference-list">機能を使用したければ、postgresql-9.4 以降のドライバをお使いください
1011      </para>
1012     </caution>
1013
1014     <para>
1015      <!--
1016      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
1017      -->
1018      このパラメータは<productname>Pgpool-II</>の設定を再読み込みすることで変更可能です。
1019     </para>
1020    </listitem>
1021   </varlistentry>
1022
1023   <varlistentry id="guc-allow-sql-comments" xreflabel="allow_sql_comments">
1024    <term><varname>allow_sql_comments</varname> (<type>boolean</type>)
1025     <indexterm>
1026      <!--
1027      <primary><varname>allow_sql_comments</varname> configuration parameter</primary>
1028      -->
1029      <primary><varname>allow_sql_comments</varname> 設定パラメータ</primary>
1030     </indexterm>
1031    </term>
1032    <listitem>
1033     <para>
1034      <!--
1035      When set to on, <productname>Pgpool-II</productname> ignore the
1036      <acronym>SQL</acronym> comments when identifying if the load balance
1037      or query cache is possible on the query.
1038      When this parameter is set to off, the <acronym>SQL</acronym> comments
1039      on the query could effectively prevent the query from being
1040      load balanced or cached (pre <productname>Pgpool-II</productname>
1041      <emphasis>V3.4</emphasis> behavior).
1042      -->
1043      onに設定すると、<productname>Pgpool-II</productname>は負荷分散やクエリキャッシュができるかどうかの判定の際に<acronym>SQL</acronym>コメントを無視します。
1044      このパラメータがoffに設定されている場合、クエリの<acronym>SQL</acronym>コメントにより、クエリの負荷分散やキャッシュを防止することができます。
1045      (<productname>Pgpool-II</productname> <emphasis>V3.4</emphasis>より前のバージョンの動作です)。
1046     </para>
1047     <para>
1048      <!--
1049      This parameter can be changed by reloading the <productname>Pgpool-II</> configurations.
1050      You can also use <xref linkend="SQL-PGPOOL-SET"> command to alter the value of
1051      this parameter for a current session.
1052      -->
1053      このパラメータは<productname>Pgpool-II</>の設定を再読み込みすることで変更可能です。
1054      現在のセッションでのパラメータ値は、<xref linkend="SQL-PGPOOL-SET">コマンドで変更することもできます。
1055     </para>
1056    </listitem>
1057   </varlistentry>
1058
1059  </variablelist>
1060 </sect2>
1061</sect1>
1062