-
Notifications
You must be signed in to change notification settings - Fork 4k
opt: Improve FuncDepSet #27046
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
opt: Improve FuncDepSet #27046
Conversation
|
Some minor comments for r1 (posting separately so it's easier to keep track of which commit to update). Review status: pkg/sql/opt/props/func_dep.go, line 737 at r1 (raw file):
I wondered if we should also set pkg/sql/opt/props/func_dep.go, line 748 at r1 (raw file):
[nit] This is a bit misleading. There are two cases:
pkg/sql/opt/props/func_dep_test.go, line 472 at r1 (raw file):
single column pkg/sql/opt/props/func_dep_test.go, line 473 at r1 (raw file):
a=1? Comments from Reviewable |
|
r2 LGTM Review status: pkg/sql/opt/props/func_dep.go, line 721 at r2 (raw file):
[nit] columns Comments from Reviewable |
|
r3,r4 LGTM Review status: pkg/sql/opt/props/func_dep.go, line 986 at r5 (raw file):
Could you add a pkg/sql/opt/props/func_dep_test.go, line 597 at r5 (raw file):
[nit] should be Comments from Reviewable |
|
question on r6 Review status: pkg/sql/opt/props/func_dep.go, line 810 at r6 (raw file):
Can't we also replace any removed columns in Comments from Reviewable |
|
r7 LGTM Review status: pkg/sql/opt/norm/testdata/rules/decorrelate, line 643 at r8 (raw file):
Why is pkg/sql/opt/props/func_dep.go, line 1071 at r9 (raw file):
Should we check that there are no const cols in any Comments from Reviewable |
|
Review status: pkg/sql/opt/norm/testdata/rules/decorrelate, line 643 at r8 (raw file): Previously, RaduBerinde wrote…
We always simplify constants when directly adding them. But there are transitive cases where a previously lax dependency becomes a strict dependency where we might end up with transitive constants that aren't rolled into the constant FD. That's OK, as it would be expensive to always keep that up-to-date. I usually wait until It's a known All that said, you've found a bug in the FD rules. In the general case, it's not safe to do that (in this special case it's correct, b/c (6) is a key of the row-supplying side). I went ahead and removed the code that is adding a constant to other FD's when we make make that constant lax as part of pkg/sql/opt/props/func_dep.go, line 737 at r1 (raw file): Previously, RaduBerinde wrote…
Actually, this line can just be simplified to pkg/sql/opt/props/func_dep.go, line 748 at r1 (raw file): Previously, RaduBerinde wrote…
I've updated the comment to be more clear. pkg/sql/opt/props/func_dep.go, line 721 at r2 (raw file): Previously, RaduBerinde wrote…
Done. pkg/sql/opt/props/func_dep.go, line 986 at r5 (raw file): Previously, RaduBerinde wrote…
I updated the example - for some reason I thought this case was covered, but it's not. pkg/sql/opt/props/func_dep.go, line 810 at r6 (raw file): Previously, RaduBerinde wrote…
Yes, good idea. I added a commit to the end of this PR to do that. pkg/sql/opt/props/func_dep.go, line 1071 at r9 (raw file): Previously, RaduBerinde wrote…
For reasons I explain in another comment, it's only best effort to maintain the complete closure of the constant FD (and to then remove constants from other locations in the FD). If we see important benefits to doing it, we can reconsider. pkg/sql/opt/props/func_dep_test.go, line 472 at r1 (raw file): Previously, RaduBerinde wrote…
Done. pkg/sql/opt/props/func_dep_test.go, line 473 at r1 (raw file): Previously, RaduBerinde wrote…
Done. pkg/sql/opt/props/func_dep_test.go, line 597 at r5 (raw file): Previously, RaduBerinde wrote…
Done. Comments from Reviewable |
|
Reviewed 1 of 36 files at r10, 1 of 3 files at r16, 31 of 31 files at r17, 1 of 3 files at r18, 2 of 2 files at r19. Comments from Reviewable |
|
Reviewed 36 of 36 files at r10, 2 of 2 files at r11, 2 of 2 files at r12, 2 of 2 files at r13, 2 of 2 files at r14, 3 of 3 files at r15, 3 of 3 files at r16, 31 of 31 files at r17, 3 of 3 files at r18, 2 of 2 files at r19. pkg/sql/opt/props/func_dep.go, line 934 at r13 (raw file):
The comment above implies you don't need this call here. Maybe add a comment here or update the comment above. pkg/sql/opt/props/func_dep.go, line 986 at r14 (raw file):
It's a bit odd that you only included the CREATE TABLE statement for pkg/sql/opt/props/func_dep.go, line 1037 at r14 (raw file):
Isn't this actually rule #1? pkg/sql/opt/props/func_dep.go, line 771 at r15 (raw file):
Can you give an example of an edge case? pkg/sql/opt/props/func_dep.go, line 828 at r15 (raw file):
Why is this necessary? Shouldn't constants have already been removed from all determinants by previous normalization? pkg/sql/opt/props/func_dep.go, line 864 at r15 (raw file):
Maybe you mean IndexJoin (since these are different now)? Also, can you add a comment to explain what the pkg/sql/opt/props/func_dep.go, line 1064 at r18 (raw file):
determinants -> dependants pkg/sql/opt/props/func_dep.go, line 728 at r19 (raw file):
Why not just call pkg/sql/opt/props/func_dep.go, line 827 at r19 (raw file):
You could add another check that Comments from Reviewable |
Release note: None
Release note: None
Release note: None
Release note: None
Allow equivalent columns in outer join cases like: SELECT * FROM ab LEFT OUTER JOIN cde ON a=c Add rule to downgrade any dependencies that cross join boundaries, by either dropping them entirely, or making them lax. For example, the (c)==(a) dependency becomes just (c)~~>(a), and (a)==(c) is dropped entirely. Release note: None
Currently, ProjectCols sometimes marks un-projected columns as "removed" rather than actually removing them. This commit gets rid of the removed set and instead discards or modifies FDs that include un-projected columns. Release note: None
This commit fixes a bug in which incorrect constant dependencies are sometimes generated for apply joins. For example: SELECT * FROM abcde INNER JOIN LATERAL (SELECT * FROM mnpq WHERE m=a LIMIT 1) ON True A constant dependency for the columns of mnpq is generated, since all columns in a relation having zero or one rows are constants. However, since the value of the inner relation can change based on the value of the outer relation, this constant dependency cannot be propagated to the join's logical properties. Release note: None
This commit updates all the unit tests to reflect the FD set changes made in previous commits. Release note: None
Add some verification checks to FuncDepSet and run them in testrace builds. Release note: None
|
bors r+ |
|
bors r- |
Canceled |
In the FD ProjectCols method, before removing a column that is not part of a projection, try to find an equivalent column that can be substituted for it. This enables us to preserve that FD rather than discarding it. Release note: None
|
bors r+ |
27046: opt: Improve FuncDepSet r=andy-kimball a=andy-kimball This PR contains a number of improvements and fixes to the functional dependency library: - Normalize constants and equivalencies so there's less redundancy - Allow MakeOuter dependencies that cross join boundaries - Make ProjectCols actually remove un-projected columns - Fix FDs generated for apply joins - Add Verify method to FuncDepSet Together, these changes clean up the FD logical props so that they're more compact and more efficient. Co-authored-by: Andrew Kimball <andyk@cockroachlabs.com>
Build succeeded |
This PR contains a number of improvements and fixes to the functional
dependency library:
Together, these changes clean up the FD logical props so that they're
more compact and more efficient.