Closed wiebeytec closed 11 months ago
I'll address the documentation part of this. This is in fact documented, you just have to follow the link to unsupported queries
from the page you are looking at.
Direct link: https://github.com/vitessio/vitess/blob/main/go/vt/vtgate/planbuilder/testdata/unsupported_cases.json#L59
This is currently not supported for sharded keyspaces.
Related issue: https://github.com/vitessio/vitess/issues/12677
I'll address the documentation part of this. This is in fact documented, you just have to follow the link to
unsupported queries
from the page you are looking at. Direct link: https://github.com/vitessio/vitess/blob/main/go/vt/vtgate/planbuilder/testdata/unsupported_cases.json#L59
That query joins to user_extra
. In go/vt/vtgate/testdata/executorVSchema.json
, user_extra
is not a reference table.
That query joins to
user_extra
. Ingo/vt/vtgate/testdata/executorVSchema.json
,user_extra
is not a reference table.
Good point. Given that we are supposed to be able to join with reference tables efficiently for selects, it is reasonable to ask why it doesn't work the same way for update and delete. @harshit-gangal both you and I are wrong. This is not the same as #12677. Can we look into how we plan queries that involve reference tables? maybe there is a somewhat quick way of extending what we do in SELECT planning to DMLs. cc @systay
We need to remodel our update
and delete
operators to incorporate multi-table, then it would not matter if it is a reference table or not.
I'm not quite sure if you mean that makes it easy or hard, but just to be sure my 2 cents:
Are you talking about full support for multi-shard write, even when I invert the join condition? Like so:
DELETE users
FROM users
INNER JOIN other_data_from_shard
ON users.user_id <> other_data_from_shard.user_id
;
Because this is not "just" a matter of executing the query on the shard (because it would delete way too much: edit: or, would it delete not enough 🤔), whereas doing it with reference tables is, I think?
Once the planning work is undertaken for this. It should work as expected for the query above based on the join/where condition.
Overview of the Issue
I'm not sure if this is a bug report or feature request.
When happily setting up our Vitess cluster and testing our app on it, I ran into (undocumented) limitations on joining with UPDATE and DELETE. If the following does not apply, perhaps MySQL compatability needs updating to describe this?
When one does a
DELETE
withJOIN
to sharded data, it says:VT12001: unsupported: multi-shard or vindex write statement
. However, I think joining to reference tables should actually be possible?At first glance, I thought a query like the following should work even with sharded tables:
However, I can understand this becomes a problem when you invert your
ON
condition, for instance.But, for reference tables, deleting (and updating) with JOINs should be possible?
My work-around for now is composing a string with IDs to be used in the query.
Reproduction Steps
I started three tablets with a sharded and unsharded keyspace:
VSchema:
Apply:
./vtctldclient ApplyVSchema --vschema-file bug_report_inner_join_delete.vschema playground_sharded
I didn't actually create any tables, because it's not relevant to prove the case. Normally I would populate the reference table with a
Materialize
workflow.On the gate:
Binary Version
Operating System and Environment details
Log Fragments
No response