[Bug] ORCA misses direct dispatch for multi-value predicates (IN / OR of equalities) on the distribution key
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- backend, databases, distributed-systems
Hướng nghiên cứu
Bắt đầu với đường dẫn dịch DXL-to-PlannedStmt và kiểm tra cách PlanSlice->directDispatch.contentIds được điền, so sánh với MergeDirectDispatchCalculationInfo trong src/backend/cdb/cdbmutate.c và dòng phát triển của directdispatch.c. Tái hiện vấn đề bằng các ví dụ SQL ba segment, với optimizer được bật và tắt, bao gồm cả các vị từ IN và OR tường minh. Được xem là hoàn tất khi ORCA chỉ báo cáo và dispatch đến hợp của các segment đích đối với các vị từ có nhiều giá trị trên khóa phân phối.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Apache Cloudberry version
All versions
What happened
For a predicate that restricts the distribution key to a small set of
constants, e.g. WHERE dist_key IN (c1, c2), GPORCA only performs direct
dispatch when ALL values happen to hash to the SAME segment. If the values
hash to different segments, ORCA gives up entirely and dispatches the slice
to every segment, while the Postgres planner correctly direct-dispatches to
the union of the target segments.
Results are correct — this is a performance issue (missed direct dispatch),
not a wrong-results bug. I'm filing it as a bug rather than a feature request
because the optimizer side already emits the complete multi-value dispatch
info into the DXL plan, and the DXL-to-PlannedStmt translator silently drops
it (details in "Anything else").
What you think should happen instead
ORCA should dispatch to the union of the segments the constants hash to,
like the Postgres planner does (see MergeDirectDispatchCalculationInfo in
src/backend/cdb/cdbmutate.c / directdispatch.c lineage). For the
reproduction below, the planner produces:
Gather Motion 2:1 (slice1; segments: 2)
INFO: (slice 1) Dispatch command to PARTIAL contents: 1 2
while ORCA produces:
Gather Motion 3:1 (slice1; segments: 3)
INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
The infrastructure already supports this: PlanSlice->directDispatch.contentIds
is a List, and the dispatcher handles multiple content ids today (the planner
populates it with more than one; so does ORCA's own raw-values path for
gp_segment_id IN (...) predicates on randomly distributed tables).
How to reproduce
On a 3-segment demo cluster:
create table t_dd (a int, b text) distributed by (a);
insert into t_dd select i, 'x' from generate_series(1, 10) i;
-- on my cluster: a=1 -> seg1, a=2,3 -> seg0, a=5 -> seg2
-- (cdbhash of int is deterministic, so a 3-segment cluster gets the same mapping)
set gp_test_print_direct_dispatch_info = on;
set optimizer = on;
explain (costs off) select * from t_dd where a in (1, 5);
-- Gather Motion 3:1 (slice1; segments: 3) <-- all segments
select * from t_dd where a in (1, 5);
-- INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
explain (costs off) select * from t_dd where a in (2, 3);
-- Gather Motion 1:1 (slice1; segments: 1) <-- works, but only because
-- both values hash to seg0
set optimizer = off;
explain (costs off) select * from t_dd where a in (1, 5);
-- Gather Motion 2:1 (slice1; segments: 2) <-- planner dispatches to
select * from t_dd where a in (1, 5); -- the union {seg1, seg2}
-- INFO: (slice 1) Dispatch command to PARTIAL contents: 1 2
The explicit OR form (a = 1 or a = 5) behaves the same way.
Operating System
Rocky Linux 9.5
Anything else
No response
Are you willing to submit PR?
- Yes, I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct.
- Ngôn ngữ chính
- C
- Star
- 1.4k
- Fork
- 260
- Merge trung bình
- 4 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 56
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/cloudberry
-
[Bug] Expand fails to recognize user-defined tablespacesCó thể đã có người làm @nix-oss đã nhận 57 ngày trước. Đang mởtype: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
apache/cloudberry#1885 · 2 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
gpexpand first stage fails: 'SyncPackages' object has no attribute 'ret' (extension sync never runs; regression)Có thể đã có người làm @talmacschen-arch đã nhận 119 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
apache/cloudberry#1825 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
type: Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
apache/cloudberry#2135 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Bug] REINDEX DATABASE CONCURRENTLY breaks temporary PAX tables created with ON COMMIT DELETE ROWSĐang mởtype: Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
apache/cloudberry#2134 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
apache/cloudberry#2130 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của apache/cloudberry
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
libsdl-org/SDL#16530 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
FriendsofECCE/ECCE#336 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
fw876/helloworld#2067 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
mediatek/filogic: OpenFi 6C (openfi,6c): func key has wrong polarity, event class and key codeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
immortalwrt/immortalwrt#2501 ·