Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize joins, redirect dml for reference tables (vitessio#11875)
* go/vt/vtgate, proto: add "source" field to vschema * Add "source" field to vschema reference tables. * Model "source" field in go/vt/vtgate/vindexes/vschema.go. * Treat multiple tables in different keyspaces as unambiguous when all of those tables are references to or by each other. Signed-off-by: Max Englander <[email protected]> * go/vt/vtgate/planbuilder: plan reference joins Given: * Two unsharded keyspace `k1` and sharded keyspace `k2`. * Source table `k1.r` and reference table `k2.r`. * Sharded table `k2.x`. The previous commit adds support to globally route `r` to `k1.r`. This means that `SELECT x JOIN r` will join `k1.r` to `x`, but what we want is to join `k2.r`. This commit propagates `vindexes.Table.Source` info from the `vindexes.VSchema` into `operators.Route`, and uses that information when planning joins. Signed-off-by: Max Englander <[email protected]> * go/vt/vtgate/vindexes: test reference source constraints Signed-off-by: Max Englander <[email protected]> * go/vt/vtgate/vindexes: FindTable unit tests for reference sources Signed-off-by: Max Englander <[email protected]> * go/vt/vtgate/vindexes: build keyspace allow unresolved references Signed-off-by: Max Englander <[email protected]> * go/vt/vtgate: executor unit test reference tables Signed-off-by: Max Englander <[email protected]> * go/vt/vtgate: executor unit test reference dml Signed-off-by: Max Englander <[email protected]> * go/vt/vtgate/vindexes: avoid bi-directional references (causes infinite loop) Signed-off-by: Max Englander <[email protected]> * go/test/endtoend/vtgate: test reference tables Signed-off-by: Max Englander <[email protected]> * tidy up Signed-off-by: Max Englander <[email protected]> * address pr comments round 1 Signed-off-by: Max Englander <[email protected]> * address pr feedback round 2: dont use replicas in tests when not needed Signed-off-by: Max Englander <[email protected]> * address pr feedback round 2: use vterrors in vschema.go Signed-off-by: Max Englander <[email protected]> * fix tests Signed-off-by: Max Englander <[email protected]> * address pr feedback round 3: fix e2e test Signed-off-by: Max Englander <[email protected]> * address pr feedback round 3: optimally route dml Signed-off-by: Max Englander <[email protected]> * address pr feedback round 3: fix e2e & plan tests (primitive.GetTablesUsed) Signed-off-by: Max Englander <[email protected]> * forgot to commit these 🤦 Signed-off-by: Max Englander <[email protected]> * move TablesUsed from engine => planbuilder Signed-off-by: Max Englander <[email protected]> * rm engine.(any).GetTablesUsed Signed-off-by: Max Englander <[email protected]> * rm engine.(any).MergedWith; revert engine.(*Route).TableNames => engine.(*Route).TableName Signed-off-by: Max Englander <[email protected]> * tidy up Signed-off-by: Max Englander <[email protected]> * address pr feedback round 3: redir gen4 insert to source Signed-off-by: Max Englander <[email protected]> * address pr feedback round 4: remove unused (vindexFunc).TableName Signed-off-by: Max Englander <[email protected]> Signed-off-by: Max Englander <[email protected]>
- Loading branch information