Conversation
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds an opt-in scoped query-plan override for one calendar query shape. The override validates the compiled query, rewrites an intermediate collector, and adds child-lookup hints. Unit and integration tests compare projected plans with baseline results. ChangesCalendar query projection
Priority: ⬇️ Low Estimated code review effort: 4 (Complex) | ~45 minutes Change: Refactor Sequence Diagram(s)sequenceDiagram
participant CalendarQueryCompiler
participant apply_plan
participant reassign_calendar_child_ids
participant sql_select_arrays
CalendarQueryCompiler->>apply_plan: compile calendar query with CTEs
apply_plan->>reassign_calendar_child_ids: apply configured app-specific plan
reassign_calendar_child_ids->>reassign_calendar_child_ids: validate flags, query shape, CTEs, and child lookup scan
reassign_calendar_child_ids-->>apply_plan: return rewritten CTEs and join hints
apply_plan->>sql_select_arrays: execute projected SQL
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reassign’s calendar query scans
triplesagain to collect child entity IDs that its OR branches already found. Replace that intermediate scan with a distinct projection of the existing IDs. DirectedLeadingandNestLoophints retain the child join order, but production plan validation found that they do not reliably preserve the entity-bound inner index scan.The change requires the exact app, normalized query, compiler structure and existing child index hint. It defaults off behind
scoped-query-plans/reassign-calendar-child-ids, respects the kill switches, and falls back when the guards differ. Returned CTEs, filters, permissions, row multiplicities and invalidation topics are preserved. The hint formatter gains nestedLeadingpairs; existing flat hints use the same formatting path.Validation: 23 targeted tests and 275 assertions passed on PostgreSQL 17.10 with pg_hint_plan 1.7.1; clj-kondo is clean. Differential tests cover complete results, permissions, tenant isolation, overlapping branches, empty ranges, dangling children and many-valued dates. Plan tests verify an entity-bound child index lookup for sparse, empty and broad ranges.
A 7,960-triple synthetic benchmark preserved complete results for all three ranges. Local buffer hits fell from 1,447 to 952 for the sparse range and from 15,533 to 14,734 for the broad range; the empty range was unchanged. These measurements do not establish production CPU savings. The change is not deployed or enabled.
Rollout is blocked. A read-only
EXPLAIN (ANALYZE FALSE)on the current Aurora writer, using the current compiler and fresh sketches, produced a materialized innert8scan bound by app and attribute but not entity. The baseline retained all three index conditions. This gap needs a regression test and a structural fix before activation. No production workload was executed by the probe, and the calendar change remains undeployed and disabled.Stacked on #2912. The separate release candidate preserves all subsequent production changes and passed 43 tests / 459 assertions, but its local plan tests do not cover the production planner choice above.