Skip to content

Add pg_stat_role system view for per-role cumulative statistics#5

Open
shinyaaa wants to merge 1 commit into
masterfrom
claude/pg-stat-role-view-fg1atz
Open

Add pg_stat_role system view for per-role cumulative statistics#5
shinyaaa wants to merge 1 commit into
masterfrom
claude/pg-stat-role-view-fg1atz

Conversation

@shinyaaa

Copy link
Copy Markdown
Owner

The new view reports, for each role, the number of sessions
established and the number of committed and rolled back transactions,
along with the time at which the role's statistics were last reset.

Statistics are attributed to the login role of a session, so SET ROLE
and SECURITY DEFINER functions do not redirect where activity is
counted. Only client backends are counted, matching the session
accounting of pg_stat_database.

This adds a new variable-numbered cumulative statistics kind
PGSTAT_KIND_ROLE, keyed by role OID and shared across databases.
Stats entries are created by CREATE ROLE and dropped by DROP ROLE
(transactionally), survive clean restarts, and can be reset with the
new pg_stat_reset_role_stats() function.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_012dKR6zB32MW351m4dsoXPg

The new view reports, for each role, the number of sessions
established and the number of committed and rolled back transactions,
along with the time at which the role's statistics were last reset.

Statistics are attributed to the login role of a session, so SET ROLE
and SECURITY DEFINER functions do not redirect where activity is
counted.  Only client backends are counted, matching the session
accounting of pg_stat_database.

This adds a new variable-numbered cumulative statistics kind
PGSTAT_KIND_ROLE, keyed by role OID and shared across databases.
Stats entries are created by CREATE ROLE and dropped by DROP ROLE
(transactionally), survive clean restarts, and can be reset with the
new pg_stat_reset_role_stats() function.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012dKR6zB32MW351m4dsoXPg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants