Repository navigation
Enable query_plan_top_k_through_array_join by default - #128705
Conversation
|
Workflow [PR], commit [dd38098] Summary: ✅
AI ReviewSummaryEnables PR MetadataThe
Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block. Keep the setting disabled or bound the memory retained by the rewrite before enabling it globally; validate the actual default behavior and correct the changelog's unconditional memory claim. |
| )", 0, \ | ||
| {"26.5", false, true, "New setting to enable a query-plan-level optimization that pushes ORDER BY ... LIMIT n through a LEFT/RIGHT join when the sort key only references the preserved side."}) \ | ||
| DECLARE(Bool, query_plan_top_k_through_array_join, false, R"( | ||
| DECLARE(Bool, query_plan_top_k_through_array_join, true, R"( |
There was a problem hiding this comment.
[P1] Preserve bounded memory before enabling this by default
This makes an existing long-array query exceed its memory limit by default. Using the exact-head Fast Test binary and the topk_array_join_long fixture from tests/performance/top_k_through_array_join.xml (8,192 rows, arrays of 4,096–4,097 UInt32 elements), I measured 44.59 MiB peak with the setting off versus 160.37 MiB with it on, consistently across three runs.
SELECT k, arr
FROM topk_array_join_long ARRAY JOIN arr
ORDER BY k LIMIT 1000
SETTINGS max_threads = 1, max_memory_usage = 100000000
FORMAT Null;This succeeds with query_plan_top_k_through_array_join = 0, but raises MEMORY_LIMIT_EXCEEDED with 1 or with the new default. The moved SortingStep retains up to limit + offset complete arrays rather than that many expanded elements, and its eligibility checks impose no bound on that retained payload. The changelog's claim that this uses less memory therefore also does not hold generally.
Please keep the default disabled until the rewrite has a memory-aware eligibility check or bounded retention strategy. Include a benchmark arm without an explicit setting override when validating the flip: the existing XML forces 0 and 1 on both binaries, so its normal before/after comparison masks the default change.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 18 s compile time in total, 7 of them have a recent master baseline. |
Related: #116550
Related: #115157
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Enable
query_plan_top_k_through_array_joinby default. A query withARRAY JOINandORDER BY ... LIMITon columns that are not joined now sorts and limits the rows beforeARRAY JOIN, which uses less memory.Workflow [PR]
Sync PR [sync-upstream/pr/128705]
Version info
26.11.1.1331-master(included in26.11and later)