Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b203d4

Browse files
committed
pg_buffercache: Add pg_buffercache_os_pages
ba2a3c2 has added a way to check if a buffer is spread acrossmultiple pages with some NUMA information, via a new viewpg_buffercache_numa that depends on pg_buffercache_numa_pages(), a SQLfunction. These can only be queried when support for libnuma exists,generating an error if not.However, it can be useful to know how shared buffers and OS pages mapwhen NUMA is not supported or not available. This commit expands thecapabilities around pg_buffercache_numa:- pg_buffercache_numa_pages() is refactored as an internal function,able to optionally process NUMA. Its SQL definition prior to thiscommit is still around to ensure backward-compatibility with v1.6.- A SQL function called pg_buffercache_os_pages() is added, able to workwith or without NUMA.- The view pg_buffercache_numa is redefined to usepg_buffercache_os_pages().- A new view is added, called pg_buffercache_os_pages. This ignoresNUMA for its result processing, for a better efficiency.The implementation is done so as there is no code duplication betweenthe NUMA and non-NUMA views/functions, relying on one internal functionthat does the job for all of them. The module is bumped to v1.7.Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>Reviewed-by: Mircea Cadariu <cadariu.mircea@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/Z/fFA2heH6lpSLlt@ip-10-97-1-34.eu-west-3.compute.internal
1 parent07d1dc3 commit4b203d4

File tree

9 files changed

+289
-85
lines changed

9 files changed

+289
-85
lines changed

‎contrib/pg_buffercache/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ EXTENSION = pg_buffercache
99
DATA = pg_buffercache--1.2.sql pg_buffercache--1.2--1.3.sql\
1010
pg_buffercache--1.1--1.2.sql pg_buffercache--1.0--1.1.sql\
1111
pg_buffercache--1.3--1.4.sql pg_buffercache--1.4--1.5.sql\
12-
pg_buffercache--1.5--1.6.sql
12+
pg_buffercache--1.5--1.6.sql pg_buffercache--1.6--1.7.sql
1313
PGFILEDESC = "pg_buffercache - monitoring of shared buffer cache in real-time"
1414

1515
REGRESS = pg_buffercache pg_buffercache_numa

‎contrib/pg_buffercache/expected/pg_buffercache.out‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ from pg_buffercache;
88
t
99
(1 row)
1010

11+
-- For pg_buffercache_os_pages, we expect at least one entry for each buffer
12+
select count(*) >= (select setting::bigint
13+
from pg_settings
14+
where name = 'shared_buffers')
15+
from pg_buffercache_os_pages;
16+
?column?
17+
----------
18+
t
19+
(1 row)
20+
1121
select buffers_used + buffers_unused > 0,
1222
buffers_dirty <= buffers_used,
1323
buffers_pinned <= buffers_used
@@ -28,6 +38,8 @@ SELECT count(*) > 0 FROM pg_buffercache_usage_counts() WHERE buffers >= 0;
2838
SET ROLE pg_database_owner;
2939
SELECT * FROM pg_buffercache;
3040
ERROR: permission denied for view pg_buffercache
41+
SELECT * FROM pg_buffercache_os_pages;
42+
ERROR: permission denied for view pg_buffercache_os_pages
3143
SELECT * FROM pg_buffercache_pages() AS p (wrong int);
3244
ERROR: permission denied for function pg_buffercache_pages
3345
SELECT * FROM pg_buffercache_summary();
@@ -43,6 +55,12 @@ SELECT count(*) > 0 FROM pg_buffercache;
4355
t
4456
(1 row)
4557

58+
SELECT count(*) > 0 FROM pg_buffercache_os_pages;
59+
?column?
60+
----------
61+
t
62+
(1 row)
63+
4664
SELECT buffers_used + buffers_unused > 0 FROM pg_buffercache_summary();
4765
?column?
4866
----------

‎contrib/pg_buffercache/meson.build‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ install_data(
2424
'pg_buffercache--1.3--1.4.sql',
2525
'pg_buffercache--1.4--1.5.sql',
2626
'pg_buffercache--1.5--1.6.sql',
27+
'pg_buffercache--1.6--1.7.sql',
2728
'pg_buffercache.control',
2829
kwargs: contrib_data_args,
2930
)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* contrib/pg_buffercache/pg_buffercache--1.6--1.7.sql*/
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use"ALTER EXTENSION pg_buffercache UPDATE TO '1.7'" to load this file. \quit
5+
6+
-- Function to retrieve information about OS pages, with optional NUMA
7+
-- information.
8+
CREATEFUNCTIONpg_buffercache_os_pages(IN include_numaboolean,
9+
OUT bufferidinteger,
10+
OUT os_page_numbigint,
11+
OUT numa_nodeinteger)
12+
RETURNS SETOF record
13+
AS'MODULE_PATHNAME','pg_buffercache_os_pages'
14+
LANGUAGE C PARALLEL SAFE;
15+
16+
-- View for OS page information, without NUMA.
17+
CREATEVIEWpg_buffercache_os_pagesAS
18+
SELECT bufferid, os_page_num
19+
FROM pg_buffercache_os_pages(false);
20+
21+
-- Re-create view for OS page information, with NUMA.
22+
DROPVIEW pg_buffercache_numa;
23+
CREATEVIEWpg_buffercache_numaAS
24+
SELECT bufferid, os_page_num, numa_node
25+
FROM pg_buffercache_os_pages(true);
26+
27+
REVOKE ALLON FUNCTION pg_buffercache_os_pages(boolean)FROM PUBLIC;
28+
REVOKE ALLON pg_buffercache_os_pagesFROM PUBLIC;
29+
REVOKE ALLON pg_buffercache_numaFROM PUBLIC;
30+
31+
GRANT EXECUTEON FUNCTION pg_buffercache_os_pages(boolean) TO pg_monitor;
32+
GRANTSELECTON pg_buffercache_os_pages TO pg_monitor;
33+
GRANTSELECTON pg_buffercache_numa TO pg_monitor;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pg_buffercache extension
22
comment = 'examine the shared buffer cache'
3-
default_version = '1.6'
3+
default_version = '1.7'
44
module_pathname = '$libdir/pg_buffercache'
55
relocatable = true

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp