Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
b0194ab1
Commit
b0194ab1
authored
Apr 07, 2007
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the usage count statistics to the information available in
contrib/pgbuffercache. Greg Smith
parent
5695f38f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
14 deletions
+23
-14
contrib/pg_buffercache/README.pg_buffercache
contrib/pg_buffercache/README.pg_buffercache
+13
-11
contrib/pg_buffercache/pg_buffercache.sql.in
contrib/pg_buffercache/pg_buffercache.sql.in
+1
-1
contrib/pg_buffercache/pg_buffercache_pages.c
contrib/pg_buffercache/pg_buffercache_pages.c
+9
-2
No files found.
contrib/pg_buffercache/README.pg_buffercache
View file @
b0194ab1
...
...
@@ -40,7 +40,7 @@ Notes
reldatabase | pg_database.oid | Database for the relation.
relblocknumber | | Offset of the page in the relation.
isdirty | | Is the page dirty?
usagecount | | Page LRU count
There is one row for each buffer in the shared cache. Unused buffers are
shown with all fields null except bufferid.
...
...
@@ -60,20 +60,22 @@ Sample output
regression=# \d pg_buffercache;
View "public.pg_buffercache"
Column | Type | Modifiers
----------------+---------+-----------
bufferid | integer |
relfilenode | oid |
reltablespace | oid |
reldatabase | oid |
relblocknumber | bigint |
isdirty | boolean |
Column | Type | Modifiers
----------------+----------+-----------
bufferid | integer |
relfilenode | oid |
reltablespace | oid |
reldatabase | oid |
relblocknumber | bigint |
isdirty | boolean |
usagecount | smallint |
View definition:
SELECT p.bufferid, p.relfilenode, p.reltablespace, p.reldatabase,
p.relblocknumber, p.isdirty
p.relblocknumber, p.isdirty
, p.usagecount
FROM pg_buffercache_pages() p(bufferid integer, relfilenode oid,
reltablespace oid, reldatabase oid, relblocknumber bigint,
isdirty boolean);
isdirty boolean
, usagecount smallint
);
regression=# SELECT c.relname, count(*) AS buffers
FROM pg_class c INNER JOIN pg_buffercache b
...
...
contrib/pg_buffercache/pg_buffercache.sql.in
View file @
b0194ab1
...
...
@@ -12,7 +12,7 @@ LANGUAGE C;
CREATE VIEW pg_buffercache AS
SELECT P.* FROM pg_buffercache_pages() AS P
(bufferid integer, relfilenode oid, reltablespace oid, reldatabase oid,
relblocknumber int8, isdirty bool);
relblocknumber int8, isdirty bool
, usagecount int2
);
-- Don't want these to be available at public.
REVOKE ALL ON FUNCTION pg_buffercache_pages() FROM PUBLIC;
...
...
contrib/pg_buffercache/pg_buffercache_pages.c
View file @
b0194ab1
...
...
@@ -3,7 +3,7 @@
* pg_buffercache_pages.c
* display some contents of the buffer cache
*
* $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.1
1 2006/10/22 17:49:21 tgl
Exp $
* $PostgreSQL: pgsql/contrib/pg_buffercache/pg_buffercache_pages.c,v 1.1
2 2007/04/07 16:09:14 momjian
Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
...
...
@@ -16,7 +16,7 @@
#include "utils/relcache.h"
#define NUM_BUFFERCACHE_PAGES_ELEM
6
#define NUM_BUFFERCACHE_PAGES_ELEM
7
PG_MODULE_MAGIC
;
...
...
@@ -35,6 +35,7 @@ typedef struct
BlockNumber
blocknum
;
bool
isvalid
;
bool
isdirty
;
uint16
usagecount
;
}
BufferCachePagesRec
;
...
...
@@ -91,6 +92,8 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
INT8OID
,
-
1
,
0
);
TupleDescInitEntry
(
tupledesc
,
(
AttrNumber
)
6
,
"isdirty"
,
BOOLOID
,
-
1
,
0
);
TupleDescInitEntry
(
tupledesc
,
(
AttrNumber
)
7
,
"usage_count"
,
INT2OID
,
-
1
,
0
);
fctx
->
tupdesc
=
BlessTupleDesc
(
tupledesc
);
...
...
@@ -126,6 +129,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
fctx
->
record
[
i
].
reltablespace
=
bufHdr
->
tag
.
rnode
.
spcNode
;
fctx
->
record
[
i
].
reldatabase
=
bufHdr
->
tag
.
rnode
.
dbNode
;
fctx
->
record
[
i
].
blocknum
=
bufHdr
->
tag
.
blockNum
;
fctx
->
record
[
i
].
usagecount
=
bufHdr
->
usage_count
;
if
(
bufHdr
->
flags
&
BM_DIRTY
)
fctx
->
record
[
i
].
isdirty
=
true
;
...
...
@@ -172,6 +176,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
nulls
[
3
]
=
true
;
nulls
[
4
]
=
true
;
nulls
[
5
]
=
true
;
nulls
[
6
]
=
true
;
}
else
{
...
...
@@ -185,6 +190,8 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
nulls
[
4
]
=
false
;
values
[
5
]
=
BoolGetDatum
(
fctx
->
record
[
i
].
isdirty
);
nulls
[
5
]
=
false
;
values
[
6
]
=
Int16GetDatum
(
fctx
->
record
[
i
].
usagecount
);
nulls
[
6
]
=
false
;
}
/* Build and return the tuple. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment