Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Compare mv rowCount when both mv dimensions contains query dimensions (backport #51511) #53305

Open
wants to merge 1 commit into
base: branch-3.3
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 28, 2024

Why I'm doing:

-- rows: 100 mv1: 
select sum(v1) from t1 group by a, b, c, f; 

-- rows: 10000 mv2: 
select sum(v1) from t1 group by a, b, d; 

query: select sum(v1) from t1 where b = 'a' group by a;

Before: prefer mv with less dimensions -> mv2, but mv2 has more rows which is not expected.
After: when many mvs satisfy query, prefer mv with less rows, so choose mv1.

What I'm doing:

  1. MaterializationContext.RewriteOrdering decides which MVs are retained in case too many MV candidates and candidate list should be truncated. MaterializationContext.RewriteOrdering should compare MV's maxPartitionRowCount rather than MV's total row count, in case a MV is with less partitions and total row count but maxPartitionRowCount is large.
  2. BestMvSelector is the actually place to decide which MV should be chose. The comparator in BestMvSelector should consider row count first if MV's outputRowCount is not zero in statistics.

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

This is an automatic backport of pull request #51511 done by [Mergify](https://mergify.com). ## Why I'm doing:
-- rows: 100 mv1: 
select sum(v1) from t1 group by a, b, c, f; 

-- rows: 10000 mv2: 
select sum(v1) from t1 group by a, b, d; 

query: select sum(v1) from t1 where b = 'a' group by a;

Before: prefer mv with less dimensions -> mv2, but mv2 has more rows which is not expected.
After: when many mvs satisfy query, prefer mv with less rows, so choose mv1.

What I'm doing:

  1. MaterializationContext.RewriteOrdering decides which MVs are retained in case too many MV candidates and candidate list should be truncated. MaterializationContext.RewriteOrdering should compare MV's maxPartitionRowCount rather than MV's total row count, in case a MV is with less partitions and total row count but maxPartitionRowCount is large.
  2. BestMvSelector is the actually place to decide which MV should be chose. The comparator in BestMvSelector should consider row count first if MV's outputRowCount is not zero in statistics.

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

…ery dimensions (#51511)

Signed-off-by: kaijian.ding <[email protected]>
(cherry picked from commit 308ff81)
Copy link

sonarcloud bot commented Nov 28, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
10.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant