Repository navigation
fix(inkless:control_plane): force generic find batches planning - #786
Closed
giuseppelillo wants to merge 1 commit into
Closed
giuseppelillo wants to merge 1 commit into
giuseppelillo wants to merge 1 commit into
Conversation
giuseppelillo
force-pushed
the
glillo/fix-find-batches-query-plan
branch
from
September 3, 2026 17:48
85782bb to
6081491
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused migration and regression test introduce no unresolved issues.
Pull request overview
Forces reusable generic PostgreSQL plans for find_batches_v2, reducing repeated planning overhead.
Changes:
- Sets function-level
plan_cache_mode=force_generic_plan. - Verifies the setting through PostgreSQL’s function catalog.
File summaries
| File | Description |
|---|---|
storage/inkless/src/test/java/io/aiven/inkless/control_plane/postgres/FindBatchesJobTest.java |
Tests the function-level plan configuration. |
storage/inkless/src/main/resources/db/migration/V28__Find_batches_generic_plan.sql |
Enables generic plan reuse for find_batches_v2. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
`find_batches_v2` runs its `batches`-to-`files` lookup once for every requested partition. With automatic plan caching, a PostgreSQL backend can select a custom plan for that statement and invoke the planner on every lookup, even though each invocation produces the same ordered index-scan plan. Planning then dominates replica CPU and makes performance depend on backend-local plan-cache history. `plan_cache_mode=auto` (default) normally switches to a generic plan when its estimated cost is competitive with the average custom-plan cost. For this parameterized query, benchmarks showed that in some cases PostgreSQL keeps replanning equivalent index scans instead of reliably selecting the reusable generic plan. Set `plan_cache_mode` to `force_generic_plan` at the function boundary to bypass that misleading cost decision. PostgreSQL now builds and reuses one generic inner plan per backend while `find_batches_v2` runs. The setting does not affect other control-plane statements, and the generic plan preserves the last-offset index order and budget-bounded early exit. The migration test checks the function catalog configuration so a future function replacement cannot silently remove the setting.
giuseppelillo
force-pushed
the
glillo/fix-find-batches-query-plan
branch
from
September 3, 2026 17:54
6081491 to
bde1953
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_batches_v2runs itsbatches-to-fileslookup once for every requested partition. With automatic plan caching, a PostgreSQL backend can select a custom plan for that statement and invoke the planner on every lookup, even though each invocation produces the same ordered index-scan plan. Planning then dominates replica CPU and makes performance depend on backend-local plan-cache history.plan_cache_mode=auto(default) normally switches to a generic plan when its estimated cost is competitive with the average custom-plan cost. For this parameterized query, benchmarks showed that in some cases PostgreSQL keeps replanning equivalent index scans instead of reliably selecting the reusable generic plan.Set
plan_cache_modetoforce_generic_planat the function boundary to bypass that misleading cost decision. PostgreSQL now builds and reuses one generic inner plan per backend whilefind_batches_v2runs. The setting does not affect other control-plane statements, and the generic plan preserves the last-offset index order and budget-bounded early exit.The migration test checks the function catalog configuration so a future function replacement cannot silently remove the setting.