G
YouTube TikTok Games
Skip to content

[Postgres] Collect column statistics by default - #26015

Open
sangeetashivaji wants to merge 5 commits into
masterfrom
sangeeta/postgres-column-stats-default-on
Open

sangeetashivaji wants to merge 5 commits into
masterfrom
sangeeta/postgres-column-stats-default-on

Conversation

@sangeetashivaji

@sangeetashivaji sangeetashivaji commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Turns on column statistics collection by default (collect_column_statistics.enabled: true). It still requires dbm: true.
  • Checks that the datadog.column_statistics() function exists before calling it. Databases without it are skipped with the existing one-time warning and health event, and no failing query appears in the Postgres logs.
  • Adds collect_column_statistics.function to use a function in a different schema, like query_samples.explain_function. Invalid names are rejected when the config loads.

Motivation

Column statistics help Database Monitoring reason about query plans, but as an opt-in setting they are rarely enabled. With this change, creating the function is the only setup step.

Checklist before requesting review

  • I self-reviewed the full diff, and this description matches the final change
  • Tests cover the change, or this description explains why none are needed
    • An integration test runs a DBM instance with no column stats config and checks that column statistics are sent. Unit tests cover the existence check, the configurable function and name validation. Diagnose tests that check other features now turn column stats off explicitly.
  • Automated review comments, including Codex review, were addressed or answered
    • Codex: the default flip is a changed entry (it changes emitted data for existing instances), and the new option is added. The default-on test now checks emitted events.
  • I, the human author, understand this change, can explain it to reviewers, and believe it meets the repository standards

🤖 Generated with Claude Code

collect_column_statistics.enabled now defaults to true, so every DBM
Postgres instance collects pg_stats summaries without extra config.
As an opt-in setting it was rarely enabled.

Collection still needs the datadog.column_statistics() function in each
database. Before reading it, the collector now checks for the function
with to_regprocedure. A database without it is skipped with the same
one-time warning and column_statistics_function_not_found health event
as before, but without running a failing query, so instances that never
set the function up don't get an hourly ERROR in their Postgres logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Major version bump
The changelog type changed or removed was used in this Pull Request, so the next release will bump major version. Please make sure this is a breaking change, or use the fixed or added type instead.

@dd-octo-sts

dd-octo-sts Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Dispatcher tests: passed

Dispatcher beta: informational only
Existing CI remains the merge signal.

  38/38 jobs

✅ 38 passed · nothing failed

Batches · ✅ batch-01 38/38

Dispatcher finished on cb282ce — GitHub Run · Dispatcher Logs.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

evalya-impact-summary

Evalya CI impact

Impact analysis: 0 selected, 0 skipped (of 0 test tasks)
Publish tasks:   4 (always emitted)
Changed files:   15

Full impact report
Learn more about CI impact filtering

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines  Tests  Code Coverage

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog retried 1 test - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
• Patch Coverage: 98.10%
• Overall Coverage: 94.56% (+4.79%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 0fedf0e | Docs | View more details | Give us feedback!

@dd-octo-sts

dd-octo-sts Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Disk usage change

Commit 0fedf0e compared against cb282ce.

Uncompressed

linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
🔺 +2.29 KiB 🔺 +2.29 KiB 🔺 +2.29 KiB 🔺 +2.29 KiB 🔺 +2.29 KiB
Details
Name Version Type linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
postgres 23.15.0 Integration 🔺 +2.29 KiB 🔺 +2.29 KiB 🔺 +2.29 KiB 🔺 +2.29 KiB 🔺 +2.29 KiB

Compressed

linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
🔺 +533 B 🔺 +533 B 🔺 +533 B 🔺 +533 B 🔺 +533 B
Details
Name Version Type linux-aarch64 linux-x86_64 macos-aarch64 macos-x86_64 windows-x86_64
postgres 23.15.0 Integration 🔺 +533 B 🔺 +533 B 🔺 +533 B 🔺 +533 B 🔺 +533 B

sangeetashivaji and others added 2 commits November 12, 2026 11:36
Adds collect_column_statistics.function (default
datadog.column_statistics), matching query_samples.explain_function, so
the function can live in another schema. The name is validated when the
config loads: a function name of letters, digits and underscores,
optionally schema-qualified, with an optional trailing "()". Anything
else is a configuration error. It is quoted before it reaches SQL.

The collector, the existence check, agent diagnose, the warning logs and
the remediation text all use the configured name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sangeetashivaji sangeetashivaji added the qa/required QA is required for this PR and will generate a QA card label Nov 12, 2026
@sangeetashivaji
sangeetashivaji marked this pull request as ready for review November 12, 2026 17:29
@sangeetashivaji
sangeetashivaji requested review from a team as code owners November 12, 2026 17:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T17:31:29.956734Z fb0e4bc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb0e4bcdd2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread postgres/changelog.d/26015.added Outdated
@@ -0,0 +1 @@
Collect column statistics by default, and add the `collect_column_statistics.function` option to override the function used to read them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Classify the default-on behavior as a breaking change

Rename this entry to 26015.changed: changing collect_column_statistics.enabled from false to true causes existing DBM instances to start emitting column-statistics data without a configuration change, which is exactly the repository's stated case for a backward-incompatible .changed entry. Leaving this as .added produces a minor release instead of the required major version bump.

AGENTS.md reference: AGENTS.md:L240-L244

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

Comment thread postgres/tests/test_unit.py Outdated
Comment on lines +552 to +553
assert check._config.collect_column_statistics.enabled
assert check.metadata_samples._column_statistics_collector is not None

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Verify the observable default-on collection behavior

Replace these private-state assertions with a boundary-level assertion that omitting collect_column_statistics actually executes collection or emits a column-statistics event. This test still passes if the collector is constructed but never scheduled or run, so it does not protect the user-visible behavior claimed by the change and duplicates the configuration-default coverage.

AGENTS.md reference: AGENTS.md:L197-L205

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

No reportable defect was found in the missing-function skip path or configurable function handling. Confidence is limited to static review and unit-level validation; live PostgreSQL integration behavior remains unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit fb0e4bc

…est it end to end

Default-on collection changes emitted data for existing DBM instances,
which AGENTS.md classes as a changed entry, so the default flip is
26015.changed and the new function option is 26015.added.

The default-on test now runs the check with no collect_column_statistics
section and asserts column statistics events are emitted, instead of
checking the collector object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dd-octo-sts

dd-octo-sts Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Validation Report

All 22 validations passed.

Show details
Validation Description Status
agent-reqs Verify check versions match the Agent requirements file ✅
ci Validate CI configuration and code coverage settings ✅
codeowners Validate every integration has a CODEOWNERS entry ✅
config Validate default configuration files against spec.yaml ✅
dep Verify dependency pins are consistent and Agent-compatible ✅
http Validate integrations use the HTTP wrapper correctly ✅
imports Validate check imports do not use deprecated modules ✅
integration-style Validate check code style conventions ✅
jmx-metrics Validate JMX metrics definition files and config ✅
labeler Validate PR labeler config matches integration directories ✅
legacy-signature Validate no integration uses the legacy Agent check signature ✅
license-headers Validate Python files have proper license headers ✅
licenses Validate third-party license attribution list ✅
metadata Validate metadata.csv metric definitions ✅
models Validate configuration data models match spec.yaml ✅
openmetrics Validate OpenMetrics integrations disable the metric limit ✅
package Validate Python package metadata, naming, and wheel contents ✅
pr-description Validate the pull request checklist and visible description length ✅
qa-label Validate the pull request declares whether it needs QA for the next Agent release ✅
readmes Validate README files have required sections ✅
saved-views Validate saved view JSON file structure and fields ✅
version Validate version consistency between package and changelog ✅

View full run

This branch has not been deployed

No deployments
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.

1 participant