Skip to content

feat: PG VACUUM/ANALYZE on every Optimize call - BED-9161 - #112

Merged
StephenHinck merged 2 commits into
mainfrom
BED-9161
Aug 6, 2026
Merged

feat: PG VACUUM/ANALYZE on every Optimize call - BED-9161#112
StephenHinck merged 2 commits into
mainfrom
BED-9161

Conversation

@StephenHinck

@StephenHinck StephenHinck commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Removes the thresholds from PG's Optimize function for VACUUM/ANALYZE. This will insure the DB always has updated statistics.

Resolves: BED-9161

Type of Change

  • Chore (a change that does not modify the application functionality)
  • Bug fix (a change that fixes an issue)
  • New feature / enhancement (a change that adds new functionality)
  • Refactor (no behaviour change)
  • Test coverage
  • Build / CI / tooling
  • Documentation

Testing

  • Unit tests added / updated
  • Integration tests added / updated
  • Full test suite run (make test_all with CONNECTION_STRING set)

Screenshots (if appropriate):

Driver Impact

  • PostgreSQL driver (drivers/pg)
  • Neo4j driver (drivers/neo4j)

Checklist

  • Code is formatted
  • All existing tests pass
  • go.mod / go.sum are up to date if dependencies changed

Summary by CodeRabbit

  • Bug Fixes
    • Improved database maintenance so vacuuming consistently runs for both node and edge data tables.
    • Prevented maintenance from being skipped based on dead-tuple statistics, improving storage cleanup reliability.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

PostgreSQL storage optimization now vacuums both node and edge tables unconditionally. Tuple-statistics queries, threshold filtering, and no-target early exit logic were removed. Tests verify the combined vacuum command.

Changes

PostgreSQL vacuum behavior

Layer / File(s) Summary
Unconditional vacuum targeting and coverage
drivers/pg/optimize.go, drivers/pg/optimize_test.go
optimizeStorage directly targets node and edge. Tuple-statistics queries, threshold filtering, and early exit logic were removed. Tests require VACUUM (ANALYZE) node, edge to succeed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • SpecterOps/DAWGS#96: Introduces the PostgreSQL OptimizeStorage functionality that this change implements.
  • SpecterOps/DAWGS#97: Modifies optimizeStorage and its tests by removing tuple-statistics threshold logic.

Suggested reviewers: seanjso

Poem

A rabbit clears the vacuum way,
For node and edge are clean today.
No ratios choose which tables go,
The tests confirm the command will flow.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the PostgreSQL VACUUM and ANALYZE behavior change performed on every Optimize call.
Description check ✅ Passed The description includes the required change summary, ticket, type, testing, driver impact, and checklist information.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BED-9161

Comment @coderabbitai help to get the list of available commands.

Comment thread drivers/pg/optimize.go Outdated

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
drivers/pg/optimize_test.go (1)

13-21: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Retain coverage for Exec failures.

This subtest verifies only successful execution. Add a separate ExpectExec(...).WillReturnError(...) case and assert that optimizeStorage returns the error. If another test already covers this path, verify that it remains after removing the statistics-query tests.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@drivers/pg/optimize_test.go` around lines 13 - 21, Add a separate failure
subtest alongside “always vacuums node and edge” that configures the mock
connection’s Exec expectation to return an error, then assert optimizeStorage
propagates that error and all mock expectations are met. Preserve or verify
equivalent existing coverage if statistics-query tests are removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@drivers/pg/optimize_test.go`:
- Around line 13-21: Add a separate failure subtest alongside “always vacuums
node and edge” that configures the mock connection’s Exec expectation to return
an error, then assert optimizeStorage propagates that error and all mock
expectations are met. Preserve or verify equivalent existing coverage if
statistics-query tests are removed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ffaab47-2bae-493b-a1fa-b579ed071d2a

📥 Commits

Reviewing files that changed from the base of the PR and between a6d3b94 and 6d438b0.

📒 Files selected for processing (2)
  • drivers/pg/optimize.go
  • drivers/pg/optimize_test.go
💤 Files with no reviewable changes (1)
  • drivers/pg/optimize.go

@StephenHinck
StephenHinck merged commit 1b0fbcf into main Aug 6, 2026
8 of 14 checks passed
@StephenHinck
StephenHinck deleted the BED-9161 branch August 6, 2026 21:44
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