バージョンごとのドキュメント一覧

20.12. ロック管理 #

<title>Lock Management</title>
deadlock_timeout (integer) #

This is the amount of time to wait on a lock before checking to see if there is a deadlock condition. The check for deadlock is relatively expensive, so the server doesn't run it every time it waits for a lock. We optimistically assume that deadlocks are not common in production applications and just wait on the lock for a while before checking for a deadlock. Increasing this value reduces the amount of time wasted in needless deadlock checks, but slows down reporting of real deadlock errors. If this value is specified without units, it is taken as milliseconds. The default is one second (<literal>1s</literal>), which is probably about the smallest value you would want in practice. On a heavily loaded server you might want to raise it. Ideally the setting should exceed your typical transaction time, so as to improve the odds that a lock will be released before the waiter decides to check for deadlock. Only superusers and users with the appropriate <literal>SET</literal> privilege can change this setting. これは、デッドロック状態があるかどうかを調べる前にロックを待つ時間です。 デッドロックの検査は比較的高価なので、サーバはロックを待つ度にこれを実行するわけではありません。 楽天的ですがデッドロックは実用レベルのアプリケーションでは頻繁に発生しないと仮定し、デッドロックの検査の前にしばらくはロック待ちをします。 この値を増やすことにより必要のないデッドロックの検査で無駄にされる時間は減りますが、本当にデッドロックがあった場合の報告が遅れます。 この値が単位なしで指定された場合は、ミリ秒単位であるとみなします。 デフォルトは1秒(1s)で、おそらく実用の際にはこれ以上は必要でしょう。 負荷の大きいサーバではもっと必要かもしれません。 理想としてはこの設定は通常のトランザクションにかかる時間を超えているべきです。 そうすればロック待ちトランザクションがデッドロックの検査をする前にロックが解除される可能性が改善されます。 スーパーユーザと、適切なSET権限を持つユーザのみがこの設定を変更することができます。

When <xref linkend="guc-log-lock-waits"/> is set, this parameter also determines the amount of time to wait before a log message is issued about the lock wait. If you are trying to investigate locking delays you might want to set a shorter than normal <varname>deadlock_timeout</varname>. log_lock_waitsが設定された場合、このパラメータはロック待機に関するログメッセージを出力する前の待機時間を決定します。 ロック遅延の調査を行う場合は、通常のdeadlock_timeoutよりも短い値を設定することを勧めます。

max_locks_per_transaction (integer) #

The shared lock table has space for <varname>max_locks_per_transaction</varname> objects (e.g., tables) per server process or prepared transaction; hence, no more than this many distinct objects can be locked at any one time. This parameter limits the average number of object locks used by each transaction; individual transactions can lock more objects as long as the locks of all transactions fit in the lock table. This is <emphasis>not</emphasis> the number of rows that can be locked; that value is unlimited. The default, 64, has historically proven sufficient, but you might need to raise this value if you have queries that touch many different tables in a single transaction, e.g., query of a parent table with many children. This parameter can only be set at server start. 共有ロックテーブルは、プロセスごと、あるいは準備されたトランザクションごとのmax_locks_per_transactionオブジェクト(たとえばテーブル)空間を持っています。 したがって、ある時点でこの数以上の個々のオブジェクトをロックすることはできません。 このパラメータは各トランザクションで使用するオブジェクトロックの平均値を制限します。 個々のトランザクションでは、このロックテーブルにすべてのトランザクションのロックが収まる限りオブジェクトのロックを獲得できます。 これは、ロックできる行数ではありません。この値には制限がありません。 デフォルトの64は、経験的に十分であると証明されていますが、単一のトランザクションで数多くの異なるテーブルをいじる問い合わせがいる場合、たとえば、数多くの子テーブルを持つ親テーブルの問い合わせなど、この値を大きくする必要があるかも知れません。 このパラメータはサーバ起動時のみ設定されます。

When running a standby server, you must set this parameter to have the same or higher value as on the primary server. Otherwise, queries will not be allowed in the standby server. スタンバイサーバを運用している場合、このパラメータはプライマリサーバでの設定と同じ、もしくはより高い値に設定しなければなりません。そうしないと問い合わせがスタンバイサーバ内で受け入れられません。

max_pred_locks_per_transaction (integer) #

The shared predicate lock table has space for <varname>max_pred_locks_per_transaction</varname> objects (e.g., tables) per server process or prepared transaction; hence, no more than this many distinct objects can be locked at any one time. This parameter limits the average number of object locks used by each transaction; individual transactions can lock more objects as long as the locks of all transactions fit in the lock table. This is <emphasis>not</emphasis> the number of rows that can be locked; that value is unlimited. The default, 64, has historically proven sufficient, but you might need to raise this value if you have clients that touch many different tables in a single serializable transaction. This parameter can only be set at server start. 共有述語ロックテーブルは、プロセスごと、あるいは準備されたトランザクションごとのmax_pred_locks_per_transactionオブジェクト(たとえばテーブル)空間を持っています。 したがって、ある時点でこの数以上の個々のオブジェクトをロックすることはできません。 このパラメータは各トランザクションで使用するオブジェクトロックの平均値を制限します。 個々のトランザクションでは、このロックテーブルにすべてのトランザクションのロックが収まる限りオブジェクトのロックを獲得できます。 これはロック可能な行数ではありません。その値は無制限です。 デフォルトは64で、過去の経験から十分であることがわかっていますが、単一のシリアライザブルトランザクションで数多くの異なるテーブルに触れるクライアントが存在する場合、この値を大きくする必要があることがあります。 このパラメータはサーバ起動時のみ設定可能です。

max_pred_locks_per_relation (integer) #

This controls how many pages or tuples of a single relation can be predicate-locked before the lock is promoted to covering the whole relation. Values greater than or equal to zero mean an absolute limit, while negative values mean <xref linkend="guc-max-pred-locks-per-transaction"/> divided by the absolute value of this setting. The default is -2, which keeps the behavior from previous versions of <productname>PostgreSQL</productname>. This parameter can only be set in the <filename>postgresql.conf</filename> file or on the server command line. リレーション全体をカバーするロックに昇格する前に、一つリレーションの中で述語ロックできるページ数あるいはタプル数を指定します。 0以上の値は、絶対的な制限を表し、負の数はmax_pred_locks_per_transactionをその絶対値で割ったものを表します。 デフォルトは-2で、以前のバージョンのPostgreSQLの振る舞いを維持します。 このパラメータはpostgresql.confファイル、または、サーバのコマンドラインのみで設定可能です。

max_pred_locks_per_page (integer) #

This controls how many rows on a single page can be predicate-locked before the lock is promoted to covering the whole page. The default is 2. This parameter can only be set in the <filename>postgresql.conf</filename> file or on the server command line. ページ全体をカバーするロックに昇格する前に、一つページの中で述語ロックできる行数を指定します。 デフォルトは2です。 このパラメータはpostgresql.confファイル、または、サーバのコマンドラインのみで設定可能です。