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

Merged
merged 2 commits into from
Jul 22, 2025
Merged

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.29%. Comparing base (f52fd00) to head (8720d7b).
Report is 9 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
activemq ?
cassandra ?
confluent_platform ?
hive ?
hivemq ?
hudi ?
ignite ?
jboss_wildfly ?
kafka ?
postgres 93.26% <ø> (+3.40%) ⬆️
presto ?
solr ?
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 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
bonnefoa added 2 commits July 21, 2025 08:20
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 7d0e0c2 to 8720d7b Compare July 21, 2025 06:23
@bonnefoa bonnefoa added this pull request to the merge queue Jul 22, 2025
Merged via the queue into master with commit 4f70c61 Jul 22, 2025
41 checks passed
@bonnefoa bonnefoa deleted the pg-index-block-usage branch July 22, 2025 06:18
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.

3 participants