Skip to content

PG: Add per index blocks hit and blocks read #20767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bonnefoa
Copy link
Contributor

What does this PR do?

pg_statio_user_indexes provides per index block usage. It is using pg_stat_get_blocks_fetched and pg_stat_get_blocks_hit behind the hood. We can emit those metrics directly from our IDX_METRICS query.

The metric name postgresql.index.blocks_read was used as postgresql.index_blocks_read already exists for the per table block usage.

Motivation

This would provide a better granularity of the index block usage.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

nenadnoveljic
nenadnoveljic previously approved these changes Jul 16, 2025
Copy link

codecov bot commented Jul 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.14%. Comparing base (962d1f6) to head (7d0e0c2).

Additional details and impacted files
Flag Coverage Δ
confluent_platform ?
hudi ?
postgres 93.26% <ø> (+3.43%) ⬆️
presto ?
tomcat ?
weblogic ?

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

bonnefoa added 2 commits July 16, 2025 17:21
pg_statio_user_indexes provides per index block usage. It is using
pg_stat_get_blocks_fetched and pg_stat_get_blocks_hit behind the hood.
We can emit those metrics directly from our IDX_METRICS query.

The metric name index.blocks_read was used as index_blocks_read already
exists for the per table block usage.
WAL metrics presence are already covered in common pg integration tests
@bonnefoa bonnefoa force-pushed the pg-index-block-usage branch from a0eca4a to 7d0e0c2 Compare July 16, 2025 15:21
@temporal-github-worker-1 temporal-github-worker-1 bot dismissed nenadnoveljic’s stale review July 16, 2025 15:21

Review from nenadnoveljic is dismissed. Related teams and files:

  • database-monitoring-agent
    • postgres/changelog.d/20767.added
    • postgres/datadog_checks/postgres/relationsmanager.py
    • postgres/metadata.csv
    • postgres/tests/test_pg_integration.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants