The <filename>pg_buffercache</filename> module provides a means for
examining what's happening in the shared buffer cache in real time.
It also offers a low-level way to evict data from it, for testing
purposes.
pg_buffercache
モジュールは、共有バッファキャッシュで何が起きているかをリアルタイムに確認する方法を提供します。
また、テスト目的で、低レベルでデータを取り出す方法も提供します。
This module provides the <function>pg_buffercache_pages()</function>
function (wrapped in the <structname>pg_buffercache</structname> view), the
<function>pg_buffercache_numa_pages()</function> function (wrapped in the
<structname>pg_buffercache_numa</structname> view), the
<function>pg_buffercache_summary()</function> function, the
<function>pg_buffercache_usage_counts()</function> function, the
<function>pg_buffercache_evict()</function> function, the
<function>pg_buffercache_evict_relation()</function> function and the
<function>pg_buffercache_evict_all()</function> function.
《マッチ度[54.871795]》このモジュールは、pg_buffercache_pages()
関数(pg_buffercache
ビューでラップされています)、pg_buffercache_summary()
関数、pg_buffercache_usage_counts()
関数、およびpg_buffercache_evict()
関数を提供します。
《機械翻訳》このモジュールはpg_buffercache_pages()
pg_buffercache
関数にラップされたビュー、pg_buffercache_numa_pages()
pg_buffercache_numa
関数にラップされたビュー、pg_buffercache_summary()
関数、pg_buffercache_usage_counts()
関数、pg_buffercache_evict()
関数、pg_buffercache_evict_relation()
関数、pg_buffercache_evict_all()
関数です。
The <function>pg_buffercache_pages()</function> function returns a set of
records, each row describing the state of one shared buffer entry. The
<structname>pg_buffercache</structname> view wraps the function for
convenient use.
pg_buffercache_pages()
関数は、各行が1つの共有バッファエントリの状態を記述するレコード集合を返します。
pg_buffercache
ビューは、簡単に利用できるようにこの関数をラップしています。
The <function>pg_buffercache_numa_pages()</function> function provides
<acronym>NUMA</acronym> node mappings for shared buffer entries. This
information is not part of <function>pg_buffercache_pages()</function>
itself, as it is much slower to retrieve.
The <structname>pg_buffercache_numa</structname> view wraps the function for
convenient use.
《マッチ度[52.023121]》pg_buffercache_pages()
関数は、各行が1つの共有バッファエントリの状態を記述するレコード集合を返します。
pg_buffercache
ビューは、簡単に利用できるようにこの関数をラップしています。
《機械翻訳》pg_buffercache_numa_pages()
関数は、共有ノードエントリのNUMAバッファマッピングを提供します。
この情報はpg_buffercache_pages()
自分自身のパートではありません。
これは、取得に時間がかかるためです。
pg_buffercache_numa
ビューは、使用に便利なように関数をラップします。
The <function>pg_buffercache_summary()</function> function returns a single
row summarizing the state of the shared buffer cache.
pg_buffercache_summary()
関数は、共有バッファキャッシュの状態を要約した1行を返します。
The <function>pg_buffercache_usage_counts()</function> function returns a set
of records, each row describing the number of buffers with a given usage
count.
pg_buffercache_usage_counts()
関数は、各行が対応する使用カウントを持つバッファの数を記述するレコード集合を返します。
By default, use of the above functions is restricted to superusers and roles
with privileges of the <literal>pg_monitor</literal> role. Access may be
granted to others using <command>GRANT</command>.
デフォルトでは、上記関数の使用はスーパーユーザとpg_monitor
ロールの権限を持つロールに限定されています。
他のユーザに対してはGRANT
を使用してアクセス権を付与できます。
The <function>pg_buffercache_evict()</function> function allows a block to
be evicted from the buffer pool given a buffer identifier. Use of this
function is restricted to superusers only.
pg_buffercache_evict()
関数は、バッファ識別子を指定して、ブロックをバッファプールから退避させることができます。
この関数の使用はスーパーユーザのみに制限されています。
The <function>pg_buffercache_evict_relation()</function> function allows all
unpinned shared buffers in the relation to be evicted from the buffer pool
given a relation identifier. Use of this function is restricted to
superusers only.
《マッチ度[74.042553]》pg_buffercache_evict()
関数は、バッファ識別子を指定して、ブロックをバッファプールから退避させることができます。
この関数の使用はスーパーユーザのみに制限されています。
《機械翻訳》pg_buffercache_evict_relation()
関数は、リレーション識別子を与えられたバッファプールから、リレーション内のピン止めされていないすべての共有バッファを立ち退かせることを許可します。
この関数の使用はスーパーユーザのみに制限されています。
The <function>pg_buffercache_evict_all()</function> function allows all
unpinned shared buffers to be evicted in the buffer pool. Use of this
function is restricted to superusers only.
《マッチ度[67.934783]》pg_buffercache_evict()
関数は、バッファ識別子を指定して、ブロックをバッファプールから退避させることができます。
この関数の使用はスーパーユーザのみに制限されています。
《機械翻訳》pg_buffercache_evict_all()
関数は、ピン止めされていないすべての共有バッファをバッファプール内で退避させることができます。
この関数の使用はスーパーユーザのみに制限されています。
pg_buffercache
ビュー #The definitions of the columns exposed by the view are shown in <xref linkend="pgbuffercache-columns"/>. ビューによって公開されている列の定義を表 F.14に示します。
表F.14 pg_buffercache
の列
Column Type 列 型 Description 説明 |
---|
ID, in the range 1..<varname>shared_buffers</varname>
1から |
Filenode number of the relation リレーションのファイルノード番号 |
Tablespace OID of the relation リレーションのテーブル空間OID |
Database OID of the relation リレーションのデータベースOID |
Fork number within the relation; see
<filename>common/relpath.h</filename>
リレーション内のフォーク番号。 |
Page number within the relation リレーション内のページ番号 |
Is the page dirty? ダーティページかどうか |
Clock-sweep access count Clock-sweepアクセスカウント |
Number of backends pinning this buffer このバッファをピン留めしているバックエンドの数 |
There is one row for each buffer in the shared cache. Unused buffers are
shown with all fields null except <structfield>bufferid</structfield>. Shared system
catalogs are shown as belonging to database zero.
共有キャッシュ内の各バッファに対して、1行が存在します。
未使用のバッファは、bufferid
を除き、すべてのフィールドがNULLになります。
共有システムカタログは、OIDがゼロのデータベースに属するものとして表示されます。
Because the cache is shared by all the databases, there will normally be
pages from relations not belonging to the current database. This means
that there may not be matching join rows in <structname>pg_class</structname> for
some rows, or that there could even be incorrect joins. If you are
trying to join against <structname>pg_class</structname>, it's a good idea to
restrict the join to rows having <structfield>reldatabase</structfield> equal to
the current database's OID or zero.
キャッシュはすべてのデータベースで共有されているため、現在のデータベースに属さないリレーションのページも表示されます。
これは、一部の行に対して一致するpg_class
の結合行が存在しない、間違った結合をしてしまう可能性すらあることを意味します。
pg_class
に対して結合しようとする場合、現在のデータベースのOIDまたは0と等しいreldatabase
を持つ行に限定して結合することをお勧めします。
Since buffer manager locks are not taken to copy the buffer state data that
the view will display, accessing <structname>pg_buffercache</structname> view
has less impact on normal buffer activity but it doesn't provide a consistent
set of results across all buffers. However, we ensure that the information of
each buffer is self-consistent.
ビューが表示するバッファ状態データのコピーのために、バッファマネージャのロックを取得しません。このため、pg_buffercache
ビューへのアクセスは、通常のバッファ処理への影響がより小さくなりますが、バッファすべてに渡る矛盾のない結果を提供しません。
しかしながら、各バッファの情報に自己矛盾がないことは保証されます。
pg_buffercache_numa
View #The definitions of the columns exposed by the view are shown in <xref linkend="pgbuffercache-numa-columns"/>. 《マッチ度[92.660550]》ビューによって公開されている列の定義を表 F.14に示します。
表F.15 pg_buffercache_numa
Columns
Column Type 列 型 Description 説明 |
---|
ID, in the range 1..<varname>shared_buffers</varname>
1から |
number of OS memory page for this buffer 《機械翻訳》このバッファのOSメモリページの数。 |
ID of <acronym>NUMA</acronym> node 《機械翻訳》NUMAノードのID。 |
As <acronym>NUMA</acronym> node ID inquiry for each page requires memory pages to be paged-in, the first execution of this function can take a noticeable amount of time. In all the cases (first execution or not), retrieving this information is costly and querying the view at a high frequency is not recommended. 《機械翻訳》各ノードのNUMAページID照会ではメモリページがページインされる必要があるため、この関数の最初の実行にはかなりの時間がかかる場合があります。 いずれの場合も(最初の実行の有無にかかわらず)、この情報の取得にはコストがかかり、高い頻度でビューを照会することはお薦めしません。
When determining the <acronym>NUMA</acronym> node, the view touches all memory pages for the shared memory segment. This will force allocation of the shared memory, if it wasn't allocated already, and the memory may get allocated in a single <acronym>NUMA</acronym> node (depending on system configuration). 《機械翻訳》NUMAノードを決定する場合、ビューは共有メモリページのメモリセグメントすべてに接触します。 これにより、共有メモリのアロケーションがまだ割り当てられていない場合は強制的に割り当てられ、メモリは単一のNUMAノードに割り当てられる可能性があります(システム設定に依存します)。
pg_buffercache_summary()
関数 #The definitions of the columns exposed by the function are shown in <xref linkend="pgbuffercache-summary-columns"/>. 関数によって公開されている列の定義を表 F.16に示します。
表F.16 pg_buffercache_summary()
出力列
Column Type 列 型 Description 説明 |
---|
Number of used shared buffers 使用中の共有バッファの数 |
Number of unused shared buffers 未使用の共有バッファの数 |
Number of dirty shared buffers ダーティ共有バッファの数 |
Number of pinned shared buffers 固定された共有バッファの数 |
Average usage count of used shared buffers 使用中の共有バッファの平均使用カウント |
The <function>pg_buffercache_summary()</function> function returns a
single row summarizing the state of all shared buffers. Similar and more
detailed information is provided by the
<structname>pg_buffercache</structname> view, but
<function>pg_buffercache_summary()</function> is significantly cheaper.
pg_buffercache_summary()
関数は、すべての共有バッファの状態を要約した単一の行を返します。
同様の、より詳細な情報はpg_buffercache
ビューによって提供されますが、pg_buffercache_summary()
はかなり安価です。
Like the <structname>pg_buffercache</structname> view,
<function>pg_buffercache_summary()</function> does not acquire buffer
manager locks. Therefore concurrent activity can lead to minor inaccuracies
in the result.
pg_buffercache
ビューと同様に、pg_buffercache_summary()
はバッファマネージャのロックを取得しません。
そのため、同時実行中の処理によって結果に小さな不正確さが生じる可能性があります。
pg_buffercache_usage_counts()
関数 #The definitions of the columns exposed by the function are shown in <xref linkend="pgbuffercache_usage_counts-columns"/>. 関数によって公開されている列の定義を表 F.17に示します。
表F.17 pg_buffercache_usage_counts()
出力列
Column Type 列 型 Description 説明 |
---|
A possible buffer usage count 推定バッファ使用カウント |
Number of buffers with the usage count その使用カウントのバッファの数 |
Number of dirty buffers with the usage count その使用カウントのダーティバッファの数 |
Number of pinned buffers with the usage count その使用カウントの固定されたバッファの数 |
The <function>pg_buffercache_usage_counts()</function> function returns a
set of rows summarizing the states of all shared buffers, aggregated over
the possible usage count values. Similar and more detailed information is
provided by the <structname>pg_buffercache</structname> view, but
<function>pg_buffercache_usage_counts()</function> is significantly cheaper.
pg_buffercache_usage_counts()
関数は、すべての共有バッファの状態を要約した行の集合を返します。これは、推定使用カウント値に基づいて集計されます。
同様の、より詳細な情報はpg_buffercache
ビューによって提供されますが、pg_buffercache_usage_counts()
はかなり安価です。
Like the <structname>pg_buffercache</structname> view,
<function>pg_buffercache_usage_counts()</function> does not acquire buffer
manager locks. Therefore concurrent activity can lead to minor inaccuracies
in the result.
pg_buffercache
ビューと同様に、pg_buffercache_usage_counts()
はバッファマネージャのロックを取得しません。
そのため、同時実行中の処理によって結果に小さな不正確さが生じる可能性があります。
pg_buffercache_evict()
関数 #
The <function>pg_buffercache_evict()</function> function takes a buffer
identifier, as shown in the <structfield>bufferid</structfield> column of
the <structname>pg_buffercache</structname> view. It returns information
about whether the buffer was evicted and flushed. The buffer_evicted
column is true on success, and false if the buffer wasn't valid, if it
couldn't be evicted because it was pinned, or if it became dirty again
after an attempt to write it out. The buffer_flushed column is true if the
buffer was flushed. This does not necessarily mean that buffer was flushed
by us, it might be flushed by someone else. The result is immediately out
of date upon return, as the buffer might become valid again at any time due
to concurrent activity. The function is intended for developer testing
only.
《マッチ度[66.377171]》pg_buffercache_evict()
関数は、pg_buffercache
ビューのbufferid
列に示されるバッファ識別子を取ります。
成功した場合はtrueを、バッファが有効でなかった場合はfalseを、バッファが固定されていたために削除できなかった場合や、書き出そうとした後で再びダーティになった場合はfalseを返します。
バッファは同時アクティビティのためにいつでも再び有効になる可能性があるため、結果は戻されるとすぐに無効になります。
この関数は、開発者のテストのみを目的としています。
《機械翻訳》pg_buffercache
関数のbufferid
バッファに示されているように、pg_buffercache_evict()
識別子はカラムビューを取ります。
バッファが削除され、フラッシュされたかどうかに関する情報が戻されます。
バッファ_evictedカラムは、成功した場合は真です。
バッファが有効でなかった場合、固定されていたために削除できなかった場合、または書き込もうとした後に再びダーティになった場合は偽です。
バッファ_flushedカラムは、バッファがフラッシュされた場合は真です。
これは必ずしもバッファが私たちによってフラッシュされたことを意味するわけではなく、他の誰かによってフラッシュされた可能性があります。
結果では、同時アクティビティのためにバッファがいつでも再び有効になる可能性があるため、結果はすぐに期限切れになります。
関数は開発者のテスト専用です。
pg_buffercache_evict_relation()
Function #
The <function>pg_buffercache_evict_relation()</function> function is very
similar to the <function>pg_buffercache_evict()</function> function. The
difference is that the <function>pg_buffercache_evict_relation()</function>
takes a relation identifier instead of buffer identifier. It tries to
evict all buffers for all forks in that relation.
It returns the number of evicted buffers, flushed buffers and the number of
buffers that could not be evicted. Flushed buffers haven't necessarily
been flushed by us, they might have been flushed by someone else. The
result is immediately out of date upon return, as buffers might immediately
be read back in due to concurrent activity. The function is intended for
developer testing only.
《機械翻訳》pg_buffercache_evict_relation()
関数はpg_buffercache_evict()
関数と非常によく似ています。
差は、pg_buffercache_evict_relation()
がリレーション識別子代わりバッファ識別子を取るというものです。
リレーション内のすべてのフォークのすべてのバッファを立ち退かせようとします。
立ち退かされたバッファの数、フラッシュされたバッファの数、および立ち退かせることができなかったバッファの数を返します。
フラッシュされたバッファは、必ずしも私たちによってフラッシュされたわけではなく、他の誰かによってフラッシュされた可能性があります。
同時アクティビティのためにバッファがすぐに読み戻される可能性があるため、結果は結果時にすぐに古くなります。
関数は開発者のテスト専用です。
pg_buffercache_evict_all()
Function #
The <function>pg_buffercache_evict_all()</function> function is very
similar to the <function>pg_buffercache_evict()</function> function. The
difference is, the <function>pg_buffercache_evict_all()</function> function
does not take an argument; instead it tries to evict all buffers in the
buffer pool. It returns the number of evicted buffers, flushed buffers and
the number of buffers that could not be evicted. Flushed buffers haven't
necessarily been flushed by us, they might have been flushed by someone
else. The result is immediately out of date upon return, as buffers might
immediately be read back in due to concurrent activity. The function is
intended for developer testing only.
《機械翻訳》pg_buffercache_evict_all()
関数はpg_buffercache_evict()
関数と非常によく似ています。
pg_buffercache_evict_all()
差は、関数は引数を取得しません。
かわりに、バッファプール内のすべてのバッファを排除しようとします。
排除されたバッファの数、フラッシュされたバッファの数、および排除できなかったバッファの数を返します。
フラッシュされたバッファは、必ずしも私たちによってフラッシュされたわけではありません。
他の誰かによってフラッシュされた可能性があります。
同時アクティビティのためにバッファがすぐに読み戻される可能性があるため、結果は結果時にすぐに古くなります。
関数は開発者のテスト専用です。
regression=# SELECT n.nspname, c.relname, count(*) AS buffers FROM pg_buffercache b JOIN pg_class c ON b.relfilenode = pg_relation_filenode(c.oid) AND b.reldatabase IN (0, (SELECT oid FROM pg_database WHERE datname = current_database())) JOIN pg_namespace n ON n.oid = c.relnamespace GROUP BY n.nspname, c.relname ORDER BY 3 DESC LIMIT 10; nspname | relname | buffers ------------+------------------------+--------- public | delete_test_table | 593 public | delete_test_table_pkey | 494 pg_catalog | pg_attribute | 472 public | quad_poly_tbl | 353 public | tenk2 | 349 public | tenk1 | 349 public | gin_test_idx | 306 pg_catalog | pg_largeobject | 206 public | gin_test_tbl | 188 public | spgist_text_tbl | 182 (10 rows) regression=# SELECT * FROM pg_buffercache_summary(); buffers_used | buffers_unused | buffers_dirty | buffers_pinned | usagecount_avg --------------+----------------+---------------+----------------+---------------- 248 | 2096904 | 39 | 0 | 3.141129 (1 row) regression=# SELECT * FROM pg_buffercache_usage_counts(); usage_count | buffers | dirty | pinned -------------+---------+-------+-------- 0 | 14650 | 0 | 0 1 | 1436 | 671 | 0 2 | 102 | 88 | 0 3 | 23 | 21 | 0 4 | 9 | 7 | 0 5 | 164 | 106 | 0 (6 rows)
Mark Kirkwood <markir@paradise.net.nz>
Design suggestions: Neil Conway <email>neilc@samurai.com</email>
設計協力: Neil Conway <neilc@samurai.com>
Debugging advice: Tom Lane <email>tgl@sss.pgh.pa.us</email>
デバッグのアドバイス: Tom Lane <tgl@sss.pgh.pa.us>