risingwave_frontend::optimizer::rule

Module index_selection_rule

source
Expand description

ยงIndex selection cost matrix

column_idx01234remark
Equal11111
In108555take the minimum value with actual in number
Range(Two)60050201010RangeTwoSideBound like a between 1 and 2
Range(One)140070251510RangeOneSideBound like a > 1, a >= 1, a < 1
All4000100302010
index cost = cost(match type of 0 idx)
* cost(match type of 1 idx)
* ... cost(match type of the last idx)

ยงExample

Given index order key (a, b, c)

  • For a = 1 and b = 1 and c = 1, its cost is 1 = Equal0 * Equal1 * Equal2 = 1
  • For a in (xxx) and b = 1 and c = 1, its cost is In0 * Equal1 * Equal2 = 10
  • For a = 1 and b in (xxx), its cost is Equal0 * In1 * All2 = 1 * 8 * 50 = 400
  • For a between xxx and yyy, its cost is Range(Two)0 = 600
  • For a = 1 and b between xxx and yyy, its cost is Equal0 * Range(Two)1 = 50
  • For a = 1 and b > 1, its cost is Equal0 * Range(One)1 = 70
  • For a = 1, its cost is 100 = Equal0 * All1 = 100
  • For no condition, its cost is All0 = 4000

With the assumption that the most effective part of a index is its prefix, cost decreases as column_idx increasing.

For index order key length > 5, we just ignore the rest.

Structsยง

Enumsยง

Constantsยง