zhangwenchao-123 opened a new pull request, #1852:
URL: https://github.com/apache/cloudberry/pull/1852
For a predicate restricting the distribution key to several constants, e.g.
WHERE dist_key IN (c1, c2), the Postgres planner direct-dispatches the slice to
the union of the segments the constants hash to. GPORCA gave up instead: the
optimizer side already emits one datum array per value into
CDXLDirectDispatchInfo, but TranslateDXLDirectDispatchInfo required every value
to hash to the same segment and returned NIL otherwise, so the query was
dispatched to all segments.
Collect the distinct content ids of all datum combinations instead,
mirroring the planner's MergeDirectDispatchCalculationInfo behavior. A value
set that spans every segment still returns NIL, since direct dispatch buys
nothing there. PlanSlice->directDispatch.contentIds is already a list and the
dispatcher handles multiple content ids, so no dispatcher change is needed. Add
a gpdb::LAppendUniqueInt wrapper for list_append_unique_int.
On a 3-segment cluster, "select * from t1_varchar where col1_varchar in
('a','b')" now dispatches to 2 segments (PARTIAL contents) instead of all 3,
matching the planner. Single-value and same-segment cases are unchanged, as is
the raw-values gp_segment_id path. Update the affected expected outputs: the
direct_dispatch disjunction scenarios, the bfv_dd dispatch INFO lines, and the
plans in create_index, inherit, partition, partition_append, partition_prune,
partition_prune_append and qp_misc_jiras whose Gather Motion drops from 3:1 to
2:1, in src/test/regress as well as in the copies of these tests carried by the
pax_storage and vectorization suites.
<!-- Thank you for your contribution to Apache Cloudberry (Incubating)! -->
Fixes #ISSUE_Number
### What does this PR do?
<!-- Brief overview of the changes, including any major features or fixes -->
### Type of Change
- [ ] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change (fix or feature with breaking changes)
- [ ] Documentation update
### Breaking Changes
<!-- Remove if not applicable. If yes, explain impact and migration path -->
### Test Plan
<!-- How did you test these changes? -->
- [ ] Unit tests added/updated
- [ ] Integration tests added/updated
- [ ] Passed `make installcheck`
- [ ] Passed `make -C src/test installcheck-cbdb-parallel`
### Impact
<!-- Remove sections that don't apply -->
**Performance:**
<!-- Any performance implications? -->
**User-facing changes:**
<!-- Any changes visible to users? -->
**Dependencies:**
<!-- New dependencies or version changes? -->
### Checklist
- [ ] Followed [contribution
guide](https://cloudberry.apache.org/contribute/code)
- [ ] Added/updated documentation
- [ ] Reviewed code for security implications
- [ ] This PR contains AI-assisted code generation
- [ ] Requested review from [cloudberry
committers](https://github.com/orgs/apache/teams/cloudberry-committers)
### Additional Context
<!-- Any other information that would help reviewers? Remove if none -->
### CI Skip Instructions
<!--
To skip CI builds, add the appropriate CI skip identifier to your PR title.
The identifier must:
- Be in square brackets []
- Include the word "ci" and either "skip" or "no"
- Only use for documentation-only changes or when absolutely necessary
-->
---
<!-- Join our community:
- Mailing list:
[[email protected]](https://lists.apache.org/[email protected])
(subscribe: [email protected])
- Discussions: https://github.com/apache/cloudberry/discussions -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]