Skip to content

Commit

Permalink
opt: corrects function doc for canMaybeConstrainIndex
Browse files Browse the repository at this point in the history
This commit corrects a the function documentation for
canMaybeConstrainIndex.

Prior to this change, it did not mention a third check, for tight filter
constraints, that is performed to determinte the possibility that an
index could be constrained by a filer.

Also, the documentation now correctly maps to the logic of the function.
Previously it falsly claimed that if any of the checks were false then
the function would return false. Now it correctly states that if any of
the checks are true, then the fucntion returns true.

Release note: None
  • Loading branch information
mgartner committed Apr 8, 2020
1 parent 27debe8 commit 5e23169
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/sql/opt/xform/custom_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,14 @@ func (c *CustomFuncs) allInvIndexConstraints(
return constraints, true
}

// canMaybeConstrainIndex performs two checks that can quickly rule out the
// possibility that the given index can be constrained by the specified filter:
//
// 1. If the filter does not reference the first index column, then no
// constraint can be generated.
// 2. If none of the filter's constraints start with the first index column,
// then no constraint can be generated.
// canMaybeConstrainIndex can quickly rule out the possibility that the given
// index can be constrained by the specified filter. If any of the three
// following statements are true, then it is possible that the index can be
// constrained:
//
// 1. The filter references the first index column.
// 2. The constraints are not tight (see Scalar.TightConstraints).
// 3. Any of the filter's constraints start with the first index column.
//
func (c *CustomFuncs) canMaybeConstrainIndex(
filters memo.FiltersExpr, tabID opt.TableID, indexOrd int,
Expand Down

0 comments on commit 5e23169

Please sign in to comment.