Skip to content

pg_stat_statements: Add gc_count and query_file_size to pgss_info#35

Open
lfittl wants to merge 1 commit into
masterfrom
pgss-additional-info-19
Open

pg_stat_statements: Add gc_count and query_file_size to pgss_info#35
lfittl wants to merge 1 commit into
masterfrom
pgss-additional-info-19

Conversation

@lfittl
Copy link
Copy Markdown
Owner

@lfittl lfittl commented Feb 28, 2026

This surfaces two internal metrics to end-users and monitoring scripts that allow using pg_stat_statements more effectively:

The "gc_count" field complements the existing deallocation counter ("dealloc"), but counts up when the actual query text garbage collection occurrs, which is when the pg_stat_statements LWLock is typically held the longest, and significant I/O can occur for large query text files.

The "query_file_size" field returns the current size of the query text file, as tracked by pg_stat_statements already, without requiring a stat() call. This can be useful for automated collection of query texts, to tweak how often to collect them, based on the query file size. It also helps correlate the amount of I/O performed with the actual file size, which can be up to 2x of the sum of the query texts actually returned.

Bump pg_stat_statements version to 1.14 due to the addition of the two new columns to pg_stat_statements_info.

This surfaces two internal metrics to end-users and monitoring scripts
that allow using pg_stat_statements more effectively:

The "gc_count" field complements the existing deallocation counter
("dealloc"), but counts up when the actual query text garbage collection
occurrs, which is when the pg_stat_statements LWLock is typically held
the longest, and significant I/O can occur for large query text files.

The "query_file_size" field returns the current size of the query text
file, as tracked by pg_stat_statements already, without requiring a stat()
call. This can be useful for automated collection of query texts, to
tweak how often to collect them, based on the query file size. It also
helps correlate the amount of I/O performed with the actual file size,
which can be up to 2x of the sum of the query texts actually returned.

Bump pg_stat_statements version to 1.14 due to the addition of the two
new columns to pg_stat_statements_info.

Author: Lukas Fittl <lukas@fittl.com>
Reviewed by:
Discussion:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant