planner: introduce a configurable rule to adjust the optimizer's tendency between large IndexLookup
and large FullScan
to make index selection more stable
#45132
Labels
report/customer
Customers have encountered this bug.
sig/planner
SIG: Planner
type/enhancement
The issue or PR belongs to an enhancement.
Enhancement
The current optimizer's cost model tends to avoid using
large IndexLookup
, because it may trigger massive requests, which is resource-consuming and may slow down the whole system.But this tendency is not always correct, it can lead to some unreasonable
large FullScan
plans:In the case above, the optimizer selects a
1654784-row FullScan
instead of a16305-row IndexLookup
.We believe in most cases
16305-row IndexLookup
should be better than1654784-row FullScan
, but the optimizer tends to useFullScan
here.To make index selection more stable, we decided to introduce a rule to adjust this tendency.
This rule is based on the
estRows
ofFullScan
andIndexLookup
, if their ratio is larger than a threshold (e.g.FullScan-Rows / IndexLookup-Rows > 100
, we bypass the cost model and useIndexLookup
directly.The text was updated successfully, but these errors were encountered: