Skip to content

[memo] RequiredIndex interface#2238

Merged
max-hoffman merged 2 commits intomainfrom
max/required-index
Jan 4, 2024
Merged

[memo] RequiredIndex interface#2238
max-hoffman merged 2 commits intomainfrom
max/required-index

Conversation

@max-hoffman
Copy link
Copy Markdown
Contributor

Some table nodes need to be executed as IndexScans with mandatory filters. The new interface makes this transparent to join planning.

re: dolthub/dolt#7256

Some table nodes need to be executed as IndexScans with mandatory
filters. The new interface makes this transparent to join planning.
Copy link
Copy Markdown
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good solution just a few comments

// IndexRequired tables cannot be executed without index lookups on certain
// columns. Join planning uses this interface to maintain plan correctness
// for these nodes
type IndexRequired interface {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good interface, good name

p.reqIdxCols = rel.Child.RelProps.reqIdxCols
case *Filter:
p.reqIdxCols = rel.Child.RelProps.reqIdxCols
default:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No empty default

}

func (m *Memo) MemoizeHashJoin(grp *ExprGroup, join *JoinBase, toExpr, fromExpr []sql.Expression) *ExprGroup {
if join.Right.RelProps.reqIdxCols.Len() > 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about this logic would help

sql/memo/memo.go Outdated
}

func (m *Memo) MemoizeLookupJoin(grp, left, right *ExprGroup, op plan.JoinType, filter []sql.Expression, lookup *IndexScan) *ExprGroup {
if left.RelProps.reqIdxCols.Union(right.RelProps.reqIdxCols).Difference(lookup.Index.set).Len() > 0 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about this logic would help

@max-hoffman max-hoffman merged commit dcf9acb into main Jan 4, 2024
@max-hoffman max-hoffman deleted the max/required-index branch January 4, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants