Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace qvalueRange and qvalueRangeMap with analyzeExpr. #2285

Merged
merged 11 commits into from
Aug 28, 2015

Conversation

petermattis
Copy link
Collaborator

Working towards #2140 and #2142.

rdatum := rcmp.Right.(parser.Datum)
cmp := ldatum.Compare(rdatum)

// TODO(pmattis): Figure out how to generate this logic.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wouldn't bother trying to review this switch or the one in simplifyOneOrExpr. Instead, look at the test cases in TestSimplify{And,Or}Expr.

if !v.covering {
return
}

v.makeStartInfo(m)
v.makeEndInfo(m)
v.makeStartInfo(exprs)
Copy link
Contributor

Choose a reason for hiding this comment

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

both of these methods do nothing if len(exprs) != 1; can analyzeRanges just take a single expr?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably, though I don't want to change this code much in this PR. See the TODO added in one of the commits to planner.selectIndex about where this code is going.

})

case *parser.AndExpr:
// De Morgan's Law: (a AND b) -> (NOT a) OR (NOT b)
Copy link
Contributor

Choose a reason for hiding this comment

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

should this have been NOT (a AND b) -> (NOT a) OR (NOT b)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I'm not sure what happened to that NOT.

@tamird
Copy link
Contributor

tamird commented Aug 28, 2015

a few outstanding comments and I didn't review the switch as you suggested, but LGTM

@petermattis
Copy link
Collaborator Author

I'm going to merge this as-is and fix up the few nits in a separate PR. I already have a few hundred lines of code in a new branch which is based on this and I want to avoid rebase irritations as much as possible.

While I don't think it is worthwhile to review the big switches, it would be worthwhile to think about whether there are simpler ways to implement them. Paraphrasing Pascal (Blaise): "I have made this switch longer than usual because I have not had time to make it shorter".

The previous qvalueRange analysis was limiting and buggy in a variety of
ways. It didn't maintain range information in OR expressions in a way
that could be used to perform multiple scans of an index for independent
ranges.
checkEquivExpr checks that the original and simplified expressions
produce identical results for interesting values.
petermattis added a commit that referenced this pull request Aug 28, 2015
Replace qvalueRange and qvalueRangeMap with analyzeExpr.
@petermattis petermattis merged commit 332c23a into master Aug 28, 2015
@petermattis petermattis deleted the pmattis/sql-analyze branch August 28, 2015 16:42
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