Remove redundant same-shard check for cross-shard updates#1141
Conversation
We don't need to check this in insert_row, we already checked if we're on the same shard in UpdateMulti::execute_internal before calling this
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Could you point me to the check? Also, we have a conflicting PR in flight to support multi-row updates #1109 |
|
I don't think this should cause problems with the other PR, the same-shard check in that PR is redundant as best I can tell |
|
I think this check is there to prevent the trivial case where the the sharding key is in the where-clause. But, the other check also checks for this: UPDATE users SET sharding_key = $5 WHERE banned = true;We check if the rows returned by the |
|
Do you think it's worth the added complexity (especially in that other PR which makes this check even more complex) to avoid doing a multi-step update on edge cases like that? Personally I'm fine with it just doing the select/delete/insert in cases where we can't statically determine the shard from the where clause, but I don't feel super strongly |
|
I think so yeah. You could add a comment there as part of this PR and think about it some more - definitely don't want to lose this context. The more complexity we handle, the less the user has to worry about. |
|
I don't think it's something the user has to worry about. The end result is the same either way, it's purely a performance optimization, not a semantic one |
|
True. But yeah, we should keep this imo, especially since we can't do all sharding key updates yet. |
|
Okie dokie |
|
(Gonna try and come back and add an explicit test case for this when I have time) |
We don't need to check this in insert_row, we already checked if we're on the same shard in UpdateMulti::execute_internal before calling this