Waloid24 opened a new pull request, #2007:
URL: https://github.com/apache/cloudberry/pull/2007
Fixes #ISSUE_Number
### What does this PR do?
optimizer_damping_factor_filter accepts zero, but CStatisticsConfig asserts
that the value is strictly positive. In assertion-enabled builds, this can
trigger ORCA fallback during configuration creation.
Zero damping represents full correlation between predicates, so retain the
largest scale factor, corresponding to the smallest predicate selectivity.
### Type of Change
- [ ] Bug fix (non-breaking change)
### Test Plan
I created tables as:
~~~~sql
SET optimizer = off;
CREATE TABLE damping_inner (
id integer,
a integer,
b integer,
c integer,
z integer
) USING heap DISTRIBUTED RANDOMLY;
INSERT INTO damping_inner
SELECT
n,
n % 10,
(n / 10) % 5,
(n / 50) % 4,
0
FROM generate_series(0, 9999) AS g(n);
CREATE TABLE damping_outer (
b integer,
c integer,
z integer
) USING heap DISTRIBUTED REPLICATED;
INSERT INTO damping_outer VALUES (0, 0, 0);
CREATE INDEX damping_inner_abcz
ON damping_inner USING bitmap (a, b, c, z);
CREATE INDEX damping_inner_bcza
ON damping_inner USING bitmap (b, c, z, a);
ANALYZE damping_inner;
ANALYZE damping_outer;
SET optimizer = on;
SET optimizer_enable_hashjoin = off;
~~~~
and run a query:
~~~~sql
SET optimizer_damping_factor_filter = 0;
EXPLAIN (ANALYZE, TIMING OFF)
SELECT i.*
FROM damping_outer AS o
CROSS JOIN damping_inner AS i
WHERE i.a = 1
AND i.b = o.b
AND i.c = o.c;
~~~~
In explain I see `Optimizer: GPORCA` instead `Optimizer: Postgres query
optimizer` as it was before.
### Impact
Allows optimizer_damping_factor_filter = 0 in debug builds and makes
zero-damping semantics explicit for conjunctions.
**Performance:**
No.
**User-facing changes:**
There is no fallback to Postgres optimizer when
`optimizer_damping_factor_filter = 0`.
**Dependencies:**
No.
### 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)
---
<!-- 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]