oceanbase icon indicating copy to clipboard operation
oceanbase copied to clipboard

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

Open zzg19950727 opened this issue 1 year ago • 2 comments

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)) }

zzg19950727 avatar Jul 29 '24 03:07 zzg19950727

/assign

sparkyen avatar Jul 29 '24 03:07 sparkyen

邮件已收到。


mail received.

zzg19950727 avatar Jul 29 '24 03:07 zzg19950727