|
21 | 21 | </indexterm> |
22 | 22 |
|
23 | 23 | <para> |
24 | | - The module provides the <function>pg_buffercache_pages()</function> |
25 | | - function, wrapped in the <structname>pg_buffercache</structname> view, and |
26 | | - the <function>pg_buffercache_summary()</function> function. |
| 24 | + This module provides the <function>pg_buffercache_pages()</function> |
| 25 | + function (wrapped in the <structname>pg_buffercache</structname> view), |
| 26 | + the <function>pg_buffercache_summary()</function> function, and the |
| 27 | + <function>pg_buffercache_usage_counts()</function> function. |
27 | 28 | </para> |
28 | 29 |
|
29 | 30 | <para> |
|
38 | 39 | row summarizing the state of the shared buffer cache. |
39 | 40 | </para> |
40 | 41 |
|
| 42 | + <para> |
| 43 | + The <function>pg_buffercache_usage_counts()</function> function returns a set |
| 44 | + of records, each row describing the number of buffers with a given usage |
| 45 | + count. |
| 46 | + </para> |
| 47 | + |
41 | 48 | <para> |
42 | 49 | By default, use is restricted to superusers and roles with privileges of the |
43 | 50 | <literal>pg_monitor</literal> role. Access may be granted to others |
|
242 | 249 | <structfield>usagecount_avg</structfield> <type>float8</type> |
243 | 250 | </para> |
244 | 251 | <para> |
245 | | - Average usagecount of used shared buffers |
| 252 | + Average usage count of used shared buffers |
246 | 253 | </para></entry> |
247 | 254 | </row> |
248 | 255 | </tbody> |
|
266 | 273 | </sect2> |
267 | 274 |
|
268 | 275 | <sect2> |
| 276 | + <title>The <function>pg_buffercache_usage_counts()</function> Function</title> |
| 277 | + |
| 278 | + <para> |
| 279 | + The definitions of the columns exposed by the function are shown in |
| 280 | + <xref linkend="pgbuffercache_usage_counts-columns"/>. |
| 281 | + </para> |
| 282 | + |
| 283 | + <table id="pgbuffercache_usage_counts-columns"> |
| 284 | + <title><function>pg_buffercache_usage_counts()</function> Output Columns</title> |
| 285 | + <tgroup cols="1"> |
| 286 | + <thead> |
| 287 | + <row> |
| 288 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 289 | + Column Type |
| 290 | + </para> |
| 291 | + <para> |
| 292 | + Description |
| 293 | + </para></entry> |
| 294 | + </row> |
| 295 | + </thead> |
| 296 | + |
| 297 | + <tbody> |
| 298 | + <row> |
| 299 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 300 | + <structfield>usage_count</structfield> <type>int4</type> |
| 301 | + </para> |
| 302 | + <para> |
| 303 | + A possible buffer usage count |
| 304 | + </para></entry> |
| 305 | + </row> |
| 306 | + |
| 307 | + <row> |
| 308 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 309 | + <structfield>buffers</structfield> <type>int4</type> |
| 310 | + </para> |
| 311 | + <para> |
| 312 | + Number of buffers with the usage count |
| 313 | + </para></entry> |
| 314 | + </row> |
| 315 | + |
| 316 | + <row> |
| 317 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 318 | + <structfield>dirty</structfield> <type>int4</type> |
| 319 | + </para> |
| 320 | + <para> |
| 321 | + Number of dirty buffers with the usage count |
| 322 | + </para></entry> |
| 323 | + </row> |
| 324 | + |
| 325 | + <row> |
| 326 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 327 | + <structfield>pinned</structfield> <type>int4</type> |
| 328 | + </para> |
| 329 | + <para> |
| 330 | + Number of pinned buffers with the usage count |
| 331 | + </para></entry> |
| 332 | + </row> |
| 333 | + </tbody> |
| 334 | + </tgroup> |
| 335 | + </table> |
| 336 | + |
| 337 | + <para> |
| 338 | + The <function>pg_buffercache_usage_counts()</function> function returns a |
| 339 | + set of rows summarizing the states of all shared buffers, aggregated over |
| 340 | + the possible usage count values. Similar and more detailed information is |
| 341 | + provided by the <structname>pg_buffercache</structname> view, but |
| 342 | + <function>pg_buffercache_usage_counts()</function> is significantly cheaper. |
| 343 | + </para> |
| 344 | + |
| 345 | + <para> |
| 346 | + Like the <structname>pg_buffercache</structname> view, |
| 347 | + <function>pg_buffercache_usage_counts()</function> does not acquire buffer |
| 348 | + manager locks. Therefore concurrent activity can lead to minor inaccuracies |
| 349 | + in the result. |
| 350 | + </para> |
| 351 | + </sect2> |
| 352 | + |
| 353 | + <sect2 id="pgbuffercache-sample-output"> |
269 | 354 | <title>Sample Output</title> |
270 | 355 |
|
271 | 356 | <screen> |
@@ -299,6 +384,18 @@ regression=# SELECT * FROM pg_buffercache_summary(); |
299 | 384 | --------------+----------------+---------------+----------------+---------------- |
300 | 385 | 248 | 2096904 | 39 | 0 | 3.141129 |
301 | 386 | (1 row) |
| 387 | + |
| 388 | + |
| 389 | +regression=# SELECT * FROM pg_buffercache_usage_counts(); |
| 390 | + usage_count | buffers | dirty | pinned |
| 391 | +-------------+---------+-------+-------- |
| 392 | + 0 | 14650 | 0 | 0 |
| 393 | + 1 | 1436 | 671 | 0 |
| 394 | + 2 | 102 | 88 | 0 |
| 395 | + 3 | 23 | 21 | 0 |
| 396 | + 4 | 9 | 7 | 0 |
| 397 | + 5 | 164 | 106 | 0 |
| 398 | +(6 rows) |
302 | 399 | </screen> |
303 | 400 | </sect2> |
304 | 401 |
|
|
0 commit comments