-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
sql/{plan,analyzer}: Cache subquery results when joining against a subquery. #322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG!
if i.cache != nil { | ||
if err != nil { | ||
if err == io.EOF { | ||
i.parent.mutex.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a little easier to read with fillCacheInParent method
sql/plan/cached_results.go
Outdated
i.parent.cache = i.cache | ||
i.parent.dispose = i.dispose | ||
} else { | ||
i.dispose() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.cleanUp() for this repeated block?
_, isJoin := parent.(plan.JoinNode) | ||
_, isIndexedJoin := parent.(*plan.IndexedJoin) | ||
if isJoin || isIndexedJoin { | ||
sa, isSubqueryAlias := child.(*plan.SubqueryAlias) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to waste memory unnecessarily if the subquery is the first table in the join and therefore unnecessary to cache. Maybe add a TODO to fix? (algorithm to determine this case doesn't map easily to one of the transform up methods, i don't think)
…achedResults nodes from join plans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG!
} | ||
} else if j, isIndexedJoin := parent.(*plan.IndexedJoin); isIndexedJoin { | ||
if j.JoinType() == plan.JoinTypeRight { | ||
return childNum == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong -- indexed joins always put the primary table as the first table, even if it's a right join
…t child of indexed joins.
…y-alias-results-in-joins
No description provided.