You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm going to mail a PR that adds this test case documenting the limitation. Not sure what it would take to fix it. Query planning would succeed if one of the left joins were removed:
# Multi-table unique vindex constraint on left table of left join, two levels of join, simple aggregation
# This should work, but doesn't. If you remove the join with ue2 this works, but for some reason when
# there are two levels of left join instead of just one the query planner fails to realize that all these
# rows must belong to the same shard.
"select user.id, count(*) from user left join user_extra ue1 on user.id = ue1.user_id left join user_extra ue2 on ue1.user_id = ue2.user_id group by user.id"
"unsupported: cross-shard query with aggregates"
The text was updated successfully, but these errors were encountered:
There's a workaround, incidentally, which is adding "and user.id = ue2.user_id" to the second "on" clause. That should be implied from user.id = ue1.user_id && ue1.user_id = ue2._user_id, though, since both of those use unique vindexes.
Fixesvitessio#4772Fixesvitessio#5508
Previously, vitess was conservative about using vindexes for tables
involving left joins. After some reasoning, we've determined that it's
actually safe (and more efficient) to use them.
In existing functionality, a reference table had to be on the RHS
of the analysis. There was no benefit if it was on the LHS. When
we changed dual to be a Reference tables, it caused a regression.
If dual was on the LHS of a join or subquery, then it would get
treated as cross-shard. The new change handles the case of ref
tables to be on the LHS. This also fixes the regression.
Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
I'm going to mail a PR that adds this test case documenting the limitation. Not sure what it would take to fix it. Query planning would succeed if one of the left joins were removed:
The text was updated successfully, but these errors were encountered: