|
16 | 16 | <primary>pg_buffercache_pages</primary>
|
17 | 17 | </indexterm>
|
18 | 18 |
|
| 19 | + <indexterm> |
| 20 | + <primary>pg_buffercache_summary</primary> |
| 21 | + </indexterm> |
| 22 | + |
| 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. |
| 27 | + </para> |
| 28 | + |
19 | 29 | <para>
|
20 |
| - The module provides a C function <function>pg_buffercache_pages</function> |
21 |
| - that returns a set of records, plus a view |
22 |
| - <structname>pg_buffercache</structname> that wraps the function for |
| 30 | + The <function>pg_buffercache_pages()</function> function returns a set of |
| 31 | + records, each row describing the state of one shared buffer entry. The |
| 32 | + <structname>pg_buffercache</structname> view wraps the function for |
23 | 33 | convenient use.
|
24 | 34 | </para>
|
25 | 35 |
|
| 36 | + <para> |
| 37 | + The <function>pg_buffercache_summary()</function> function returns a single |
| 38 | + row summarizing the state of the shared buffer cache. |
| 39 | + </para> |
| 40 | + |
26 | 41 | <para>
|
27 | 42 | By default, use is restricted to superusers and roles with privileges of the
|
28 | 43 | <literal>pg_monitor</literal> role. Access may be granted to others
|
|
164 | 179 | </para>
|
165 | 180 | </sect2>
|
166 | 181 |
|
| 182 | + <sect2> |
| 183 | + <title>The <function>pg_buffercache_summary()</function> Function</title> |
| 184 | + |
| 185 | + <para> |
| 186 | + The definitions of the columns exposed by the function are shown in <xref linkend="pgbuffercache_summary-columns"/>. |
| 187 | + </para> |
| 188 | + |
| 189 | + <table id="pgbuffercache_summary-columns"> |
| 190 | + <title><function>pg_buffercache_summary()</function> Output Columns</title> |
| 191 | + <tgroup cols="1"> |
| 192 | + <thead> |
| 193 | + <row> |
| 194 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 195 | + Column Type |
| 196 | + </para> |
| 197 | + <para> |
| 198 | + Description |
| 199 | + </para></entry> |
| 200 | + </row> |
| 201 | + </thead> |
| 202 | + |
| 203 | + <tbody> |
| 204 | + <row> |
| 205 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 206 | + <structfield>buffers_used</structfield> <type>int4</type> |
| 207 | + </para> |
| 208 | + <para> |
| 209 | + Number of unused shared buffers |
| 210 | + </para></entry> |
| 211 | + </row> |
| 212 | + |
| 213 | + <row> |
| 214 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 215 | + <structfield>buffers_unused</structfield> <type>int4</type> |
| 216 | + </para> |
| 217 | + <para> |
| 218 | + Number of unused shared buffers |
| 219 | + </para></entry> |
| 220 | + </row> |
| 221 | + |
| 222 | + <row> |
| 223 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 224 | + <structfield>buffers_dirty</structfield> <type>int4</type> |
| 225 | + </para> |
| 226 | + <para> |
| 227 | + Number of dirty shared buffers |
| 228 | + </para></entry> |
| 229 | + </row> |
| 230 | + |
| 231 | + <row> |
| 232 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 233 | + <structfield>buffers_pinned</structfield> <type>int4</type> |
| 234 | + </para> |
| 235 | + <para> |
| 236 | + Number of pinned shared buffers |
| 237 | + </para></entry> |
| 238 | + </row> |
| 239 | + |
| 240 | + <row> |
| 241 | + <entry role="catalog_table_entry"><para role="column_definition"> |
| 242 | + <structfield>usagecount_avg</structfield> <type>float8</type> |
| 243 | + </para> |
| 244 | + <para> |
| 245 | + Average usagecount of used shared buffers |
| 246 | + </para></entry> |
| 247 | + </row> |
| 248 | + </tbody> |
| 249 | + </tgroup> |
| 250 | + </table> |
| 251 | + |
| 252 | + <para> |
| 253 | + The <function>pg_buffercache_summary()</function> function returns a |
| 254 | + single row summarizing the state of all shared buffers. Similar and more |
| 255 | + detailed information is provided by the |
| 256 | + <structname>pg_buffercache</structname> view, but |
| 257 | + <function>pg_buffercache_summary()</function> is significantly cheaper. |
| 258 | + </para> |
| 259 | + |
| 260 | + <para> |
| 261 | + Like the <structname>pg_buffercache</structname> view, |
| 262 | + <function>pg_buffercache_summary()</function> does not acquire buffer |
| 263 | + manager locks. Therefore concurrent activity can lead to minor inaccuracies |
| 264 | + in the result. |
| 265 | + </para> |
| 266 | + </sect2> |
| 267 | + |
167 | 268 | <sect2>
|
168 | 269 | <title>Sample Output</title>
|
169 | 270 |
|
@@ -191,6 +292,13 @@ regression=# SELECT n.nspname, c.relname, count(*) AS buffers
|
191 | 292 | public | gin_test_tbl | 188
|
192 | 293 | public | spgist_text_tbl | 182
|
193 | 294 | (10 rows)
|
| 295 | + |
| 296 | + |
| 297 | +regression=# SELECT * FROM pg_buffercache_summary(); |
| 298 | + buffers_used | buffers_unused | buffers_dirty | buffers_pinned | usagecount_avg |
| 299 | +--------------+----------------+---------------+----------------+---------------- |
| 300 | + 248 | 2096904 | 39 | 0 | 3.141129 |
| 301 | +(1 row) |
194 | 302 | </screen>
|
195 | 303 | </sect2>
|
196 | 304 |
|
|
0 commit comments