Skip to content

Expand relkinds in buffercache_by_type metric#1271

Open
nadashaban11 wants to merge 2 commits intocybertec-postgresql:masterfrom
nadashaban11:enhance-buffercache_by_type
Open

Expand relkinds in buffercache_by_type metric#1271
nadashaban11 wants to merge 2 commits intocybertec-postgresql:masterfrom
nadashaban11:enhance-buffercache_by_type

Conversation

@nadashaban11
Copy link
Contributor

@nadashaban11 nadashaban11 commented Mar 3, 2026

Description

I have noticed the TODO in the buffercache_by_type metric, then I explored the official doc of PostgreSQL to expand 4 other classifications.

Fixes

Added the following cases based on the doc:
S => "Sequence"
v => "View"
p => "Partitioned table"
I => "Partitioned index"

Screenshot

Screenshot from 2026-03-03 22-53-47

AI & Automation Policy

  • I am the human author and take full personal responsibility for every change in this PR.
  • No AI or automated generative tool was used in any part of this PR OR I have disclosed all tool(s) below.

AI/automation tools used (leave blank if none):
AI helped me to know the query that gives me the relkinds in my DB

Checklist

  • Code compiles and existing tests pass locally.
  • New or updated tests are included where applicable (Manually testing using psql).
  • Documentation is updated where applicable (metrics.yaml).

@nadashaban11 nadashaban11 changed the title Expand relkinds in buffercache_by_type Expand relkinds in buffercache_by_type Mar 3, 2026
@nadashaban11 nadashaban11 changed the title Expand relkinds in buffercache_by_type Expand relkinds in buffercache_by_type metric Mar 3, 2026
@pashagolub
Copy link
Collaborator

Could you please explain what kind of buffer cache statistics have Sequence and View?

Did you check the metric query output on a real database?

Thanks

@pashagolub pashagolub self-assigned this Mar 10, 2026
@pashagolub pashagolub added the metrics Metrics related issues label Mar 10, 2026
@nadashaban11
Copy link
Contributor Author

nadashaban11 commented Mar 10, 2026

Sure, when I searched and explored docs, I found that when we create Sequence, which is as a single-row table, then it has a storage and when nextval() called, stored Sequence is loaded to buffer. then it can affect and appear in cache usage.
If there are many updates, Sequences can also cause I/O overhead, so specifying its kind may help monitoring accuracy.

The previous query result shown in (screenshot) is from my local running database. If you mean checking from pgwatch itself, I did not but I can do that if you want.

For standard View it does not actually occupy buffers, but I included it to cover all relkind types I found in PostgreSQL doc. If it does not make sense I will remove it.

@pashagolub
Copy link
Collaborator

Why didn't you add 'Foreign table' for example?

@nadashaban11
Copy link
Contributor Author

nadashaban11 commented Mar 10, 2026

I think it not stored in local files that postgres buffers manage. or am I misunderstanding that?

@pashagolub
Copy link
Collaborator

so postgres buffers manage local files?

@nadashaban11
Copy link
Contributor Author

nadashaban11 commented Mar 10, 2026

What I know is that postgres storage manager manages the movement of local files from local storage into buffers when these files are needed to be accessible by any operation like read, write, or update. So if we have file is not stored locally, we can not manage by postgres.
Please correct me if I'm wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics Metrics related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants