oceanbase / oceanbase/oceanbase

[Enhancement]: 相同过滤条件的估行偏小 || [Enhancement]: The estimated rows with the same filter conditions are too small

Open
#2,068 2 comments 0 reactions 1 assignee View on GitHub

@sparkyen is already working on this.

Since Jul 29, 2024.

type: enhancement
Dominant language
C++
Stars
10.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Enhancement
select * from t1 where c1 in (1,2,3) and c1 in (1,2,3);

对于这种查询,优化器估行的行数为:table_rows * (3.0/ NDV(c1)) * (3.0 / NDV(c1))

对于这种过滤条件,优化器依然使用的是独立模型计算的选择率,但是对于这种简单的场景,可以识别出来是强相关的,使用强相关模型计算选择率,即:

table_rows * min{ (3.0/ NDV(c1)) , (3.0 / NDV(c1)) }


Enhancement
select * from t1 where c1 in (1,2,3) and c1 in (1,2,3);

For this query, the optimizer estimates the number of rows as: table_rows * (3.0/ NDV(c1)) * (3.0 / NDV(c1))

For this filtering condition, the optimizer still uses the selection rate calculated by the independent model, but for this simple scenario, it can be identified that it is strongly correlated, and the strong correlation model is used to calculate the selection rate, that is:

table_rows * min{ (3.0/ NDV(c1)) , (3.0 / NDV(c1)) }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.