From db6115cf9ec4413e79ac41173dc4df0bcf22fd23 Mon Sep 17 00:00:00 2001 From: Harshit Gangal Date: Thu, 6 Feb 2025 16:13:53 +0530 Subject: [PATCH] feat: added plan type Signed-off-by: Harshit Gangal --- go/vt/vtgate/engine/plan.go | 162 ++++++-- go/vt/vtgate/executor.go | 10 +- go/vt/vtgate/plan_execute.go | 10 +- go/vt/vtgate/planbuilder/builder.go | 9 +- .../planbuilder/testdata/aggr_cases.json | 172 ++++++++ .../testdata/alterVschema_cases.json | 9 + .../testdata/bypass_keyrange_cases.json | 10 + .../testdata/bypass_shard_cases.json | 15 + .../planbuilder/testdata/call_cases.json | 3 + .../planbuilder/testdata/cte_cases.json | 63 +++ .../planbuilder/testdata/ddl_cases.json | 27 ++ .../ddl_cases_no_default_keyspace.json | 36 ++ .../planbuilder/testdata/dml_cases.json | 217 ++++++++++ .../dml_cases_with_user_as_default.json | 3 +- .../planbuilder/testdata/filter_cases.json | 369 ++++++++++++------ .../planbuilder/testdata/flush_cases.json | 4 + .../flush_cases_no_default_keyspace.json | 5 + .../testdata/foreignkey_cases.json | 51 +++ .../testdata/foreignkey_checks_off_cases.json | 15 + .../testdata/foreignkey_checks_on_cases.json | 34 ++ .../planbuilder/testdata/from_cases.json | 123 ++++++ .../testdata/info_schema57_cases.json | 43 ++ .../testdata/info_schema80_cases.json | 48 +++ .../planbuilder/testdata/large_cases.json | 1 + .../testdata/large_union_cases.json | 1 + .../planbuilder/testdata/lock_cases.json | 9 + .../testdata/memory_sort_cases.json | 17 + .../planbuilder/testdata/migration_cases.json | 6 + .../planbuilder/testdata/mirror_cases.json | 11 + .../planbuilder/testdata/misc_cases.json | 9 + .../planbuilder/testdata/oltp_cases.json | 9 + .../testdata/other_admin_cases.json | 5 +- .../testdata/other_read_cases.json | 9 + .../testdata/postprocess_cases.json | 70 ++++ .../planbuilder/testdata/rails_cases.json | 1 + .../planbuilder/testdata/reference_cases.json | 179 +++++---- .../planbuilder/testdata/select_cases.json | 178 +++++++++ .../testdata/select_cases_with_default.json | 1 + .../select_cases_with_user_as_default.json | 1 + .../planbuilder/testdata/set_cases.json | 23 ++ .../testdata/set_sysvar_disabled_cases.json | 3 +- .../planbuilder/testdata/show_cases.json | 49 +++ .../show_cases_no_default_keyspace.json | 6 + .../planbuilder/testdata/stream_cases.json | 1 + .../planbuilder/testdata/symtab_cases.json | 1 + .../testdata/sysschema_default.json | 4 + .../planbuilder/testdata/tpcc_cases.json | 40 ++ .../planbuilder/testdata/tpch_cases.json | 18 + .../testdata/transaction_cases.json | 7 + .../planbuilder/testdata/union_cases.json | 45 +++ .../planbuilder/testdata/use_cases.json | 5 + .../planbuilder/testdata/vexplain_cases.json | 4 + .../planbuilder/testdata/view_cases.json | 4 + .../testdata/vindex_func_cases.json | 10 + .../planbuilder/testdata/wireup_cases.json | 17 + 55 files changed, 1945 insertions(+), 237 deletions(-) diff --git a/go/vt/vtgate/engine/plan.go b/go/vt/vtgate/engine/plan.go index 9ea9f07655c..b0ff42094fb 100644 --- a/go/vt/vtgate/engine/plan.go +++ b/go/vt/vtgate/engine/plan.go @@ -19,6 +19,7 @@ package engine import ( "bytes" "encoding/json" + "fmt" "sync/atomic" "time" @@ -31,41 +32,49 @@ import ( // An instruction (aka Primitive) is typically a tree where // each node does its part by combining the results of the // sub-nodes. -type Plan struct { - Type sqlparser.StatementType // The type of query we have - Original string // Original is the original query. - Instructions Primitive // Instructions contains the instructions needed to fulfil the query. - BindVarNeeds *sqlparser.BindVarNeeds // Stores BindVars needed to be provided as part of expression rewriting - Warnings []*query.QueryWarning // Warnings that need to be yielded every time this query runs - TablesUsed []string // TablesUsed is the list of tables that this plan will query - - ExecCount uint64 // Count of times this plan was executed - ExecTime uint64 // Total execution time - ShardQueries uint64 // Total number of shard queries - RowsReturned uint64 // Total number of rows - RowsAffected uint64 // Total number of rows - Errors uint64 // Total number of errors -} +type ( + PlanType int8 -// AddStats updates the plan execution statistics -func (p *Plan) AddStats(execCount uint64, execTime time.Duration, shardQueries, rowsAffected, rowsReturned, errors uint64) { - atomic.AddUint64(&p.ExecCount, execCount) - atomic.AddUint64(&p.ExecTime, uint64(execTime)) - atomic.AddUint64(&p.ShardQueries, shardQueries) - atomic.AddUint64(&p.RowsAffected, rowsAffected) - atomic.AddUint64(&p.RowsReturned, rowsReturned) - atomic.AddUint64(&p.Errors, errors) -} + Plan struct { + Type PlanType // Type of plan + QueryType sqlparser.StatementType // Type of query + Original string // Original is the original query. + Instructions Primitive // Instructions contains the instructions needed to fulfil the query. + BindVarNeeds *sqlparser.BindVarNeeds // Stores BindVars needed to be provided as part of expression rewriting + Warnings []*query.QueryWarning // Warnings that need to be yielded every time this query runs + TablesUsed []string // TablesUsed is the list of tables that this plan will query -// Stats returns a copy of the plan execution statistics -func (p *Plan) Stats() (execCount uint64, execTime time.Duration, shardQueries, rowsAffected, rowsReturned, errors uint64) { - execCount = atomic.LoadUint64(&p.ExecCount) - execTime = time.Duration(atomic.LoadUint64(&p.ExecTime)) - shardQueries = atomic.LoadUint64(&p.ShardQueries) - rowsAffected = atomic.LoadUint64(&p.RowsAffected) - rowsReturned = atomic.LoadUint64(&p.RowsReturned) - errors = atomic.LoadUint64(&p.Errors) - return + ExecCount uint64 // Count of times this plan was executed + ExecTime uint64 // Total execution time + ShardQueries uint64 // Total number of shard queries + RowsReturned uint64 // Total number of rows + RowsAffected uint64 // Total number of rows + Errors uint64 // Total number of errors + } +) + +const ( + PlanUnknown PlanType = iota + PlanLocal + PlanPassthrough + PlanMultiShard + PlanScatter + PlanLookup + PlanJoinOp + PlanComplex + PlanOnlineDDL + PlanDirectDDL +) + +func NewPlan(query string, stmt sqlparser.Statement, primitive Primitive, bindVarNeeds *sqlparser.BindVarNeeds, tablesUsed []string) *Plan { + return &Plan{ + Type: getPlanType(primitive), + QueryType: sqlparser.ASTToStatementType(stmt), + Original: query, + Instructions: primitive, + BindVarNeeds: bindVarNeeds, + TablesUsed: tablesUsed, + } } // MarshalJSON serializes the plan into a JSON representation. @@ -77,6 +86,7 @@ func (p *Plan) MarshalJSON() ([]byte, error) { } marshalPlan := struct { + Type string QueryType string Original string `json:",omitempty"` Instructions *PrimitiveDescription `json:",omitempty"` @@ -88,7 +98,8 @@ func (p *Plan) MarshalJSON() ([]byte, error) { Errors uint64 `json:",omitempty"` TablesUsed []string `json:",omitempty"` }{ - QueryType: p.Type.String(), + Type: p.Type.String(), + QueryType: p.QueryType.String(), Original: p.Original, Instructions: instructions, ExecCount: atomic.LoadUint64(&p.ExecCount), @@ -110,3 +121,86 @@ func (p *Plan) MarshalJSON() ([]byte, error) { return b.Bytes(), nil } + +func (p PlanType) String() string { + switch p { + case PlanLocal: + return "Local" + case PlanPassthrough: + return "Passthrough" + case PlanMultiShard: + return "MultiShard" + case PlanScatter: + return "Scatter" + case PlanLookup: + return "Lookup" + case PlanJoinOp: + return "Join" + case PlanComplex: + return "Complex" + case PlanOnlineDDL: + return "OnlineDDL" + case PlanDirectDDL: + return "DirectDDL" + default: + return "Unknown" + } +} + +func getPlanType(p Primitive) PlanType { + switch prim := p.(type) { + case *Route: + return getPlanTypeFromRoutingParams(prim.RoutingParameters) + case *Update: + return getPlanTypeFromRoutingParams(prim.RoutingParameters) + case *Delete: + return getPlanTypeFromRoutingParams(prim.RoutingParameters) + case *Insert: + + case *Send: + case *Join: + case *DDL: + default: + return PlanComplex + + } + return PlanUnknown +} + +func getPlanTypeFromRoutingParams(rp *RoutingParameters) PlanType { + if rp == nil { + panic("RoutingParameters is nil, cannot determine plan type") + } + switch rp.Opcode { + case Unsharded, EqualUnique, Next, DBA, Reference: + return PlanPassthrough + case Equal, IN, Between, MultiEqual, SubShard, ByDestination: + return PlanMultiShard + case Scatter: + return PlanScatter + case None: + return PlanLocal + } + panic(fmt.Sprintf("cannot determine plan type for the given opcode: %s", rp.Opcode.String())) +} + +// AddStats updates the plan execution statistics +func (p *Plan) AddStats(execCount uint64, execTime time.Duration, shardQueries, rowsAffected, rowsReturned, errors uint64) { + atomic.AddUint64(&p.ExecCount, execCount) + atomic.AddUint64(&p.ExecTime, uint64(execTime)) + atomic.AddUint64(&p.ShardQueries, shardQueries) + atomic.AddUint64(&p.RowsAffected, rowsAffected) + atomic.AddUint64(&p.RowsReturned, rowsReturned) + atomic.AddUint64(&p.Errors, errors) +} + +// Stats returns a copy of the plan execution statistics +func (p *Plan) Stats() (execCount uint64, execTime time.Duration, shardQueries, rowsAffected, rowsReturned, errors uint64) { + execCount = atomic.LoadUint64(&p.ExecCount) + execTime = time.Duration(atomic.LoadUint64(&p.ExecTime)) + shardQueries = atomic.LoadUint64(&p.ShardQueries) + rowsAffected = atomic.LoadUint64(&p.RowsAffected) + rowsReturned = atomic.LoadUint64(&p.RowsReturned) + errors = atomic.LoadUint64(&p.Errors) + return +} diff --git a/go/vt/vtgate/executor.go b/go/vt/vtgate/executor.go index c8dfd0b6269..cbd1364d060 100644 --- a/go/vt/vtgate/executor.go +++ b/go/vt/vtgate/executor.go @@ -307,7 +307,7 @@ func (e *Executor) StreamExecute( var seenResults atomic.Bool var resultMu sync.Mutex result := &sqltypes.Result{} - if canReturnRows(plan.Type) { + if canReturnRows(plan.QueryType) { srr.callback = func(qr *sqltypes.Result) error { resultMu.Lock() defer resultMu.Unlock() @@ -345,18 +345,18 @@ func (e *Executor) StreamExecute( // 4: Execute! err := vc.StreamExecutePrimitive(ctx, plan.Instructions, bindVars, true, func(qr *sqltypes.Result) error { - return srr.storeResultStats(plan.Type, qr) + return srr.storeResultStats(plan.QueryType, qr) }) // Check if there was partial DML execution. If so, rollback the effect of the partially executed query. if err != nil { - if !canReturnRows(plan.Type) { + if !canReturnRows(plan.QueryType) { return e.rollbackExecIfNeeded(ctx, safeSession, bindVars, logStats, err) } return err } - if !canReturnRows(plan.Type) { + if !canReturnRows(plan.QueryType) { return nil } @@ -435,7 +435,7 @@ func (e *Executor) execute(ctx context.Context, mysqlCtx vtgateservice.MySQLConn var qr *sqltypes.Result var stmtType sqlparser.StatementType err = e.newExecute(ctx, mysqlCtx, safeSession, sql, bindVars, logStats, func(ctx context.Context, plan *engine.Plan, vc *econtext.VCursorImpl, bindVars map[string]*querypb.BindVariable, time time.Time) error { - stmtType = plan.Type + stmtType = plan.QueryType qr, err = e.executePlan(ctx, safeSession, plan, vc, bindVars, logStats, time) return err }, func(typ sqlparser.StatementType, result *sqltypes.Result) error { diff --git a/go/vt/vtgate/plan_execute.go b/go/vt/vtgate/plan_execute.go index 75a7af6bf2a..b3c411b1755 100644 --- a/go/vt/vtgate/plan_execute.go +++ b/go/vt/vtgate/plan_execute.go @@ -139,7 +139,7 @@ func (e *Executor) newExecute( return err } - if plan.Type != sqlparser.StmtShow { + if plan.QueryType != sqlparser.StmtShow { safeSession.ClearWarnings() } @@ -157,7 +157,7 @@ func (e *Executor) newExecute( return err } if result != nil { - return recResult(plan.Type, result) + return recResult(plan.QueryType, result) } // 4: Prepare for execution. @@ -234,7 +234,7 @@ func (e *Executor) handleTransactions( ) (*sqltypes.Result, error) { // We need to explicitly handle errors, and begin/commit/rollback, since these control transactions. Everything else // will fall through and be handled through planning - switch plan.Type { + switch plan.QueryType { case sqlparser.StmtBegin: qr, err := e.handleBegin(ctx, safeSession, logStats, stmt) return qr, err @@ -390,7 +390,7 @@ func (e *Executor) rollbackPartialExec(ctx context.Context, safeSession *econtex } func (e *Executor) setLogStats(logStats *logstats.LogStats, plan *engine.Plan, vcursor *econtext.VCursorImpl, execStart time.Time, err error, qr *sqltypes.Result) { - logStats.StmtType = plan.Type.String() + logStats.StmtType = plan.QueryType.String() logStats.ActiveKeyspace = vcursor.GetKeyspace() logStats.TablesUsed = plan.TablesUsed logStats.TabletType = vcursor.TabletType().String() @@ -417,7 +417,7 @@ func (e *Executor) logExecutionEnd(logStats *logstats.LogStats, execStart time.T func (e *Executor) logPlanningFinished(logStats *logstats.LogStats, plan *engine.Plan) time.Time { execStart := time.Now() if plan != nil { - logStats.StmtType = plan.Type.String() + logStats.StmtType = plan.QueryType.String() } logStats.PlanTime = execStart.Sub(logStats.StartTime) return execStart diff --git a/go/vt/vtgate/planbuilder/builder.go b/go/vt/vtgate/planbuilder/builder.go index 85d9f5f94ea..baec8b3175f 100644 --- a/go/vt/vtgate/planbuilder/builder.go +++ b/go/vt/vtgate/planbuilder/builder.go @@ -115,14 +115,7 @@ func BuildFromStmt(ctx context.Context, query string, stmt sqlparser.Statement, primitive = planResult.primitive tablesUsed = planResult.tables } - plan := &engine.Plan{ - Type: sqlparser.ASTToStatementType(stmt), - Original: query, - Instructions: primitive, - BindVarNeeds: bindVarNeeds, - TablesUsed: tablesUsed, - } - return plan, nil + return engine.NewPlan(query, stmt, primitive, bindVarNeeds, tablesUsed), nil } func getConfiguredPlanner(vschema plancontext.VSchema, stmt sqlparser.Statement, query string) (stmtPlanner, error) { diff --git a/go/vt/vtgate/planbuilder/testdata/aggr_cases.json b/go/vt/vtgate/planbuilder/testdata/aggr_cases.json index 1ecbf3d4ff9..1b97d1ac116 100644 --- a/go/vt/vtgate/planbuilder/testdata/aggr_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/aggr_cases.json @@ -3,6 +3,7 @@ "comment": "count(*) spread across join", "query": "select count(*) from user join user_extra on user.foo = user_extra.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user join user_extra on user.foo = user_extra.bar", "Instructions": { @@ -63,6 +64,7 @@ "comment": "sum spread across join", "query": "select sum(user.col) from user join user_extra on user.foo = user_extra.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(user.col) from user join user_extra on user.foo = user_extra.bar", "Instructions": { @@ -123,6 +125,7 @@ "comment": "count spread across join", "query": "select count(user.col) from user join user_extra on user.foo = user_extra.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(user.col) from user join user_extra on user.foo = user_extra.bar", "Instructions": { @@ -183,6 +186,7 @@ "comment": "max spread across join", "query": "select max(user.col) from user join user_extra on user.foo = user_extra.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select max(user.col) from user join user_extra on user.foo = user_extra.bar", "Instructions": { @@ -235,6 +239,7 @@ "comment": "min spread across join RHS", "query": "select min(user_extra.col) from user join user_extra on user.foo = user_extra.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select min(user_extra.col) from user join user_extra on user.foo = user_extra.bar", "Instructions": { @@ -287,6 +292,7 @@ "comment": "group by a unique vindex should revert to simple route, and having clause should find the correct symbols.", "query": "select id, count(*) c from user group by id having max(col) > 10", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, count(*) c from user group by id having max(col) > 10", "Instructions": { @@ -309,6 +315,7 @@ "comment": "scatter aggregate in a subquery", "query": "select a from (select count(*) as a from user) t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a from (select count(*) as a from user) t", "Instructions": { @@ -338,6 +345,7 @@ "comment": "scatter aggregate with non-aggregate expressions.", "query": "select id, count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, count(*) from user", "Instructions": { @@ -367,6 +375,7 @@ "comment": "scatter aggregate using distinctdistinct", "query": "select distinct col from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct col from user", "Instructions": { @@ -397,6 +406,7 @@ "comment": "scatter aggregate group by select col", "query": "select col from user group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user group by col", "Instructions": { @@ -427,6 +437,7 @@ "comment": "count with distinct group by unique vindex", "query": "select id, count(distinct col) from user group by id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, count(distinct col) from user group by id", "Instructions": { @@ -449,6 +460,7 @@ "comment": "count with distinct unique vindex", "query": "select col, count(distinct id), sum(distinct id) from user group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(distinct id), sum(distinct id) from user group by col", "Instructions": { @@ -480,6 +492,7 @@ "comment": "count with distinct no unique vindex", "query": "select col1, count(distinct col2) from user group by col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, count(distinct col2) from user group by col1", "Instructions": { @@ -512,6 +525,7 @@ "comment": "count with distinct no unique vindex and no group by", "query": "select count(distinct col2) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(distinct col2) from user", "Instructions": { @@ -543,6 +557,7 @@ "comment": "WITH ROLLUP on unsharded keyspaces", "query": "select a, b, count(*) from unsharded group by a, b with rollup", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select a, b, count(*) from unsharded group by a, b with rollup", "Instructions": { @@ -565,6 +580,7 @@ "comment": "WITH ROLLUP that is pushed to single shard", "query": "select id, user_id, count(*) from music group by id, user_id with rollup", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, user_id, count(*) from music group by id, user_id with rollup", "Instructions": { @@ -587,6 +603,7 @@ "comment": "count with distinct no unique vindex, count expression aliased", "query": "select col1, count(distinct col2) c2 from user group by col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, count(distinct col2) c2 from user group by col1", "Instructions": { @@ -619,6 +636,7 @@ "comment": "using HAVING inside a derived table still produces viable plans", "query": "select id from (select id from user group by id having (count(user.id) = 2) limit 2 offset 0) subquery_for_limit", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from (select id from user group by id having (count(user.id) = 2) limit 2 offset 0) subquery_for_limit", "Instructions": { @@ -648,6 +666,7 @@ "comment": "sum with distinct no unique vindex", "query": "select col1, sum(distinct col2) from user group by col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, sum(distinct col2) from user group by col1", "Instructions": { @@ -680,6 +699,7 @@ "comment": "min with distinct no unique vindex. distinct is ignored.", "query": "select col1, min(distinct col2) from user group by col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, min(distinct col2) from user group by col1", "Instructions": { @@ -712,6 +732,7 @@ "comment": "order by count distinct", "query": "select col1, count(distinct col2) k from user group by col1 order by k", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, count(distinct col2) k from user group by col1 order by k", "Instructions": { @@ -761,6 +782,7 @@ "comment": "scatter aggregate multiple group by (columns)", "query": "select a, b, count(*) from user group by a, b", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) from user group by a, b", "Instructions": { @@ -793,6 +815,7 @@ "comment": "Aggregation with derived table", "query": "select u.id, u.name, t.num_segments from (select id, count(*) as num_segments from user group by 1 order by 2 desc limit 20) t join unsharded u on u.id = t.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.id, u.name, t.num_segments from (select id, count(*) as num_segments from user group by 1 order by 2 desc limit 20) t join unsharded u on u.id = t.id", "Instructions": { @@ -845,6 +868,7 @@ "comment": "scatter aggregate multiple group by (numbers)", "query": "select a, b, count(*) from user group by 2, 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) from user group by 2, 1", "Instructions": { @@ -877,6 +901,7 @@ "comment": "scatter aggregate multiple group by columns inverse order", "query": "select a, b, count(*) from user group by b, a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) from user group by b, a", "Instructions": { @@ -909,6 +934,7 @@ "comment": "group concat with a separator needing evaluation on vtgate", "query": "select group_concat(music.name SEPARATOR ', ') as `Group Name` from user join user_extra on user.id = user_extra.user_id left join music on user.id = music.id group by user.id;", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select group_concat(music.name SEPARATOR ', ') as `Group Name` from user join user_extra on user.id = user_extra.user_id left join music on user.id = music.id group by user.id;", "Instructions": { @@ -994,6 +1020,7 @@ "comment": "scatter aggregate group by column number", "query": "select col from user group by 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user group by 1", "Instructions": { @@ -1029,6 +1056,7 @@ "comment": "scatter aggregate order by null", "query": "select count(*) from user order by null", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user order by null", "Instructions": { @@ -1058,6 +1086,7 @@ "comment": "scatter aggregate with numbered order by columns", "query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by 1, 2, 3", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by 1, 2, 3", "Instructions": { @@ -1090,6 +1119,7 @@ "comment": "scatter aggregate with named order by columns", "query": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by a, b, c", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, c, d, count(*) from user group by 1, 2, 3 order by a, b, c", "Instructions": { @@ -1122,6 +1152,7 @@ "comment": "scatter aggregate with jumbled order by columns", "query": "select a, b, c, d, count(*) from user group by 1, 2, 3, 4 order by d, b, a, c", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, c, d, count(*) from user group by 1, 2, 3, 4 order by d, b, a, c", "Instructions": { @@ -1154,6 +1185,7 @@ "comment": "scatter aggregate with jumbled group by and order by columns", "query": "select a, b, c, d, count(*) from user group by 3, 2, 1, 4 order by d, b, a, c", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, c, d, count(*) from user group by 3, 2, 1, 4 order by d, b, a, c", "Instructions": { @@ -1186,6 +1218,7 @@ "comment": "scatter aggregate with some descending order by cols", "query": "select a, b, c, count(*) from user group by 3, 2, 1 order by 1 desc, 3 desc, b", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, c, count(*) from user group by 3, 2, 1 order by 1 desc, 3 desc, b", "Instructions": { @@ -1223,6 +1256,7 @@ "comment": "aggregate with limit", "query": "select col, count(*) from user group by col limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(*) from user group by col limit 10", "Instructions": { @@ -1260,6 +1294,7 @@ "comment": "routing rules for aggregates", "query": "select id, count(*) from route2 group by id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id, count(*) from route2 group by id", "Instructions": { @@ -1282,6 +1317,7 @@ "comment": "order by on a reference table", "query": "select col from ref order by col", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from ref order by col", "Instructions": { @@ -1304,6 +1340,7 @@ "comment": "distinct and aggregate functions missing group by", "query": "select distinct a, count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct a, count(*) from user", "Instructions": { @@ -1333,6 +1370,7 @@ "comment": "distinct and aggregate functions", "query": "select distinct a, count(*) from user group by a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct a, count(*) from user group by a", "Instructions": { @@ -1365,6 +1403,7 @@ "comment": "Group by invalid column number (code is duplicated from symab).", "query": "select id from user group by 1.1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user group by 1.1", "Instructions": { @@ -1402,6 +1441,7 @@ "comment": "here it is safe to remove the order by on the derived table since it will not influence the output of the count(*)", "query": "select count(*) from (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) a", "Instructions": { @@ -1432,6 +1472,7 @@ "comment": "order by inside derived tables can be ignored", "query": "select col from (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) a", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) a", "Instructions": { @@ -1455,6 +1496,7 @@ "comment": "here we keep the order since the column is visible on the outside, and used by the orderedAggregate", "query": "select col, count(*) from (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) a group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(*) from (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) a group by col", "Instructions": { @@ -1487,6 +1529,7 @@ "comment": "optimize group by when using distinct with no aggregation", "query": "select distinct col1, col2 from user group by col1, col2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct col1, col2 from user group by col1, col2", "Instructions": { @@ -1519,6 +1562,7 @@ "comment": "do not use distinct when using only aggregates and no group by", "query": "select distinct count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct count(*) from user", "Instructions": { @@ -1548,6 +1592,7 @@ "comment": "Grouping on join", "query": "select user.a from user join user_extra group by user.a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.a from user join user_extra group by user.a", "Instructions": { @@ -1599,6 +1644,7 @@ "comment": "multiple distinct functions with grouping.", "query": "select col1, count(distinct col2), sum(distinct col2) from user group by col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, count(distinct col2), sum(distinct col2) from user group by col1", "Instructions": { @@ -1631,6 +1677,7 @@ "comment": "aggregate query with order by aggregate column along with NULL", "query": "select col, count(*) k from user group by col order by null, k", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(*) k from user group by col order by null, k", "Instructions": { @@ -1669,6 +1716,7 @@ "comment": "aggregate query with order by NULL", "query": "select col, count(*) k from user group by col order by null", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(*) k from user group by col order by null", "Instructions": { @@ -1700,6 +1748,7 @@ "comment": "join query on sharding key with group by a unique vindex with having clause.", "query": "select user.id, count(*) c from user, user_extra where user.id = user_extra.user_id group by user.id having max(user.col) > 10", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.id, count(*) c from user, user_extra where user.id = user_extra.user_id group by user.id having max(user.col) > 10", "Instructions": { @@ -1723,6 +1772,7 @@ "comment": "correlated subquery on sharding key with group by a unique vindex with having clause.", "query": "select count(*) from user where exists (select 1 from user_extra where user_id = user.id group by user_id having max(col) > 10)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user where exists (select 1 from user_extra where user_id = user.id group by user_id having max(col) > 10)", "Instructions": { @@ -1753,6 +1803,7 @@ "comment": "aggregation filtering by having on a route", "query": "select id from user group by id having count(id) = 10", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user group by id having count(id) = 10", "Instructions": { @@ -1775,6 +1826,7 @@ "comment": "weight_string addition to group by", "query": "select lower(col1) as v, count(*) from authoritative group by v", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select lower(col1) as v, count(*) from authoritative group by v", "Instructions": { @@ -1806,6 +1858,7 @@ "comment": "weight_string addition to group by when also there in order by", "query": "select char_length(col1) as a, count(*) from authoritative group by a order by a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select char_length(col1) as a, count(*) from authoritative group by a order by a", "Instructions": { @@ -1837,6 +1890,7 @@ "comment": "order by inside and outside parenthesis select", "query": "(select id from user order by 1 desc) order by 1 asc limit 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(select id from user order by 1 desc) order by 1 asc limit 2", "Instructions": { @@ -1867,6 +1921,7 @@ "comment": "correlated subquery in exists clause with an ordering", "query": "select col, id from user where exists(select user_id from user_extra where user_id = 3 and user_id < user.id) order by id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, id from user where exists(select user_id from user_extra where user_id = 3 and user_id < user.id) order by id", "Instructions": { @@ -1918,6 +1973,7 @@ "comment": "Column and Literal equality filter on scatter aggregates", "query": "select count(*) a from user having a = 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a = 10", "Instructions": { @@ -1953,6 +2009,7 @@ "comment": "Equality filtering with column and string literal on scatter aggregates", "query": "select count(*) a from user having a = '1'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a = '1'", "Instructions": { @@ -1988,6 +2045,7 @@ "comment": "Column and Literal not equal filter on scatter aggregates", "query": "select count(*) a from user having a != 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a != 10", "Instructions": { @@ -2023,6 +2081,7 @@ "comment": "Not equal filter with column and string literal on scatter aggregates", "query": "select count(*) a from user having a != '1'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a != '1'", "Instructions": { @@ -2058,6 +2117,7 @@ "comment": "Greater than filter on scatter aggregates", "query": "select count(*) a from user having a > 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a > 10", "Instructions": { @@ -2093,6 +2153,7 @@ "comment": "Greater Equal filter on scatter aggregates", "query": "select count(*) a from user having a >= 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a >= 10", "Instructions": { @@ -2128,6 +2189,7 @@ "comment": "Less than filter on scatter aggregates", "query": "select count(*) a from user having a < 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a < 10", "Instructions": { @@ -2163,6 +2225,7 @@ "comment": "Less Equal filter on scatter aggregates", "query": "select count(*) a from user having a <= 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a <= 10", "Instructions": { @@ -2198,6 +2261,7 @@ "comment": "Less Equal filter on scatter with grouping", "query": "select col1, count(*) a from user group by col1 having a <= 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, count(*) a from user group by col1 having a <= 10", "Instructions": { @@ -2236,6 +2300,7 @@ "comment": "We should be able to find grouping keys on ordered aggregates", "query": "select count(*) as a, col2 from user group by col2 having a = 1.00", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) as a, col2 from user group by col2 having a = 1.00", "Instructions": { @@ -2274,6 +2339,7 @@ "comment": "User defined aggregation expression being used in order by of a query that is single sharded", "query": "select col1, udf_aggr( col2 ) r from user where id = 1 group by col1 having r >= 0.3", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col1, udf_aggr( col2 ) r from user where id = 1 group by col1 having r >= 0.3", "Instructions": { @@ -2300,6 +2366,7 @@ "comment": "user defined aggregation such that it can pushed to mysql in a scatter route", "query": "select id, udf_aggr( col2 ) r from user group by id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, udf_aggr( col2 ) r from user group by id", "Instructions": { @@ -2322,6 +2389,7 @@ "comment": "distinct on text column with collation", "query": "select col, count(distinct textcol1) from user group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(distinct textcol1) from user group by col", "Instructions": { @@ -2353,6 +2421,7 @@ "comment": "aggregation filtering by having on a route with no group by with non-unique vindex filter", "query": "select 1 from user having count(id) = 10 and name = 'a'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from user having count(id) = 10 and name = 'a'", "Instructions": { @@ -2418,6 +2487,7 @@ "comment": "Aggregates and joins", "query": "select count(*) from user join user_extra", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user join user_extra", "Instructions": { @@ -2475,6 +2545,7 @@ "comment": "aggregation filtering by having on a route with no group by", "query": "select 1 from user having count(id) = 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from user having count(id) = 10", "Instructions": { @@ -2511,6 +2582,7 @@ "comment": "Aggregate on join", "query": "select user.a, count(*) from user join user_extra group by user.a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.a, count(*) from user join user_extra group by user.a", "Instructions": { @@ -2573,6 +2645,7 @@ "comment": "Aggregate on other table in join", "query": "select user.a, count(user_extra.a) from user join user_extra group by user.a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.a, count(user_extra.a) from user join user_extra group by user.a", "Instructions": { @@ -2635,6 +2708,7 @@ "comment": "aggregation spread out across three routes", "query": "select count(u.textcol1), count(ue.foo), us.bar from user u join user_extra ue on u.foo = ue.bar join unsharded us on ue.bar = us.baz group by us.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(u.textcol1), count(ue.foo), us.bar from user u join user_extra ue on u.foo = ue.bar join unsharded us on ue.bar = us.baz group by us.bar", "Instructions": { @@ -2741,6 +2815,7 @@ "comment": "using two distinct columns - min with distinct vindex, sum with distinct without vindex", "query": "select col1, min(distinct id), sum(distinct col3) from user group by col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, min(distinct id), sum(distinct col3) from user group by col1", "Instructions": { @@ -2773,6 +2848,7 @@ "comment": "aggregation on top of semijoin", "query": "select count(*) from user where exists (select 0 from user_extra where user.apa = user_extra.bar)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user where exists (select 0 from user_extra where user.apa = user_extra.bar)", "Instructions": { @@ -2832,6 +2908,7 @@ "comment": "we have to track the order of distinct aggregation expressions", "query": "select val2, count(distinct val1), count(*) from user group by val2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select val2, count(distinct val1), count(*) from user group by val2", "Instructions": { @@ -2864,6 +2941,7 @@ "comment": "group by column alias", "query": "select ascii(col2) as a, count(*) from user group by a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select ascii(col2) as a, count(*) from user group by a", "Instructions": { @@ -2896,6 +2974,7 @@ "comment": "multiple distinct aggregations on the same column is allowed", "query": "select tcol1, count(distinct tcol2), sum(distinct tcol2) from user group by tcol1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select tcol1, count(distinct tcol2), sum(distinct tcol2) from user group by tcol1", "Instructions": { @@ -2928,6 +3007,7 @@ "comment": "multiple distinct aggregations on the same column in different positions", "query": "select count(distinct tcol2), tcol1, count(*), sum(distinct tcol2) from user group by tcol1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(distinct tcol2), tcol1, count(*), sum(distinct tcol2) from user group by tcol1", "Instructions": { @@ -2960,6 +3040,7 @@ "comment": "distinct aggregation will 3 table join query", "query": "select u.textcol1, count(distinct u.val2) from user u join user u2 on u.val2 = u2.id join music m on u2.val2 = m.id group by u.textcol1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.textcol1, count(distinct u.val2) from user u join user u2 on u.val2 = u2.id join music m on u2.val2 = m.id group by u.textcol1", "Instructions": { @@ -3070,6 +3151,7 @@ "comment": "group_concat on single shards", "query": "select group_concat(user_id order by name), id from user group by id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select group_concat(user_id order by name), id from user group by id", "Instructions": { @@ -3092,6 +3174,7 @@ "comment": "select count(distinct user_id, name) from unsharded", "query": "select count(distinct user_id, name) from unsharded", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select count(distinct user_id, name) from unsharded", "Instructions": { @@ -3114,6 +3197,7 @@ "comment": "select sum(col) from (select user.col as col, 32 from user join user_extra) t", "query": "select sum(col) from (select user.col as col, 32 from user join user_extra) t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(col) from (select user.col as col, 32 from user join user_extra) t", "Instructions": { @@ -3171,6 +3255,7 @@ "comment": "find aggregation expression and use column offset in filter", "query": "select foo, count(*) from user group by foo having count(*) = 3", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select foo, count(*) from user group by foo having count(*) = 3", "Instructions": { @@ -3209,6 +3294,7 @@ "comment": "find aggregation expression and use column offset in filter times two", "query": "select foo, sum(foo), sum(bar) from user group by foo having sum(foo)+sum(bar) = 42", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select foo, sum(foo), sum(bar) from user group by foo having sum(foo)+sum(bar) = 42", "Instructions": { @@ -3247,6 +3333,7 @@ "comment": "find aggregation expression and use column offset in filter times three", "query": "select foo, sum(foo) as fooSum, sum(bar) as barSum from user group by foo having fooSum+sum(bar) = 42", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select foo, sum(foo) as fooSum, sum(bar) as barSum from user group by foo having fooSum+sum(bar) = 42", "Instructions": { @@ -3285,6 +3372,7 @@ "comment": "having should be able to add new aggregation expressions in having", "query": "select foo from user group by foo having count(*) = 3", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select foo from user group by foo having count(*) = 3", "Instructions": { @@ -3323,6 +3411,7 @@ "comment": "select u.id from user u join user_extra ue on ue.id = u.id group by u.id having count(u.name) = 3", "query": "select u.id from user u join user_extra ue on ue.id = u.id group by u.id having count(u.name) = 3", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.id from user u join user_extra ue on ue.id = u.id group by u.id having count(u.name) = 3", "Instructions": { @@ -3404,6 +3493,7 @@ "comment": "select u.id from user u join user_extra ue on ue.user_id = u.id group by u.id having count(u.name) = 3", "query": "select u.id from user u join user_extra ue on ue.user_id = u.id group by u.id having count(u.name) = 3", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select u.id from user u join user_extra ue on ue.user_id = u.id group by u.id having count(u.name) = 3", "Instructions": { @@ -3427,6 +3517,7 @@ "comment": "only extract the aggregation once, even if used twice", "query": "select u.id from user u join user_extra ue on ue.id = u.id group by u.id having count(*) < 3 and count(*) > 5", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.id from user u join user_extra ue on ue.id = u.id group by u.id having count(*) < 3 and count(*) > 5", "Instructions": { @@ -3508,6 +3599,7 @@ "comment": "group by and ',' joins with condition", "query": "select user.col from user join user_extra on user_extra.col = user.col group by user.id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user_extra.col = user.col group by user.id", "Instructions": { @@ -3568,6 +3660,7 @@ "comment": "aggr and non-aggr without group by (with query does not give useful result out)", "query": "select id, count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, count(*) from user", "Instructions": { @@ -3597,6 +3690,7 @@ "comment": "group by and ',' joins", "query": "select user.id from user, user_extra group by user.id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.id from user, user_extra group by user.id", "Instructions": { @@ -3648,6 +3742,7 @@ "comment": "count on column from LIMIT", "query": "select count(city) from (select phone, id, city from user where id > 12 limit 10) as x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(city) from (select phone, id, city from user where id > 12 limit 10) as x", "Instructions": { @@ -3689,6 +3784,7 @@ "comment": "count(*) on column from LIMIT", "query": "select count(*) from (select phone, id, city from user where id > 12 limit 10) as x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from (select phone, id, city from user where id > 12 limit 10) as x", "Instructions": { @@ -3732,6 +3828,7 @@ "comment": "count non-null columns incoming from outer joins should work well", "query": "select count(col) from (select user_extra.col as col from user left join user_extra on user.id = user_extra.id limit 10) as x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(col) from (select user_extra.col as col from user left join user_extra on user.id = user_extra.id limit 10) as x", "Instructions": { @@ -3802,6 +3899,7 @@ "comment": "grouping on data from derived table", "query": "select val1, count(*) from (select id, val1 from user where val2 < 4 order by val1 limit 2) as x group by val1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select val1, count(*) from (select id, val1 from user where val2 < 4 order by val1 limit 2) as x group by val1", "Instructions": { @@ -3850,6 +3948,7 @@ "comment": "Can't inline derived table when it has HAVING with aggregation function", "query": "select * from (select id from user having count(*) = 1) s", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from (select id from user having count(*) = 1) s", "Instructions": { @@ -3903,6 +4002,7 @@ "comment": "Group By X Order By X", "query": "SELECT user.intcol FROM user GROUP BY user.intcol ORDER BY COUNT(user.intcol)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT user.intcol FROM user GROUP BY user.intcol ORDER BY COUNT(user.intcol)", "Instructions": { @@ -3942,6 +4042,7 @@ "comment": "AggregateAnyValue in non full group by query", "query": "select u.id, u.name, count(m.predef1) from user.user as u join user.user_extra as m on u.id = m.order group by u.id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.id, u.name, count(m.predef1) from user.user as u join user.user_extra as m on u.id = m.order group by u.id", "Instructions": { @@ -4018,6 +4119,7 @@ "comment": "Aggregation on column from inner side in a left join query", "query": "select count (u.id) from user u left join user_extra ue on u.col = ue.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count (u.id) from user u left join user_extra ue on u.col = ue.col", "Instructions": { @@ -4078,6 +4180,7 @@ "comment": "Aggregation on outer side in a left join query", "query": "select count(ue.id) from user u left join user_extra ue on u.col = ue.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(ue.id) from user u left join user_extra ue on u.col = ue.col", "Instructions": { @@ -4138,6 +4241,7 @@ "comment": "Aggregations from derived table used in arithmetic outside derived table", "query": "select A.a, A.b, (A.a / A.b) as d from (select sum(a) as a, sum(b) as b from user) A", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select A.a, A.b, (A.a / A.b) as d from (select sum(a) as a, sum(b) as b from user) A", "Instructions": { @@ -4177,6 +4281,7 @@ "comment": "when pushing predicates into derived tables, make sure to put them in HAVING when they contain aggregations", "query": "select t1.portalId, t1.flowId from (select portalId, flowId, count(*) as count from user_extra where localDate > :v1 group by user_id, flowId order by null) as t1 where count >= :v2", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select t1.portalId, t1.flowId from (select portalId, flowId, count(*) as count from user_extra where localDate > :v1 group by user_id, flowId order by null) as t1 where count >= :v2", "Instructions": { @@ -4199,6 +4304,7 @@ "comment": "aggregation, where and derived tables - we can push extremums", "query": "SELECT foo FROM (SELECT foo, max(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) tt WHERE bazo BETWEEN 100 AND 200", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT foo FROM (SELECT foo, max(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) tt WHERE bazo BETWEEN 100 AND 200", "Instructions": { @@ -4237,6 +4343,7 @@ "comment": "aggregation, where and derived tables - we can't push aggregations that might need a second layer of aggregation", "query": "SELECT foo FROM (SELECT foo, count(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) tt WHERE bazo BETWEEN 100 AND 200", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT foo FROM (SELECT foo, count(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) tt WHERE bazo BETWEEN 100 AND 200", "Instructions": { @@ -4275,6 +4382,7 @@ "comment": "Scatter order by is complex with aggregates in select", "query": "select col, count(*) from user group by col order by col+1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(*) from user group by col order by col+1", "Instructions": { @@ -4314,6 +4422,7 @@ "comment": "scatter aggregate complex order by", "query": "select id from user group by id order by id+1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user group by id order by id+1", "Instructions": { @@ -4338,6 +4447,7 @@ "comment": "select expression does not directly depend on grouping expression", "query": "select a from user group by a+1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a from user group by a+1", "Instructions": { @@ -4370,6 +4480,7 @@ "comment": "inner join with scalar aggregation", "query": "select count(*) from user join music on user.foo = music.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user join music on user.foo = music.bar", "Instructions": { @@ -4430,6 +4541,7 @@ "comment": "left outer join with scalar aggregation", "query": "select count(*) from user left join music on user.foo = music.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join music on user.foo = music.bar", "Instructions": { @@ -4490,6 +4602,7 @@ "comment": "inner join with left grouping", "query": "select count(*) from user left join music on user.foo = music.bar group by user.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join music on user.foo = music.bar group by user.col", "Instructions": { @@ -4554,6 +4667,7 @@ "comment": "inner join with right grouping", "query": "select count(*) from user left join music on user.foo = music.bar group by music.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join music on user.foo = music.bar group by music.col", "Instructions": { @@ -4625,6 +4739,7 @@ "comment": "left outer join with left grouping", "query": "select count(*) from user left join music on user.foo = music.bar group by user.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join music on user.foo = music.bar group by user.col", "Instructions": { @@ -4689,6 +4804,7 @@ "comment": "left outer join with right grouping", "query": "select count(*) from user left join music on user.foo = music.bar group by music.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join music on user.foo = music.bar group by music.col", "Instructions": { @@ -4760,6 +4876,7 @@ "comment": "3 table inner join with scalar aggregation", "query": "select count(*) from user join music on user.foo = music.bar join user_extra on user.foo = user_extra.baz", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user join music on user.foo = music.bar join user_extra on user.foo = user_extra.baz", "Instructions": { @@ -4851,6 +4968,7 @@ "comment": "3 table with mixed join with scalar aggregation", "query": "select count(*) from user left join music on user.foo = music.bar join user_extra on user.foo = user_extra.baz", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join music on user.foo = music.bar join user_extra on user.foo = user_extra.baz", "Instructions": { @@ -4943,6 +5061,7 @@ "comment": "ordering have less column than grouping columns, grouping gets rearranged as order by and missing columns gets added to ordering", "query": "select u.col, u.intcol, count(*) from user u join music group by 1,2 order by 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.col, u.intcol, count(*) from user u join music group by 1,2 order by 2", "Instructions": { @@ -5004,6 +5123,7 @@ "comment": "redundant group by columns are not added", "query": "select col, val, id from user group by col, val, id, id, val, col", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col, val, id from user group by col, val, id, id, val, col", "Instructions": { @@ -5026,6 +5146,7 @@ "comment": "scatter aggregate with ambiguous aliases", "query": "select distinct a, b as a from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct a, b as a from user", "Instructions": { @@ -5058,6 +5179,7 @@ "comment": "scatter aggregate with complex select list (can't build order by)", "query": "select distinct a+1 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct a+1 from user", "Instructions": { @@ -5089,6 +5211,7 @@ "comment": "distinct on top of aggregation", "query": "select distinct count(*) from user group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct count(*) from user group by col", "Instructions": { @@ -5129,6 +5252,7 @@ "comment": "scalar aggregates with min, max, sum distinct and count distinct using collations", "query": "select min(textcol1), max(textcol2), sum(distinct textcol1), count(distinct textcol1) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select min(textcol1), max(textcol2), sum(distinct textcol1), count(distinct textcol1) from user", "Instructions": { @@ -5160,6 +5284,7 @@ "comment": "grouping aggregates with mi, max, sum distinct and count distinct using collations", "query": "select col, min(textcol1), max(textcol2), sum(distinct textcol1), count(distinct textcol1) from user group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, min(textcol1), max(textcol2), sum(distinct textcol1), count(distinct textcol1) from user group by col", "Instructions": { @@ -5192,6 +5317,7 @@ "comment": "using a grouping column multiple times should be OK", "query": "select col, col, count(*) from user group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, col, count(*) from user group by col", "Instructions": { @@ -5223,6 +5349,7 @@ "comment": "multiple count star and a count with 3 table join", "query": "select count(*), count(*), count(u.col) from user u, user u2, user_extra ue", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*), count(*), count(u.col) from user u, user u2, user_extra ue", "Instructions": { @@ -5310,6 +5437,7 @@ "comment": "interleaving grouping, aggregation and join with min, max columns", "query": "select user.col, min(user_extra.foo), user.bar, max(user_extra.bar) from user join user_extra on user.col = user_extra.bar group by user.col, user.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.col, min(user_extra.foo), user.bar, max(user_extra.bar) from user join user_extra on user.col = user_extra.bar group by user.col, user.bar", "Instructions": { @@ -5365,6 +5493,7 @@ "comment": "extremum on input from both sides", "query": "select max(u.foo*ue.bar) from user u join user_extra ue", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select max(u.foo*ue.bar) from user u join user_extra ue", "Instructions": { @@ -5418,6 +5547,7 @@ "comment": "aggregate on input from both sides - TODO optimize more", "query": "select sum(user.foo+user_extra.bar) from user, user_extra", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(user.foo+user_extra.bar) from user, user_extra", "Instructions": { @@ -5470,6 +5600,7 @@ "comment": "grouping column could be coming from multiple sides", "query": "select count(*) from user, user_extra group by user.id+user_extra.id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user, user_extra group by user.id+user_extra.id", "Instructions": { @@ -5541,6 +5672,7 @@ "comment": "Complex aggregate expression on scatter", "query": "select 1+count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1+count(*) from user", "Instructions": { @@ -5578,6 +5710,7 @@ "comment": "combine the output of two aggregations in the final result", "query": "select greatest(sum(user.foo), sum(user_extra.bar)) from user join user_extra on user.col = user_extra.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select greatest(sum(user.foo), sum(user_extra.bar)) from user join user_extra on user.col = user_extra.col", "Instructions": { @@ -5647,6 +5780,7 @@ "comment": "Aggregate detection (group_concat)", "query": "select group_concat(user.a) from user join user_extra", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select group_concat(user.a) from user join user_extra", "Instructions": { @@ -5696,6 +5830,7 @@ "comment": "plan a query with any_value()", "query": "select count(*), any_value(u.name), any_value(ue.title) from user u join user_extra ue on u.bar = ue.foo ", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*), any_value(u.name), any_value(ue.title) from user u join user_extra ue on u.bar = ue.foo ", "Instructions": { @@ -5758,6 +5893,7 @@ "comment": "Rewrite derived expression while pushing order by underneath aggregation", "query": "select d.a from music join (select id, count(*) as a from user) as d on music.user_id = d.id group by 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select d.a from music join (select id, count(*) as a from user) as d on music.user_id = d.id group by 1", "Instructions": { @@ -5835,6 +5971,7 @@ "comment": "group_concat with group by without in select list", "query": "select group_concat(user.id) from user, music where user.id = music.foo group by user.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select group_concat(user.id) from user, music where user.id = music.foo group by user.bar", "Instructions": { @@ -5900,6 +6037,7 @@ "comment": "group_concat aggregation on top of route", "query": "select intcol, group_concat(foo) from user group by intcol", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select intcol, group_concat(foo) from user group by intcol", "Instructions": { @@ -5931,6 +6069,7 @@ "comment": "ordering on top of aggregator without pushing the column down during the horizon phase", "query": "select u.foo, group_concat(u.bar) from user u, music m where u.col = m.col group by u.foo order by u.baz", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.foo, group_concat(u.bar) from user u, music m where u.col = m.col group by u.foo order by u.baz", "Instructions": { @@ -5993,6 +6132,7 @@ "comment": "count distinct and sum distinct on join query pushed down - unique vindex", "query": "select u.col1, count(distinct m.user_id), sum(distinct m.user_id) from user u join music m group by u.col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.col1, count(distinct m.user_id), sum(distinct m.user_id) from user u join music m group by u.col1", "Instructions": { @@ -6045,6 +6185,7 @@ "comment": "count and sum distinct with min distinct on different expressions", "query": "select foo, min(distinct bar), count(distinct baz), sum(distinct baz), max(distinct toto) from user group by foo", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select foo, min(distinct bar), count(distinct baz), sum(distinct baz), max(distinct toto) from user group by foo", "Instructions": { @@ -6077,6 +6218,7 @@ "comment": "aggregation on union", "query": "select sum(col) from (select col from user union all select col from unsharded) t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(col) from (select col from user union all select col from unsharded) t", "Instructions": { @@ -6123,6 +6265,7 @@ "comment": "aggregation on top of derived table with limit", "query": "select count(val2), sum(val2) from (select id, val2 from user where val2 is null limit 2) as x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(val2), sum(val2) from (select id, val2 from user where val2 is null limit 2) as x", "Instructions": { @@ -6164,6 +6307,7 @@ "comment": "last_insert_id on aggregation calculated at the vtgate level", "query": "select last_insert_id(count(*)) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select last_insert_id(count(*)) from user", "Instructions": { @@ -6202,6 +6346,7 @@ "comment": "aggregation on top of aggregation works fine", "query": "select distinct count(*) from user, (select distinct count(*) from user) X", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct count(*) from user, (select distinct count(*) from user) X", "Instructions": { @@ -6283,6 +6428,7 @@ "comment": "Add two counts together", "query": "SELECT (select count(*) from user) + (select count(*) from user_extra)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT (select count(*) from user) + (select count(*) from user_extra)", "Instructions": { @@ -6365,6 +6511,7 @@ "comment": "avg function on scatter query", "query": "select avg(id) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select avg(id) from user", "Instructions": { @@ -6402,6 +6549,7 @@ "comment": "avg function on scatter query deep inside the output expression", "query": "select avg(id)+count(foo)+bar from user group by bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select avg(id)+count(foo)+bar from user group by bar", "Instructions": { @@ -6451,6 +6599,7 @@ "comment": "avg function on scatter query deep inside the output expression", "query": "select avg(id)+count(foo)+bar from user group by bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select avg(id)+count(foo)+bar from user group by bar", "Instructions": { @@ -6500,6 +6649,7 @@ "comment": "two avg aggregations", "query": "select avg(foo), avg(bar) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select avg(foo), avg(bar) from user", "Instructions": { @@ -6538,6 +6688,7 @@ "comment": "avg and count on the same argument", "query": "select avg(foo), count(foo) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select avg(foo), count(foo) from user", "Instructions": { @@ -6576,6 +6727,7 @@ "comment": "GROUP BY inside derived table on the RHS should not be a problem", "query": "SELECT c.column_name FROM user c JOIN (SELECT table_name FROM user WHERE id = 143 GROUP BY 1) AS tables ON tables.table_name = c.table_name", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT c.column_name FROM user c JOIN (SELECT table_name FROM user WHERE id = 143 GROUP BY 1) AS tables ON tables.table_name = c.table_name", "Instructions": { @@ -6624,6 +6776,7 @@ "comment": "Group by aggregated column should not be a problem", "query": "SELECT b.col FROM music AS b JOIN (SELECT MIN(bb.id) AS min_id, MAX(bb.id) AS max_id FROM user AS bb) AS foobars WHERE b.id > foobars.min_id GROUP BY b.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT b.col FROM music AS b JOIN (SELECT MIN(bb.id) AS min_id, MAX(bb.id) AS max_id FROM user AS bb) AS foobars WHERE b.id > foobars.min_id GROUP BY b.col", "Instructions": { @@ -6699,6 +6852,7 @@ "comment": "Group by aliases on both sides of a join", "query": "select count(*), cast(user.foo as datetime) as f1, cast(music.foo as datetime) as f2 from user join music group by f1, f2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*), cast(user.foo as datetime) as f1, cast(music.foo as datetime) as f2 from user join music group by f1, f2", "Instructions": { @@ -6769,6 +6923,7 @@ "comment": "count(*) push down through left hash join", "query": "select count(*) from user left join (select col, bar from user_extra limit 10) ue on user.col = ue.col group by user.foo, ue.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join (select col, bar from user_extra limit 10) ue on user.col = ue.col group by user.foo, ue.bar", "Instructions": { @@ -6874,6 +7029,7 @@ "comment": "sharded subquery inside aggregation function on a dual table", "query": "select max((select min(col) from user where id = 1))", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select max((select min(col) from user where id = 1))", "Instructions": { @@ -6901,6 +7057,7 @@ "comment": "unsharded subquery inside aggregation function on a sharded table", "query": "select max((select min(col) from unsharded)) from user where id = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select max((select min(col) from unsharded)) from user where id = 1", "Instructions": { @@ -6958,6 +7115,7 @@ "comment": "sharded subquery inside aggregation function on a sharded table on different vindex value", "query": "select max((select min(col) from user where id = 1)) from user where id = 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select max((select min(col) from user where id = 1)) from user where id = 2", "Instructions": { @@ -7018,6 +7176,7 @@ "comment": "sharded subquery inside group_concat multi-column aggregation function on a dual table", "query": "select max((select group_concat(col1, col2) from user where id = 1))", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select max((select group_concat(col1, col2) from user where id = 1))", "Instructions": { @@ -7045,6 +7204,7 @@ "comment": "sharded subquery inside group_concat multi-column aggregation function on a sharded table on same vindex value", "query": "select max((select group_concat(col1, col2) from user where id = 1)) from user where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select max((select group_concat(col1, col2) from user where id = 1)) from user where id = 1", "Instructions": { @@ -7071,6 +7231,7 @@ "comment": "sharded subquery inside group_concat multi-column aggregation function on a sharded table", "query": "select max((select group_concat(col1, col2) from user where id = 1)) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select max((select group_concat(col1, col2) from user where id = 1)) from user", "Instructions": { @@ -7127,6 +7288,7 @@ "comment": "sharded correlated subquery inside aggregation function on a sharded table on same vindex", "query": "select max((select max(col2) from user u1 where u1.id = u2.id)) from user u2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select max((select max(col2) from user u1 where u1.id = u2.id)) from user u2", "Instructions": { @@ -7157,6 +7319,7 @@ "comment": "Multi-value aggregates pushed as function without splitting", "query": "select count(a,b) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(a,b) from user", "Instructions": { @@ -7186,6 +7349,7 @@ "comment": "group_concat with multi column - pushed without splitting", "query": "select group_concat(col1, col2) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select group_concat(col1, col2) from user", "Instructions": { @@ -7215,6 +7379,7 @@ "comment": "select count(distinct name, id) from user", "query": "select count(distinct name, id) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(distinct name, id) from user", "Instructions": { @@ -7244,6 +7409,7 @@ "comment": "valid but slightly confusing query should work - col in the order by should not get expanded to the column alias col", "query": "select id, from_unixtime(min(col)) as col from user group by id order by min(col)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, from_unixtime(min(col)) as col from user group by id order by min(col)", "Instructions": { @@ -7268,6 +7434,7 @@ "comment": "col is a column on user, but the HAVING is referring to an alias", "query": "select sum(x) col from user where x > 0 having col = 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(x) col from user where x > 0 having col = 2", "Instructions": { @@ -7313,6 +7480,7 @@ "comment": "Valid to run since we can push down the aggregate function because of the grouping", "query": "select id from user group by id having udf_aggr(foo) > 1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user group by id having udf_aggr(foo) > 1", "Instructions": { @@ -7335,6 +7503,7 @@ "comment": "Valid to run since we can push down the aggregate function because it's unsharded", "query": "select bar, udf_aggr(foo) from unsharded group by bar", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select bar, udf_aggr(foo) from unsharded group by bar", "Instructions": { @@ -7357,6 +7526,7 @@ "comment": "Valid to run since we can push down the aggregate function because the where clause using the sharding key", "query": "select bar, udf_aggr(foo) from user where id = 17 group by bar", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select bar, udf_aggr(foo) from user where id = 17 group by bar", "Instructions": { @@ -7383,6 +7553,7 @@ "comment": "Aggregation over a ORDER BY/LIMIT inside a derived table", "query": "SELECT COUNT(*) FROM (SELECT 1 AS one FROM `user` WHERE `user`.`is_not_deleted` = true ORDER BY id DESC LIMIT 25 OFFSET 0) subquery_for_count", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT COUNT(*) FROM (SELECT 1 AS one FROM `user` WHERE `user`.`is_not_deleted` = true ORDER BY id DESC LIMIT 25 OFFSET 0) subquery_for_count", "Instructions": { @@ -7428,6 +7599,7 @@ "comment": "should be able to push down aggregation", "query": "select sum(user.type) from user join user_extra on user.team_id = user_extra.id group by user_extra.id order by user_extra.id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(user.type) from user join user_extra on user.team_id = user_extra.id group by user_extra.id order by user_extra.id", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/alterVschema_cases.json b/go/vt/vtgate/planbuilder/testdata/alterVschema_cases.json index f8c57c5ea07..a4b47abaaa5 100644 --- a/go/vt/vtgate/planbuilder/testdata/alterVschema_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/alterVschema_cases.json @@ -3,6 +3,7 @@ "comment": "Create vindex", "query": "alter vschema create vindex hash_vdx using hash", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema create vindex hash_vdx using hash", "Instructions": { @@ -22,6 +23,7 @@ "comment": "Create vindex with qualifier", "query": "alter vschema create vindex user.hash_vdx using hash", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema create vindex user.hash_vdx using hash", "Instructions": { @@ -41,6 +43,7 @@ "comment": "Drop vindex", "query": "alter vschema drop vindex hash_vdx", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema drop vindex hash_vdx", "Instructions": { @@ -60,6 +63,7 @@ "comment": "Add table", "query": "alter vschema add table a", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema add table a", "Instructions": { @@ -79,6 +83,7 @@ "comment": "Add sequence", "query": "alter vschema add sequence a_seq", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema add sequence a_seq", "Instructions": { @@ -98,6 +103,7 @@ "comment": "Add auto_increment with qualifier", "query": "alter vschema on user.a add auto_increment id using a_seq", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema on user.a add auto_increment id using a_seq", "Instructions": { @@ -117,6 +123,7 @@ "comment": "Drop table", "query": "alter vschema drop table a", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema drop table a", "Instructions": { @@ -136,6 +143,7 @@ "comment": "Add Vindex", "query": "alter vschema on a add vindex hash (id)", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema on a add vindex hash (id)", "Instructions": { @@ -155,6 +163,7 @@ "comment": "Drop Vindex", "query": "alter vschema on a drop vindex hash", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "alter vschema on a drop vindex hash", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/bypass_keyrange_cases.json b/go/vt/vtgate/planbuilder/testdata/bypass_keyrange_cases.json index e1ff7de97a0..f5881e0cc26 100644 --- a/go/vt/vtgate/planbuilder/testdata/bypass_keyrange_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/bypass_keyrange_cases.json @@ -3,6 +3,7 @@ "comment": "select bypass", "query": "select count(*), col from unsharded", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select count(*), col from unsharded", "Instructions": { @@ -20,6 +21,7 @@ "comment": "update bypass", "query": "update user set val = 1 where id = 18446744073709551616 and id = 1", "plan": { + "Type": "Unknown", "QueryType": "UPDATE", "Original": "update user set val = 1 where id = 18446744073709551616 and id = 1", "Instructions": { @@ -38,6 +40,7 @@ "comment": "update bypass autocommit", "query": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user set val = 1 where id = 18446744073709551616 and id = 1", "plan": { + "Type": "Unknown", "QueryType": "UPDATE", "Original": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user set val = 1 where id = 18446744073709551616 and id = 1", "Instructions": { @@ -57,6 +60,7 @@ "comment": "delete bypass", "query": "DELETE FROM USER WHERE ID = 42", "plan": { + "Type": "Unknown", "QueryType": "DELETE", "Original": "DELETE FROM USER WHERE ID = 42", "Instructions": { @@ -80,6 +84,7 @@ "comment": "bypass query for into outfile s3", "query": "select count(*), col from unsharded into outfile S3 'x.txt'", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select count(*), col from unsharded into outfile S3 'x.txt'", "Instructions": { @@ -97,6 +102,7 @@ "comment": "Select outfile", "query": "select * from user into outfile S3 'x.txt'", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select * from user into outfile S3 'x.txt'", "Instructions": { @@ -114,6 +120,7 @@ "comment": "load data from s3 'x.txt' into table x", "query": "load data from s3 'x.txt' into table x", "plan": { + "Type": "Unknown", "QueryType": "OTHER", "Original": "load data from s3 'x.txt' into table x", "Instructions": { @@ -133,6 +140,7 @@ "comment": "load data from s3 'x.txt'", "query": "load data from s3 'x.txt'", "plan": { + "Type": "Unknown", "QueryType": "OTHER", "Original": "load data from s3 'x.txt'", "Instructions": { @@ -152,6 +160,7 @@ "comment": "create table", "query": "create /* test */ table t1(id bigint, primary key(id)) /* comments */", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create /* test */ table t1(id bigint, primary key(id)) /* comments */", "Instructions": { @@ -169,6 +178,7 @@ "comment": "remove the matching keyspace from shard targeted query", "query": "select count(*), col from `main`.unsharded join vt_main.t1 where exists (select 1 from main.t2 join information_schema.tables where table_name = 't3')", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select count(*), col from `main`.unsharded join vt_main.t1 where exists (select 1 from main.t2 join information_schema.tables where table_name = 't3')", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/bypass_shard_cases.json b/go/vt/vtgate/planbuilder/testdata/bypass_shard_cases.json index 80d4dbbd08b..40f554e687d 100644 --- a/go/vt/vtgate/planbuilder/testdata/bypass_shard_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/bypass_shard_cases.json @@ -3,6 +3,7 @@ "comment": "select bypass", "query": "select count(*), col from unsharded", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select count(*), col from unsharded", "Instructions": { @@ -20,6 +21,7 @@ "comment": "update bypass", "query": "update user set val = 1 where id = 18446744073709551616 and id = 1", "plan": { + "Type": "Unknown", "QueryType": "UPDATE", "Original": "update user set val = 1 where id = 18446744073709551616 and id = 1", "Instructions": { @@ -38,6 +40,7 @@ "comment": "delete bypass", "query": "DELETE FROM USER WHERE ID = 42", "plan": { + "Type": "Unknown", "QueryType": "DELETE", "Original": "DELETE FROM USER WHERE ID = 42", "Instructions": { @@ -56,6 +59,7 @@ "comment": "insert bypass", "query": "INSERT INTO USER (ID, NAME) VALUES (42, 'ms X')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO USER (ID, NAME) VALUES (42, 'ms X')", "Instructions": { @@ -74,6 +78,7 @@ "comment": "insert bypass with sequence: sequences ignored", "query": "insert into user(nonid) values (2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(nonid) values (2)", "Instructions": { @@ -92,6 +97,7 @@ "comment": "bypass query for into outfile s3", "query": "select count(*), col from unsharded into outfile S3 'x.txt'", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select count(*), col from unsharded into outfile S3 'x.txt'", "Instructions": { @@ -109,6 +115,7 @@ "comment": "Select outfile", "query": "select * from user into outfile S3 'x.txt'", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select * from user into outfile S3 'x.txt'", "Instructions": { @@ -126,6 +133,7 @@ "comment": "load data from s3 'x.txt' into table x", "query": "load data from s3 'x.txt' into table x", "plan": { + "Type": "Unknown", "QueryType": "OTHER", "Original": "load data from s3 'x.txt' into table x", "Instructions": { @@ -145,6 +153,7 @@ "comment": "load data from s3 'x.txt'", "query": "load data from s3 'x.txt'", "plan": { + "Type": "Unknown", "QueryType": "OTHER", "Original": "load data from s3 'x.txt'", "Instructions": { @@ -164,6 +173,7 @@ "comment": "create table", "query": "create /* test */ table t1(id bigint, primary key(id)) /* comments */", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create /* test */ table t1(id bigint, primary key(id)) /* comments */", "Instructions": { @@ -181,6 +191,7 @@ "comment": "select bypass with query timeout hint", "query": "select /*vt+ QUERY_TIMEOUT_MS=100 */ count(*), col from user", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select /*vt+ QUERY_TIMEOUT_MS=100 */ count(*), col from user", "Instructions": { @@ -199,6 +210,7 @@ "comment": "update bypass with query timeout hint", "query": "update /*vt+ QUERY_TIMEOUT_MS=100 */ user set val = 1 where id = 1", "plan": { + "Type": "Unknown", "QueryType": "UPDATE", "Original": "update /*vt+ QUERY_TIMEOUT_MS=100 */ user set val = 1 where id = 1", "Instructions": { @@ -218,6 +230,7 @@ "comment": "delete bypass with query timeout hint", "query": "DELETE /*vt+ QUERY_TIMEOUT_MS=100 */ FROM USER WHERE ID = 42", "plan": { + "Type": "Unknown", "QueryType": "DELETE", "Original": "DELETE /*vt+ QUERY_TIMEOUT_MS=100 */ FROM USER WHERE ID = 42", "Instructions": { @@ -237,6 +250,7 @@ "comment": "insert bypass with query timeout hint", "query": "INSERT /*vt+ QUERY_TIMEOUT_MS=100 */ INTO USER (ID, NAME) VALUES (42, 'ms X')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT /*vt+ QUERY_TIMEOUT_MS=100 */ INTO USER (ID, NAME) VALUES (42, 'ms X')", "Instructions": { @@ -256,6 +270,7 @@ "comment": "remove the matching keyspace from shard targeted query", "query": "select count(*), col from `main`.unsharded join vt_main.t1 where exists (select 1 from main.t2 join information_schema.tables where table_name = 't3')", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select count(*), col from `main`.unsharded join vt_main.t1 where exists (select 1 from main.t2 join information_schema.tables where table_name = 't3')", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/call_cases.json b/go/vt/vtgate/planbuilder/testdata/call_cases.json index f8786414389..93f5f26d0ba 100644 --- a/go/vt/vtgate/planbuilder/testdata/call_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/call_cases.json @@ -3,6 +3,7 @@ "comment": "simple call proc on current keyspace", "query": "call proc()", "plan": { + "Type": "Unknown", "QueryType": "CALL_PROC", "Original": "call proc()", "Instructions": { @@ -20,6 +21,7 @@ "comment": "call qualified keyspace", "query": "call main.proc()", "plan": { + "Type": "Unknown", "QueryType": "CALL_PROC", "Original": "call main.proc()", "Instructions": { @@ -42,6 +44,7 @@ "comment": "CALL with expressions and parameters", "query": "call proc(1, 'foo', @var)", "plan": { + "Type": "Unknown", "QueryType": "CALL_PROC", "Original": "call proc(1, 'foo', @var)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/cte_cases.json b/go/vt/vtgate/planbuilder/testdata/cte_cases.json index 12f92f5a9f4..03fadea4f2b 100644 --- a/go/vt/vtgate/planbuilder/testdata/cte_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/cte_cases.json @@ -3,6 +3,7 @@ "comment": "with t as (select count(*) as a from user) select a from t", "query": "with t as (select count(*) as a from user) select a from t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with t as (select count(*) as a from user) select a from t", "Instructions": { @@ -32,6 +33,7 @@ "comment": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select count(*) from a", "query": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select count(*) from a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select count(*) from a", "Instructions": { @@ -62,6 +64,7 @@ "comment": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select col from a", "query": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select col from a", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select col from a", "Instructions": { @@ -85,6 +88,7 @@ "comment": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select col, count(*) from a group by col", "query": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select col, count(*) from a group by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with a as (select user.col, user_extra.extra from user join user_extra on user.id = user_extra.user_id order by user_extra.extra) select col, count(*) from a group by col", "Instructions": { @@ -117,6 +121,7 @@ "comment": "with t as (select user.col as col, 32 from user join user_extra) select sum(col) from t", "query": "with t as (select user.col as col, 32 from user join user_extra) select sum(col) from t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with t as (select user.col as col, 32 from user join user_extra) select sum(col) from t", "Instructions": { @@ -174,6 +179,7 @@ "comment": "with x as (select phone, id, city from user where id > 12 limit 10) select count(city) from x", "query": "with x as (select phone, id, city from user where id > 12 limit 10) select count(city) from x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with x as (select phone, id, city from user where id > 12 limit 10) select count(city) from x", "Instructions": { @@ -215,6 +221,7 @@ "comment": "with x as (select phone, id, city from user where id > 12 limit 10) select count(*) from x", "query": "with x as (select phone, id, city from user where id > 12 limit 10) select count(*) from x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with x as (select phone, id, city from user where id > 12 limit 10) select count(*) from x", "Instructions": { @@ -258,6 +265,7 @@ "comment": "with x as (select user_extra.col as col from user left join user_extra on user.id = user_extra.id limit 10) select count(col) from x", "query": "with x as (select user_extra.col as col from user left join user_extra on user.id = user_extra.id limit 10) select count(col) from x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with x as (select user_extra.col as col from user left join user_extra on user.id = user_extra.id limit 10) select count(col) from x", "Instructions": { @@ -328,6 +336,7 @@ "comment": "with x as (select id, val1 from user where val2 < 4 order by val1 limit 2) select val1, count(*) from x group by val1", "query": "with x as (select id, val1 from user where val2 < 4 order by val1 limit 2) select val1, count(*) from x group by val1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with x as (select id, val1 from user where val2 < 4 order by val1 limit 2) select val1, count(*) from x group by val1", "Instructions": { @@ -376,6 +385,7 @@ "comment": "with s as (select id from user having count(*) = 1) select * from s", "query": "with s as (select id from user having count(*) = 1) select * from s", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with s as (select id from user having count(*) = 1) select * from s", "Instructions": { @@ -429,6 +439,7 @@ "comment": "with A as (select sum(a) as a, sum(b) as b from user) select A.a, A.b, (A.a / A.b) as d from A", "query": "with A as (select sum(a) as a, sum(b) as b from user) select A.a, A.b, (A.a / A.b) as d from A", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with A as (select sum(a) as a, sum(b) as b from user) select A.a, A.b, (A.a / A.b) as d from A", "Instructions": { @@ -468,6 +479,7 @@ "comment": "with t1 as (select portalId, flowId, count(*) as count from user_extra where localDate > :v1 group by user_id, flowId order by null) select t1.portalId, t1.flowId from t1 where count >= :v2", "query": "with t1 as (select portalId, flowId, count(*) as count from user_extra where localDate > :v1 group by user_id, flowId order by null) select t1.portalId, t1.flowId from t1 where count >= :v2", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with t1 as (select portalId, flowId, count(*) as count from user_extra where localDate > :v1 group by user_id, flowId order by null) select t1.portalId, t1.flowId from t1 where count >= :v2", "Instructions": { @@ -490,6 +502,7 @@ "comment": "with tt as (SELECT foo, max(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) SELECT foo FROM tt WHERE bazo BETWEEN 100 AND 200", "query": "with tt as (SELECT foo, max(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) SELECT foo FROM tt WHERE bazo BETWEEN 100 AND 200", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with tt as (SELECT foo, max(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) SELECT foo FROM tt WHERE bazo BETWEEN 100 AND 200", "Instructions": { @@ -528,6 +541,7 @@ "comment": "with tt as (SELECT foo, count(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) SELECT foo FROM tt WHERE bazo BETWEEN 100 AND 200", "query": "with tt as (SELECT foo, count(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) SELECT foo FROM tt WHERE bazo BETWEEN 100 AND 200", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with tt as (SELECT foo, count(baz) as bazo FROM (SELECT foo, baz FROM user) f GROUP BY foo) SELECT foo FROM tt WHERE bazo BETWEEN 100 AND 200", "Instructions": { @@ -566,6 +580,7 @@ "comment": "with d as (select id, count(*) as a from user) select d.a from music join d on music.user_id = d.id group by 1", "query": "with d as (select id, count(*) as a from user) select d.a from music join d on music.user_id = d.id group by 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with d as (select id, count(*) as a from user) select d.a from music join d on music.user_id = d.id group by 1", "Instructions": { @@ -643,6 +658,7 @@ "comment": "with t as (select col from user union all select col from unsharded) select sum(col) from t", "query": "with t as (select col from user union all select col from unsharded) select sum(col) from t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with t as (select col from user union all select col from unsharded) select sum(col) from t", "Instructions": { @@ -689,6 +705,7 @@ "comment": "with x as (select id, val2 from user where val2 is null limit 2) select count(val2), sum(val2) from x", "query": "with x as (select id, val2 from user where val2 is null limit 2) select count(val2), sum(val2) from x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with x as (select id, val2 from user where val2 is null limit 2) select count(val2), sum(val2) from x", "Instructions": { @@ -730,6 +747,7 @@ "comment": "with X as (select distinct count(*) from user) select distinct count(*) from X", "query": "with X as (select distinct count(*) from user) select distinct count(*) from X", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with X as (select distinct count(*) from user) select distinct count(*) from X", "Instructions": { @@ -774,6 +792,7 @@ "comment": "with t as (select id, col from user where id = 5) select id from t", "query": "with t as (select id, col from user where id = 5) select id from t", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with t as (select id, col from user where id = 5) select id from t", "Instructions": { @@ -800,6 +819,7 @@ "comment": "with t as (select id from user where id = 5) select t.id from t join user_extra on t.id = user_extra.user_id", "query": "with t as (select id from user where id = 5) select t.id from t join user_extra on t.id = user_extra.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with t as (select id from user where id = 5) select t.id from t join user_extra on t.id = user_extra.user_id", "Instructions": { @@ -827,6 +847,7 @@ "comment": "with t as (select user.id from user where user.id = 5) select t.id from t join user_extra on t.id = user_extra.user_id", "query": "with t as (select user.id from user where user.id = 5) select t.id from t join user_extra on t.id = user_extra.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with t as (select user.id from user where user.id = 5) select t.id from t join user_extra on t.id = user_extra.user_id", "Instructions": { @@ -854,6 +875,7 @@ "comment": "with t as (select id from user where id = 5) select t.id from user_extra join t on t.id = user_extra.user_id", "query": "with t as (select id from user where id = 5) select t.id from user_extra join t on t.id = user_extra.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with t as (select id from user where id = 5) select t.id from user_extra join t on t.id = user_extra.user_id", "Instructions": { @@ -881,6 +903,7 @@ "comment": "with t as (select id from user where id = 5) select t.id from t join user_extra on t.id = user_extra.col", "query": "with t as (select id from user where id = 5) select t.id from t join user_extra on t.id = user_extra.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select id from user where id = 5) select t.id from t join user_extra on t.id = user_extra.col", "Instructions": { @@ -930,6 +953,7 @@ "comment": "with t as (select id, col from route1 where id = 5) select id from t", "query": "with t as (select id, col from route1 where id = 5) select id from t", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with t as (select id, col from route1 where id = 5) select id from t", "Instructions": { @@ -956,6 +980,7 @@ "comment": "with t as (select id, col from route1) select id from t where id = 5", "query": "with t as (select id, col from route1) select id from t where id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with t as (select id, col from route1) select id from t where id = 5", "Instructions": { @@ -987,6 +1012,7 @@ "comment": "with t as (select id, textcol1 as baz from route1), s as (select id, textcol1+textcol1 as baz from user) select t.id from t join s ON t.id = s.id WHERE t.baz = '3' AND s.baz = '3'", "query": "with t as (select id, textcol1 as baz from route1), s as (select id, textcol1+textcol1 as baz from user) select t.id from t join s ON t.id = s.id WHERE t.baz = '3' AND s.baz = '3'", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with t as (select id, textcol1 as baz from route1), s as (select id, textcol1+textcol1 as baz from user) select t.id from t join s ON t.id = s.id WHERE t.baz = '3' AND s.baz = '3'", "Instructions": { @@ -1009,6 +1035,7 @@ "comment": "with u as (select colA+colB as foo from user), t as (select foo+4 as bar from u) select bar from t where bar = 5", "query": "with u as (select colA+colB as foo from user), t as (select foo+4 as bar from u) select bar from t where bar = 5", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with u as (select colA+colB as foo from user), t as (select foo+4 as bar from u) select bar from t where bar = 5", "Instructions": { @@ -1031,6 +1058,7 @@ "comment": "with u as (select col from user where id = 5), e as (select col from user_extra where user_id = 5) select u.col, e.col from u join e", "query": "with u as (select col from user where id = 5), e as (select col from user_extra where user_id = 5) select u.col, e.col from u join e", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with u as (select col from user where id = 5), e as (select col from user_extra where user_id = 5) select u.col, e.col from u join e", "Instructions": { @@ -1058,6 +1086,7 @@ "comment": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from t join unsharded on unsharded.col1 = t.col1 and unsharded.id = t.id", "query": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from t join unsharded on unsharded.col1 = t.col1 and unsharded.id = t.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from t join unsharded on unsharded.col1 = t.col1 and unsharded.id = t.id", "Instructions": { @@ -1124,6 +1153,7 @@ "comment": "with t as (select user.id, user.col1 from user join user_extra on user_extra.col = user.col) select t.id from t", "query": "with t as (select user.id, user.col1 from user join user_extra on user_extra.col = user.col) select t.id from t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select user.id, user.col1 from user join user_extra on user_extra.col = user.col) select t.id from t", "Instructions": { @@ -1169,6 +1199,7 @@ "comment": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from unsharded_a ua join t", "query": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from unsharded_a ua join t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from unsharded_a ua join t", "Instructions": { @@ -1231,6 +1262,7 @@ "comment": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from unsharded_a ua join t on t.id = ua.id", "query": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from unsharded_a ua join t on t.id = ua.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select user.id, user.col1 from user join user_extra) select t.col1 from unsharded_a ua join t on t.id = ua.id", "Instructions": { @@ -1300,6 +1332,7 @@ "comment": "with t as (select user.id from user join user_extra) select id, t.id from t", "query": "with t as (select user.id from user join user_extra) select id, t.id from t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select user.id from user join user_extra) select id, t.id from t", "Instructions": { @@ -1342,6 +1375,7 @@ "comment": "with t as (select count(*) as a from user) select a as k from t", "query": "with t as (select count(*) as a from user) select a as k from t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with t as (select count(*) as a from user) select a as k from t", "Instructions": { @@ -1379,6 +1413,7 @@ "comment": "with u as (select * from unsharded) select u.* from u", "query": "with u as (select * from unsharded) select u.* from u", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with u as (select * from unsharded) select u.* from u", "Instructions": { @@ -1401,6 +1436,7 @@ "comment": "with t as (select user.id, user.col from user join user_extra) select id from t where id=5", "query": "with t as (select user.id, user.col from user join user_extra) select id from t where id=5", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select user.id, user.col from user join user_extra) select id from t where id=5", "Instructions": { @@ -1447,6 +1483,7 @@ "comment": "with t as (select user.id, user.col from user join user_extra) select id+1 from t", "query": "with t as (select user.id, user.col from user join user_extra) select id+1 from t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select user.id, user.col from user join user_extra) select id+1 from t", "Instructions": { @@ -1489,6 +1526,7 @@ "comment": "with u(a,n) as (select id as b, name from user) select u.a from u where u.n = 1", "query": "with u(a,n) as (select id as b, name from user) select u.a from u where u.n = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with u(a,n) as (select id as b, name from user) select u.a from u where u.n = 1", "Instructions": { @@ -1540,6 +1578,7 @@ "comment": "with u(a, n) as (select id as b, name from user where b = 1) select u.a from u where u.n = 1", "query": "with u(a, n) as (select id as b, name from user where b = 1) select u.a from u where u.n = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with u(a, n) as (select id as b, name from user where b = 1) select u.a from u where u.n = 1", "Instructions": { @@ -1591,6 +1630,7 @@ "comment": "with t(i) as (select user.id from user join user_extra) select i+1 from t", "query": "with t(i) as (select user.id from user join user_extra) select i+1 from t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t(i) as (select user.id from user join user_extra) select i+1 from t", "Instructions": { @@ -1633,6 +1673,7 @@ "comment": "with t as (select `user`.col1 from `user` join unsharded) select 0 from t join unsharded on unsharded.col1 = t.col1 and unsharded.a = t.col1", "query": "with t as (select `user`.col1 from `user` join unsharded) select 0 from t join unsharded on unsharded.col1 = t.col1 and unsharded.a = t.col1", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "with t as (select `user`.col1 from `user` join unsharded) select 0 from t join unsharded on unsharded.col1 = t.col1 and unsharded.a = t.col1", "Instructions": { @@ -1697,6 +1738,7 @@ "comment": "with x(id2) as (select id from user) select id2 from x", "query": "with x(id2) as (select id from user) select id2 from x", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with x(id2) as (select id from user) select id2 from x", "Instructions": { @@ -1719,6 +1761,7 @@ "comment": "with u as (select col from unsharded join unsharded_b) select col from u join unsharded_a ua limit 1", "query": "with u as (select col from unsharded join unsharded_b) select col from u join unsharded_a ua limit 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with u as (select col from unsharded join unsharded_b) select col from u join unsharded_a ua limit 1", "Instructions": { @@ -1743,6 +1786,7 @@ "comment": "with u as (select user.col from user join user_extra) select u.col from u join user_extra ue limit 1", "query": "with u as (select user.col from user join user_extra) select u.col from u join user_extra ue limit 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with u as (select user.col from user join user_extra) select u.col from u join user_extra ue limit 1", "Instructions": { @@ -1816,6 +1860,7 @@ "comment": "simple WITH query", "query": "with x as (select * from user) select * from x", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with x as (select * from user) select * from x", "Instructions": { @@ -1838,6 +1883,7 @@ "comment": "UNION with WITH clause", "query": "with x as (select id, foo from user) select * from x union select * from x", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with x as (select id, foo from user) select * from x union select * from x", "Instructions": { @@ -1870,6 +1916,7 @@ "comment": "recursive WITH against an unsharded database", "query": "WITH RECURSIVE cte (n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM cte WHERE n < 5 ) SELECT cte.n FROM unsharded join cte on unsharded.id = cte.n ", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "WITH RECURSIVE cte (n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM cte WHERE n < 5 ) SELECT cte.n FROM unsharded join cte on unsharded.id = cte.n ", "Instructions": { @@ -1893,6 +1940,7 @@ "comment": "WITH two common expressions against an unsharded datbase and a SELECT UNION against those expressions", "query": "WITH `count_a` AS (SELECT COUNT(`id`) AS `num` FROM `unsharded_a`), `count_b` AS (SELECT COUNT(`id`) AS `num` FROM `unsharded_b`) SELECT 'count_a' AS `tab`, `num` FROM `count_a` UNION SELECT 'count_b' AS `tab`, `num` FROM `count_b`", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "WITH `count_a` AS (SELECT COUNT(`id`) AS `num` FROM `unsharded_a`), `count_b` AS (SELECT COUNT(`id`) AS `num` FROM `unsharded_b`) SELECT 'count_a' AS `tab`, `num` FROM `count_a` UNION SELECT 'count_b' AS `tab`, `num` FROM `count_b`", "Instructions": { @@ -1916,6 +1964,7 @@ "comment": "WITH two common expressions against a sharded datbase and a SELECT UNION against those expressions", "query": "WITH `count_a` AS (SELECT COUNT(`user_id`) AS `num` FROM `user_metadata`), `count_b` AS (SELECT COUNT(`user_id`) AS `num` FROM `user_extra`) SELECT 'count_a' AS `tab`, `num` FROM `count_a` UNION SELECT 'count_b' AS `tab`, `num` FROM `count_b`", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "WITH `count_a` AS (SELECT COUNT(`user_id`) AS `num` FROM `user_metadata`), `count_b` AS (SELECT COUNT(`user_id`) AS `num` FROM `user_extra`) SELECT 'count_a' AS `tab`, `num` FROM `count_a` UNION SELECT 'count_b' AS `tab`, `num` FROM `count_b`", "Instructions": { @@ -1996,6 +2045,7 @@ "comment": "CTE expression using unions and complex aggregation with literal", "query": "WITH `open` AS (SELECT COUNT(*) as `num` FROM (SELECT `user`.`id` FROM `user` WHERE `user`.`textcol1` = 'open' AND `user`.`intcol` = 1 LIMIT 1000) `t` LIMIT 1 ), `closed` AS (SELECT COUNT(*) as `num` FROM ( SELECT `user`.`id` FROM `user` WHERE `user`.`textcol1` = 'closed' AND `user`.`intcol` = 1 LIMIT 1000) `t` LIMIT 1 ), `all` AS (SELECT LEAST(1000, SUM(`num`)) AS `num` FROM ( SELECT `num` FROM `open` UNION ALL SELECT `num` FROM `closed` ) `t` LIMIT 1 )SELECT 'all' AS `tab`, `num`FROM `all`", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "WITH `open` AS (SELECT COUNT(*) as `num` FROM (SELECT `user`.`id` FROM `user` WHERE `user`.`textcol1` = 'open' AND `user`.`intcol` = 1 LIMIT 1000) `t` LIMIT 1 ), `closed` AS (SELECT COUNT(*) as `num` FROM ( SELECT `user`.`id` FROM `user` WHERE `user`.`textcol1` = 'closed' AND `user`.`intcol` = 1 LIMIT 1000) `t` LIMIT 1 ), `all` AS (SELECT LEAST(1000, SUM(`num`)) AS `num` FROM ( SELECT `num` FROM `open` UNION ALL SELECT `num` FROM `closed` ) `t` LIMIT 1 )SELECT 'all' AS `tab`, `num`FROM `all`", "Instructions": { @@ -2127,6 +2177,7 @@ "comment": "Recursive CTE that cannot be merged", "query": "with recursive cte as (select name, id from user where manager_id is null union all select e.name, e.id from user e inner join cte on e.manager_id = cte.id) select name from cte", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with recursive cte as (select name, id from user where manager_id is null union all select e.name, e.id from user e inner join cte on e.manager_id = cte.id) select name from cte", "Instructions": { @@ -2178,6 +2229,7 @@ "comment": "Recursive CTE that cannot be merged 2", "query": "with recursive cte as (select name, id from user where manager_id is null union all select e.name, e.id from cte join user e on e.manager_id = cte.id) select name from cte", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "with recursive cte as (select name, id from user where manager_id is null union all select e.name, e.id from cte join user e on e.manager_id = cte.id) select name from cte", "Instructions": { @@ -2229,6 +2281,7 @@ "comment": "Merge into a single dual route", "query": "WITH RECURSIVE cte AS (SELECT 1 as n UNION ALL SELECT n + 1 FROM cte WHERE n < 5) SELECT n FROM cte", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "WITH RECURSIVE cte AS (SELECT 1 as n UNION ALL SELECT n + 1 FROM cte WHERE n < 5) SELECT n FROM cte", "Instructions": { @@ -2251,6 +2304,7 @@ "comment": "Recursive CTE with star projection", "query": "WITH RECURSIVE cte (n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM cte WHERE n < 5) SELECT * FROM cte", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "WITH RECURSIVE cte (n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM cte WHERE n < 5) SELECT * FROM cte", "Instructions": { @@ -2273,6 +2327,7 @@ "comment": "Recursive CTE calculations on the term side - merged", "query": "WITH RECURSIVE emp_cte AS (SELECT id, 1 AS level FROM user WHERE manager_id IS NULL and id = 6 UNION ALL SELECT e.id, cte.level + 1 FROM user e JOIN emp_cte cte ON e.manager_id = cte.id and e.id = 6) SELECT * FROM emp_cte", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "WITH RECURSIVE emp_cte AS (SELECT id, 1 AS level FROM user WHERE manager_id IS NULL and id = 6 UNION ALL SELECT e.id, cte.level + 1 FROM user e JOIN emp_cte cte ON e.manager_id = cte.id and e.id = 6) SELECT * FROM emp_cte", "Instructions": { @@ -2300,6 +2355,7 @@ "comment": "Recursive CTE calculations on the term side - unmerged", "query": "WITH RECURSIVE emp_cte AS (SELECT id, 1 AS level FROM user WHERE manager_id IS NULL UNION ALL SELECT e.id, cte.level + 1 FROM user e JOIN emp_cte cte ON e.manager_id = cte.id) SELECT * FROM emp_cte", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "WITH RECURSIVE emp_cte AS (SELECT id, 1 AS level FROM user WHERE manager_id IS NULL UNION ALL SELECT e.id, cte.level + 1 FROM user e JOIN emp_cte cte ON e.manager_id = cte.id) SELECT * FROM emp_cte", "Instructions": { @@ -2343,6 +2399,7 @@ "comment": "Outer join with recursive CTE", "query": "WITH RECURSIVE literal_cte AS (SELECT 1 AS id, 100 AS value, 1 AS manager_id UNION ALL SELECT id + 1, value * 2, id FROM literal_cte WHERE id < 5) SELECT l.id, l.value, l.manager_id, e.name AS employee_name FROM literal_cte l LEFT JOIN user e ON l.id = e.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "WITH RECURSIVE literal_cte AS (SELECT 1 AS id, 100 AS value, 1 AS manager_id UNION ALL SELECT id + 1, value * 2, id FROM literal_cte WHERE id < 5) SELECT l.id, l.value, l.manager_id, e.name AS employee_name FROM literal_cte l LEFT JOIN user e ON l.id = e.id", "Instructions": { @@ -2392,6 +2449,7 @@ "comment": "Aggregation on the output of a recursive CTE", "query": "WITH RECURSIVE emp_cte AS (SELECT id, name, manager_id FROM user WHERE manager_id IS NULL UNION ALL SELECT e.id, e.name, e.manager_id FROM user e INNER JOIN emp_cte cte ON e.manager_id = cte.id) SELECT manager_id, COUNT(*) AS employee_count FROM emp_cte GROUP BY manager_id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "WITH RECURSIVE emp_cte AS (SELECT id, name, manager_id FROM user WHERE manager_id IS NULL UNION ALL SELECT e.id, e.name, e.manager_id FROM user e INNER JOIN emp_cte cte ON e.manager_id = cte.id) SELECT manager_id, COUNT(*) AS employee_count FROM emp_cte GROUP BY manager_id", "Instructions": { @@ -2460,6 +2518,7 @@ "comment": "Query that can be merged, dual on the RHS of the UNION", "query": "with recursive cte as (select id from user where id = 72 union all select id+1 from cte where id < 100) select * from cte", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "with recursive cte as (select id from user where id = 72 union all select id+1 from cte where id < 100) select * from cte", "Instructions": { @@ -2487,6 +2546,7 @@ "comment": "Merge CTE with reference tables", "query": "with recursive cte as (select ue.id, ue.foo from user u join user_extra ue on u.id = ue.user_id union all select sr.id, sr.foo from cte join main.source_of_ref sr on sr.foo = cte.foo join main.rerouted_ref rr on rr.bar = sr.bar) select * from cte", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with recursive cte as (select ue.id, ue.foo from user u join user_extra ue on u.id = ue.user_id union all select sr.id, sr.foo from cte join main.source_of_ref sr on sr.foo = cte.foo join main.rerouted_ref rr on rr.bar = sr.bar) select * from cte", "Instructions": { @@ -2512,6 +2572,7 @@ "comment": "Merge CTE with reference tables 2", "query": "with recursive cte as (select sr.id, sr.foo from main.source_of_ref sr join main.rerouted_ref rr on rr.bar = sr.bar union all select ue.id, ue.foo from cte join user_extra ue on cte.foo = ue.foo join user u on ue.user_id = u.id) select * from cte", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "with recursive cte as (select sr.id, sr.foo from main.source_of_ref sr join main.rerouted_ref rr on rr.bar = sr.bar union all select ue.id, ue.foo from cte join user_extra ue on cte.foo = ue.foo join user u on ue.user_id = u.id) select * from cte", "Instructions": { @@ -2538,6 +2599,7 @@ "comment": "Merged recursive CTE with DISTINCT", "query": "WITH RECURSIVE hierarchy AS (SELECT id, name, manager_id FROM user UNION ALL SELECT id, name, manager_id FROM user UNION DISTINCT SELECT id*2, name, manager_id from hierarchy WHERE id < 10 ) SELECT * FROM hierarchy", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "WITH RECURSIVE hierarchy AS (SELECT id, name, manager_id FROM user UNION ALL SELECT id, name, manager_id FROM user UNION DISTINCT SELECT id*2, name, manager_id from hierarchy WHERE id < 10 ) SELECT * FROM hierarchy", "Instructions": { @@ -2561,6 +2623,7 @@ "comment": "Query that caused planner to stack overflow", "query": "SELECT * FROM (SELECT 1 UNION ALL SELECT 2) AS dt(a) WHERE EXISTS(WITH RECURSIVE qn AS (SELECT a * 0 AS b UNION ALL SELECT b + 1 FROM qn WHERE b = 0) SELECT * FROM qn WHERE b = a)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM (SELECT 1 UNION ALL SELECT 2) AS dt(a) WHERE EXISTS(WITH RECURSIVE qn AS (SELECT a * 0 AS b UNION ALL SELECT b + 1 FROM qn WHERE b = 0) SELECT * FROM qn WHERE b = a)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/ddl_cases.json b/go/vt/vtgate/planbuilder/testdata/ddl_cases.json index 1ae7578854b..f03ca303fdd 100644 --- a/go/vt/vtgate/planbuilder/testdata/ddl_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/ddl_cases.json @@ -3,6 +3,7 @@ "comment": "simple create table", "query": "create table t1(id bigint, primary key(id))", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create table t1(id bigint, primary key(id))", "Instructions": { @@ -22,6 +23,7 @@ "comment": "simple create table with keyspace", "query": "create table user.t1(id bigint, primary key(id))", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create table user.t1(id bigint, primary key(id))", "Instructions": { @@ -41,6 +43,7 @@ "comment": "DDL", "query": "create table a(id int)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create table a(id int)", "Instructions": { @@ -65,6 +68,7 @@ "comment": "Alter table", "query": "alter table a ADD id int", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "alter table a ADD id int", "Instructions": { @@ -84,6 +88,7 @@ "comment": "Alter table with qualifier", "query": "alter table user.user ADD id int", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "alter table user.user ADD id int", "Instructions": { @@ -103,6 +108,7 @@ "comment": "Alter table with qualifier and table not in vschema", "query": "alter table user.a ADD id int", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "alter table user.a ADD id int", "Instructions": { @@ -127,6 +133,7 @@ "comment": "create db foo", "query": "create database foo", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "create database foo", "Instructions": { @@ -147,6 +154,7 @@ "comment": "create db if not exists main", "query": "create database if not exists main", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "create database if not exists main", "Instructions": { @@ -173,6 +181,7 @@ "comment": "drop db main", "query": "drop database main", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "drop database main", "Instructions": { @@ -188,6 +197,7 @@ "comment": "drop db if exists main", "query": "drop database if exists main", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "drop database if exists main", "Instructions": { @@ -203,6 +213,7 @@ "comment": "drop db if exists foo", "query": "drop schema if exists foo", "plan": { + "Type": "Complex", "QueryType": "DDL", "Original": "drop schema if exists foo", "Instructions": { @@ -214,6 +225,7 @@ "comment": "DDL with qualifier", "query": "create index a on user.user(id)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create index a on user.user(id)", "Instructions": { @@ -233,6 +245,7 @@ "comment": "DDL with qualifier for a table not in vschema of an unsharded keyspace", "query": "create index a on main.unknown(id)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create index a on main.unknown(id)", "Instructions": { @@ -252,6 +265,7 @@ "comment": "create view with subquery in unsharded keyspace", "query": "create view view_a as select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) a", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view view_a as select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) a", "Instructions": { @@ -271,6 +285,7 @@ "comment": "create view with subquery in unsharded keyspace with IN clause", "query": "create view view_a as select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view view_a as select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", "Instructions": { @@ -290,6 +305,7 @@ "comment": "create view with subquery in unsharded keyspace with UNION clause", "query": "create view view_a as (select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view view_a as (select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "Instructions": { @@ -309,6 +325,7 @@ "comment": "create view with subquery in unsharded keyspace with multiple UNION clauses", "query": "create view view_a as select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view view_a as select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "Instructions": { @@ -328,6 +345,7 @@ "comment": "create view with subquery in unsharded keyspace with UNION clauses in subqueries", "query": "create view view_a as (select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view view_a as (select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "Instructions": { @@ -347,6 +365,7 @@ "comment": "Alter View", "query": "alter view user.user_extra as select * from user.user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "alter view user.user_extra as select * from user.user", "Instructions": { @@ -366,6 +385,7 @@ "comment": "Create View with authoritative column", "query": "create view user.tmp_view as select * from user.authoritative", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.tmp_view as select * from user.authoritative", "Instructions": { @@ -385,6 +405,7 @@ "comment": "drop table without qualifier", "query": "drop table unsharded_a", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "drop table unsharded_a", "Instructions": { @@ -404,6 +425,7 @@ "comment": "Drop view", "query": "drop view main.a", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "drop view main.a", "Instructions": { @@ -423,6 +445,7 @@ "comment": "Truncate table with qualifier", "query": "truncate user.user_extra", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "truncate user.user_extra", "Instructions": { @@ -442,6 +465,7 @@ "comment": "Rename table", "query": "rename table a to main.b", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "rename table a to main.b", "Instructions": { @@ -462,6 +486,7 @@ "comment": "CREATE temp TABLE", "query": "create temporary table a(id int)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create temporary table a(id int)", "Instructions": { @@ -482,6 +507,7 @@ "comment": "DROP temp TABLE", "query": "drop temporary table a", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "drop temporary table a", "Instructions": { @@ -502,6 +528,7 @@ "comment": "create table with function as a default value", "query": "create table function_default (x varchar(25) DEFAULT (TRIM(' check ')))", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create table function_default (x varchar(25) DEFAULT (TRIM(' check ')))", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/ddl_cases_no_default_keyspace.json b/go/vt/vtgate/planbuilder/testdata/ddl_cases_no_default_keyspace.json index b62988b2e38..cf6ce834014 100644 --- a/go/vt/vtgate/planbuilder/testdata/ddl_cases_no_default_keyspace.json +++ b/go/vt/vtgate/planbuilder/testdata/ddl_cases_no_default_keyspace.json @@ -3,6 +3,7 @@ "comment": "Create View with qualifier", "query": "create view user.a as select* from user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.a as select* from user", "Instructions": { @@ -22,6 +23,7 @@ "comment": "create view with qualifier in select as well", "query": "create view user.a as select* from user.user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.a as select* from user.user", "Instructions": { @@ -41,6 +43,7 @@ "comment": "create view with No column referenced", "query": "create view user.view_a as select 1 from user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select 1 from user", "Instructions": { @@ -60,6 +63,7 @@ "comment": "create view with '*' expression for simple route", "query": "create view user.view_a as select user.* from user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.* from user", "Instructions": { @@ -79,6 +83,7 @@ "comment": "create view with unqualified '*' expression for simple route", "query": "create view user.view_a as select * from user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from user", "Instructions": { @@ -98,6 +103,7 @@ "comment": "create view with fully qualified '*' expression for simple route", "query": "create view user.view_a as select user.user.* from user.user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.user.* from user.user", "Instructions": { @@ -117,6 +123,7 @@ "comment": "create view with select * from authoritative table", "query": "create view user.view_a as select * from authoritative", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from authoritative", "Instructions": { @@ -136,6 +143,7 @@ "comment": "create view with select * from join of authoritative tables", "query": "create view user.view_a as select * from authoritative a join authoritative b on a.user_id=b.user_id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from authoritative a join authoritative b on a.user_id=b.user_id", "Instructions": { @@ -155,6 +163,7 @@ "comment": "create view with select * from qualified authoritative table", "query": "create view user.view_a as select a.* from authoritative a", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select a.* from authoritative a", "Instructions": { @@ -174,6 +183,7 @@ "comment": "create view with select * from intermixing of authoritative table with non-authoritative results in no expansion", "query": "create view user.view_a as select * from authoritative join user on authoritative.user_id=user.id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from authoritative join user on authoritative.user_id=user.id", "Instructions": { @@ -193,6 +203,7 @@ "comment": "create view with select authoritative.* with intermixing still expands", "query": "create view user.view_a as select user.id, a.*, user.col1 from authoritative a join user on a.user_id=user.id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.id, a.*, user.col1 from authoritative a join user on a.user_id=user.id", "Instructions": { @@ -212,6 +223,7 @@ "comment": "create view with auto-resolve anonymous columns for simple route", "query": "create view user.view_a as select user.col from user join user_extra on user.id = user_extra.user_id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.col from user join user_extra on user.id = user_extra.user_id", "Instructions": { @@ -231,6 +243,7 @@ "comment": "create view with join that can be solved in each shard separately", "query": "create view user.view_a as select user.id from user join user_extra on user.id = user_extra.user_id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.id from user join user_extra on user.id = user_extra.user_id", "Instructions": { @@ -250,6 +263,7 @@ "comment": "create view with last_insert_id for unsharded route", "query": "create view main.view_a as select last_insert_id() as x from main.unsharded", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view main.view_a as select last_insert_id() as x from main.unsharded", "Instructions": { @@ -269,6 +283,7 @@ "comment": "create view with select from pinned table", "query": "create view user.view_a as select * from pin_test", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from pin_test", "Instructions": { @@ -288,6 +303,7 @@ "comment": "create view with Expression with single-route reference", "query": "create view user.view_a as select user.col, user_extra.id + user_extra.col from user join user_extra on user.id = user_extra.user_id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.col, user_extra.id + user_extra.col from user join user_extra on user.id = user_extra.user_id", "Instructions": { @@ -307,6 +323,7 @@ "comment": "create view with Comments", "query": "create view user.view_a as select /* comment */ user.col from user join user_extra on user.id = user_extra.user_id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select /* comment */ user.col from user join user_extra on user.id = user_extra.user_id", "Instructions": { @@ -326,6 +343,7 @@ "comment": "create view with for update", "query": "create view user.view_a as select user.col from user join user_extra on user.id = user_extra.user_id for update", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.col from user join user_extra on user.id = user_extra.user_id for update", "Instructions": { @@ -345,6 +363,7 @@ "comment": "create view with Case preservation", "query": "create view user.view_a as select user.Col, user_extra.Id from user join user_extra on user.id = user_extra.user_id", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user.Col, user_extra.Id from user join user_extra on user.id = user_extra.user_id", "Instructions": { @@ -369,6 +388,7 @@ "comment": "create view with Hex number is not treated as a simple value", "query": "create view user.view_a as select * from user where id = 0x04", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from user where id = 0x04", "Instructions": { @@ -388,6 +408,7 @@ "comment": "create view with limit works if it can be dropped", "query": "create view user.view_a as select * from user where name ='abc' AND (id = 4) limit 5", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from user where name ='abc' AND (id = 4) limit 5", "Instructions": { @@ -407,6 +428,7 @@ "comment": "create view with Multiple parenthesized expressions", "query": "create view user.view_a as select * from user where (id = 4) AND (name ='abc') limit 5", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from user where (id = 4) AND (name ='abc') limit 5", "Instructions": { @@ -426,6 +448,7 @@ "comment": "create view with Multiple parenthesized expressions", "query": "create view user.view_a as select * from user where (id = 4 and name ='abc') limit 5", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from user where (id = 4 and name ='abc') limit 5", "Instructions": { @@ -445,6 +468,7 @@ "comment": "create view with Column Aliasing with Table.Column", "query": "create view user.view_a as select user0_.col as col0_ from user user0_ where id = 1 order by user0_.col", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user0_.col as col0_ from user user0_ where id = 1 order by user0_.col", "Instructions": { @@ -464,6 +488,7 @@ "comment": "create view with Column Aliasing with Column", "query": "create view user.view_a as select user0_.col as col0_ from user user0_ where id = 1 order by col0_ desc", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select user0_.col as col0_ from user user0_ where id = 1 order by col0_ desc", "Instructions": { @@ -483,6 +508,7 @@ "comment": "create view with Booleans and parenthesis", "query": "create view user.view_a as select * from user where (id = 1) AND name = true", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from user where (id = 1) AND name = true", "Instructions": { @@ -502,6 +528,7 @@ "comment": "create view with union with the same target shard", "query": "create view user.view_a as select * from music where user_id = 1 union select * from user where id = 1", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select * from music where user_id = 1 union select * from user where id = 1", "Instructions": { @@ -521,6 +548,7 @@ "comment": "create view with testing SingleRow Projection", "query": "create view user.view_a as select 42 from user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select 42 from user", "Instructions": { @@ -540,6 +568,7 @@ "comment": "create view with sql_calc_found_rows without limit", "query": "create view user.view_a as select sql_calc_found_rows * from music where user_id = 1", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_a as select sql_calc_found_rows * from music where user_id = 1", "Instructions": { @@ -559,6 +588,7 @@ "comment": "DDL", "query": "create index a on user(id)", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create index a on user(id)", "Instructions": { @@ -578,6 +608,7 @@ "comment": "Alter table with qualifier", "query": "alter table user ADD id int", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "alter table user ADD id int", "Instructions": { @@ -597,6 +628,7 @@ "comment": "Alter View", "query": "alter view user_extra as select* from user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "alter view user_extra as select* from user", "Instructions": { @@ -621,6 +653,7 @@ "comment": "drop table with qualifier in one", "query": "drop table user.user, user_extra", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "drop table user.user, user_extra", "Instructions": { @@ -646,6 +679,7 @@ "comment": "drop view with 1 view without qualifier", "query": "drop view user.user, user_extra", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "drop view user.user, user_extra", "Instructions": { @@ -671,6 +705,7 @@ "comment": "Truncate table without qualifier", "query": "truncate user_extra", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "truncate user_extra", "Instructions": { @@ -690,6 +725,7 @@ "comment": "Rename table", "query": "rename table user_extra to b", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "rename table user_extra to b", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/dml_cases.json b/go/vt/vtgate/planbuilder/testdata/dml_cases.json index 95cb14e38f5..cf9fc84f52d 100644 --- a/go/vt/vtgate/planbuilder/testdata/dml_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/dml_cases.json @@ -15,6 +15,7 @@ "comment": "explicit keyspace reference", "query": "update main.m1 set val = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update main.m1 set val = 1", "Instructions": { @@ -38,6 +39,7 @@ "comment": "update unsharded", "query": "update unsharded set val = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded set val = 1", "Instructions": { @@ -61,6 +63,7 @@ "comment": "subqueries in unsharded update", "query": "update unsharded set col = (select col from unsharded limit 1)", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded set col = (select col from unsharded limit 1)", "Instructions": { @@ -84,6 +87,7 @@ "comment": "unsharded union in subquery of unsharded update", "query": "update unsharded set col = (select id from unsharded union select id from unsharded)", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded set col = (select id from unsharded union select id from unsharded)", "Instructions": { @@ -107,6 +111,7 @@ "comment": "unsharded join in subquery of unsharded update", "query": "update unsharded set col = (select id from unsharded a join unsharded b on a.id = b.id)", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded set col = (select id from unsharded a join unsharded b on a.id = b.id)", "Instructions": { @@ -130,6 +135,7 @@ "comment": "update with join subquery", "query": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col < 1000", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id set col1 = 'asdf' where keepers.id is null and foo.col is not null and foo.col < 1000", "Instructions": { @@ -153,6 +159,7 @@ "comment": "routing rules: updated of a routed table", "query": "update route1 set a=1 where id=1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update route1 set a=1 where id=1", "Instructions": { @@ -180,6 +187,7 @@ "comment": "update: routing rules for subquery.", "query": "update unsharded_a set a=(select a from route2)", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded_a set a=(select a from route2)", "Instructions": { @@ -204,6 +212,7 @@ "comment": "delete unsharded", "query": "delete from unsharded", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from unsharded", "Instructions": { @@ -227,6 +236,7 @@ "comment": "delete from sequence", "query": "DELETE FROM seq", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "DELETE FROM seq", "Instructions": { @@ -250,6 +260,7 @@ "comment": "delete from reference table in unsharded keyspace", "query": "DELETE FROM unsharded_ref", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "DELETE FROM unsharded_ref", "Instructions": { @@ -273,6 +284,7 @@ "comment": "update by primary keyspace id", "query": "update user set val = 1 where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set val = 1 where id = 1", "Instructions": { @@ -300,6 +312,7 @@ "comment": "update by primary keyspace id with alias", "query": "update user as user_alias set val = 1 where user_alias.id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user as user_alias set val = 1 where user_alias.id = 1", "Instructions": { @@ -327,6 +340,7 @@ "comment": "update by primary keyspace id with parenthesized expression", "query": "update user set val = 1 where (id = 1)", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set val = 1 where (id = 1)", "Instructions": { @@ -354,6 +368,7 @@ "comment": "update by primary keyspace id with multi-part where clause with parens", "query": "update user set val = 1 where (name = 'foo' and id = 1)", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set val = 1 where (name = 'foo' and id = 1)", "Instructions": { @@ -381,6 +396,7 @@ "comment": "update by primary keyspace id, changing one vindex column", "query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user_metadata set email = 'juan@vitess.io' where user_id = 1", "Instructions": { @@ -420,6 +436,7 @@ "comment": "update by primary keyspace id, changing multiple vindex columns", "query": "update user_metadata set email = 'juan@vitess.io', address = '155 5th street' where user_id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user_metadata set email = 'juan@vitess.io', address = '155 5th street' where user_id = 1", "Instructions": { @@ -454,6 +471,7 @@ "comment": "update by primary keyspace id, changing one vindex column, using order by and limit", "query": "update user_metadata set email = 'juan@vitess.io' where user_id = 1 order by user_id asc limit 10", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user_metadata set email = 'juan@vitess.io' where user_id = 1 order by user_id asc limit 10", "Instructions": { @@ -487,6 +505,7 @@ "comment": "update changes non owned vindex column", "query": "update music_extra set music_id = 1 where user_id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update music_extra set music_id = 1 where user_id = 1", "Instructions": { @@ -520,6 +539,7 @@ "comment": "update by primary keyspace id, stray where clause", "query": "update user set val = 1 where id = id2 and id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set val = 1 where id = id2 and id = 1", "Instructions": { @@ -547,6 +567,7 @@ "comment": "update by primary keyspace id, stray where clause with conversion error", "query": "update user set val = 1 where id = 18446744073709551616 and id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set val = 1 where id = 18446744073709551616 and id = 1", "Instructions": { @@ -574,6 +595,7 @@ "comment": "delete from by primary keyspace id", "query": "delete from user where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from user where id = 1", "Instructions": { @@ -604,6 +626,7 @@ "comment": "multi-table delete with comma join", "query": "delete a from unsharded_a a, unsharded_b b where a.id = b.id and b.val = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete a from unsharded_a a, unsharded_b b where a.id = b.id and b.val = 1", "Instructions": { @@ -628,6 +651,7 @@ "comment": "multi-table delete with ansi join", "query": "delete a from unsharded_a a join unsharded_b b on a.id = b.id where b.val = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete a from unsharded_a a join unsharded_b b on a.id = b.id where b.val = 1", "Instructions": { @@ -652,6 +676,7 @@ "comment": "delete with join from subquery", "query": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col < 1000", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete foo from unsharded as foo left join (select id from unsharded where col is not null order by col desc limit 10) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col < 1000", "Instructions": { @@ -675,6 +700,7 @@ "comment": "routing rules: deleted from a routed table", "query": "delete from route1 where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from route1 where id = 1", "Instructions": { @@ -705,6 +731,7 @@ "comment": "delete: routing rules for subquery", "query": "delete from unsharded_a where a=(select a from route2)", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from unsharded_a where a=(select a from route2)", "Instructions": { @@ -729,6 +756,7 @@ "comment": "update by lookup", "query": "update music set val = 1 where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update music set val = 1 where id = 1", "Instructions": { @@ -756,6 +784,7 @@ "comment": "update multi-table ansi join", "query": "update unsharded_a a join unsharded_b b on a.id = b.id set a.val = 'foo' where b.val = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded_a a join unsharded_b b on a.id = b.id set a.val = 'foo' where b.val = 1", "Instructions": { @@ -780,6 +809,7 @@ "comment": "update multi-table comma join", "query": "update unsharded_a a, unsharded_b b set a.val = 'foo' where a.id = b.id and b.val = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded_a a, unsharded_b b set a.val = 'foo' where a.id = b.id and b.val = 1", "Instructions": { @@ -804,6 +834,7 @@ "comment": "delete from by lookup", "query": "delete from music where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from music where id = 1", "Instructions": { @@ -834,6 +865,7 @@ "comment": "delete from, no owned vindexes", "query": "delete from music_extra where user_id = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from music_extra where user_id = 1", "Instructions": { @@ -861,6 +893,7 @@ "comment": "simple insert, no values", "query": "insert into unsharded values()", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded values()", "Instructions": { @@ -884,6 +917,7 @@ "comment": "simple insert unsharded", "query": "insert into unsharded values(1, 2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded values(1, 2)", "Instructions": { @@ -907,6 +941,7 @@ "comment": "simple upsert unsharded", "query": "insert into unsharded values(1, 2) on duplicate key update x = 3", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded values(1, 2) on duplicate key update x = 3", "Instructions": { @@ -930,6 +965,7 @@ "comment": "unsharded insert, no col list with auto-inc and authoritative column list", "query": "insert into unsharded_authoritative values(1,1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded_authoritative values(1,1)", "Instructions": { @@ -954,6 +990,7 @@ "comment": "sharded upsert with sharding key set to vindex column", "query": "insert into music(user_id, id) values(1, 2) on duplicate key update user_id = values(user_id)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into music(user_id, id) values(1, 2) on duplicate key update user_id = values(user_id)", "Instructions": { @@ -982,6 +1019,7 @@ "comment": "sharded bulk upsert with sharding key set to vindex column", "query": "insert into music(user_id, id) values (1, 2), (3,4) on duplicate key update user_id = values(user_id)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into music(user_id, id) values (1, 2), (3,4) on duplicate key update user_id = values(user_id)", "Instructions": { @@ -1010,6 +1048,7 @@ "comment": "insert unsharded with select", "query": "insert into unsharded select id from unsharded_auto", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded select id from unsharded_auto", "Instructions": { @@ -1034,6 +1073,7 @@ "comment": "insert unsharded with select with join", "query": "insert into unsharded select id from unsharded join unsharded_auto", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded select id from unsharded join unsharded_auto", "Instructions": { @@ -1058,6 +1098,7 @@ "comment": "insert unsharded, invalid value for auto-inc", "query": "insert into unsharded_auto(id, val) values(18446744073709551616, 'aa')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded_auto(id, val) values(18446744073709551616, 'aa')", "Instructions": { @@ -1082,6 +1123,7 @@ "comment": "insert unsharded, column present", "query": "insert into unsharded_auto(id, val) values(1, 'aa')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded_auto(id, val) values(1, 'aa')", "Instructions": { @@ -1106,6 +1148,7 @@ "comment": "insert unsharded, column absent", "query": "insert into unsharded_auto(val) values('aa')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded_auto(val) values('aa')", "Instructions": { @@ -1130,6 +1173,7 @@ "comment": "insert unsharded, column absent", "query": "insert into unsharded_auto(val) values(false)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded_auto(val) values(false)", "Instructions": { @@ -1154,6 +1198,7 @@ "comment": "insert unsharded, multi-val", "query": "insert into unsharded_auto(id, val) values(1, 'aa'), (null, 'bb')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded_auto(id, val) values(1, 'aa'), (null, 'bb')", "Instructions": { @@ -1178,6 +1223,7 @@ "comment": "unsharded insert subquery in insert value", "query": "insert into unsharded values((select 1 from dual), 1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded values((select 1 from dual), 1)", "Instructions": { @@ -1201,6 +1247,7 @@ "comment": "sharded insert subquery in insert value", "query": "insert into user(id, val) values((select 1), 1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(id, val) values((select 1), 1)", "Instructions": { @@ -1230,6 +1277,7 @@ "comment": "insert into a routed table", "query": "insert into route1(id) values (1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into route1(id) values (1)", "Instructions": { @@ -1265,6 +1313,7 @@ "comment": "insert no column list for sharded authoritative table", "query": "insert into authoritative values(1, 2, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into authoritative values(1, 2, 3)", "Instructions": { @@ -1291,6 +1340,7 @@ "comment": "insert sharded, no values", "query": "insert into user values()", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user values()", "Instructions": { @@ -1320,6 +1370,7 @@ "comment": "insert with one vindex", "query": "insert into user(id) values (1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(id) values (1)", "Instructions": { @@ -1349,6 +1400,7 @@ "comment": "insert ignore sharded", "query": "insert ignore into user(id) values (1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert ignore into user(id) values (1)", "Instructions": { @@ -1379,6 +1431,7 @@ "comment": "insert on duplicate key", "query": "insert into user(id) values(1) on duplicate key update col = 2", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(id) values(1) on duplicate key update col = 2", "Instructions": { @@ -1409,6 +1462,7 @@ "comment": "insert with one vindex and bind var", "query": "insert into user(id) values (:aa)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(id) values (:aa)", "Instructions": { @@ -1438,6 +1492,7 @@ "comment": "insert with non vindex", "query": "insert into user(nonid) values (2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(nonid) values (2)", "Instructions": { @@ -1467,6 +1522,7 @@ "comment": "insert with default seq", "query": "insert into user(id, nonid) values (default, 2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(id, nonid) values (default, 2)", "Instructions": { @@ -1496,6 +1552,7 @@ "comment": "insert with non vindex bool value", "query": "insert into user(nonid) values (true)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(nonid) values (true)", "Instructions": { @@ -1525,6 +1582,7 @@ "comment": "insert with all vindexes supplied", "query": "insert into user(nonid, name, id) values (2, 'foo', 1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(nonid, name, id) values (2, 'foo', 1)", "Instructions": { @@ -1554,6 +1612,7 @@ "comment": "insert for non-vindex autoinc", "query": "insert into user_extra(nonid) values (2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user_extra(nonid) values (2)", "Instructions": { @@ -1581,6 +1640,7 @@ "comment": "insert for non-compliant names", "query": "insert into `weird``name`(`a``b*c`, `b*c`) values(1, 2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into `weird``name`(`a``b*c`, `b*c`) values(1, 2)", "Instructions": { @@ -1607,6 +1667,7 @@ "comment": "unsharded insert from union", "query": "insert into unsharded select 1 from dual union select 1 from dual", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded select 1 from dual union select 1 from dual", "Instructions": { @@ -1631,6 +1692,7 @@ "comment": "insert for non-vindex autoinc, invalid value", "query": "insert into user_extra(nonid, extra_id) values (2, 18446744073709551616)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user_extra(nonid, extra_id) values (2, 18446744073709551616)", "Instructions": { @@ -1658,6 +1720,7 @@ "comment": "insert invalid index value", "query": "insert into music_extra(music_id, user_id) values(1, 18446744073709551616)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into music_extra(music_id, user_id) values(1, 18446744073709551616)", "Instructions": { @@ -1697,6 +1760,7 @@ "comment": "insert with multiple rows", "query": "insert into user(id) values (1), (2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user(id) values (1), (2)", "Instructions": { @@ -1726,6 +1790,7 @@ "comment": "insert with query timeout", "query": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into user(id) values (1), (2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into user(id) values (1), (2)", "Instructions": { @@ -1756,6 +1821,7 @@ "comment": "insert with multiple rows - multi-shard autocommit", "query": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id) values (1), (2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ into user(id) values (1), (2)", "Instructions": { @@ -1792,6 +1858,7 @@ "comment": "simple replace unsharded", "query": "replace into unsharded values(1, 2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "replace into unsharded values(1, 2)", "Instructions": { @@ -1815,6 +1882,7 @@ "comment": "replace unsharded with select", "query": "replace into unsharded select id from unsharded_auto", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "replace into unsharded select id from unsharded_auto", "Instructions": { @@ -1839,6 +1907,7 @@ "comment": "replace unsharded, invalid value for auto-inc", "query": "replace into unsharded_auto(id, val) values(18446744073709551616, 'aa')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "replace into unsharded_auto(id, val) values(18446744073709551616, 'aa')", "Instructions": { @@ -1863,6 +1932,7 @@ "comment": "replace unsharded, column present", "query": "replace into unsharded_auto(id, val) values(1, 'aa')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "replace into unsharded_auto(id, val) values(1, 'aa')", "Instructions": { @@ -1887,6 +1957,7 @@ "comment": "replace unsharded, column absent", "query": "replace into unsharded_auto(val) values('aa')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "replace into unsharded_auto(val) values('aa')", "Instructions": { @@ -1911,6 +1982,7 @@ "comment": "replace unsharded, multi-val", "query": "replace into unsharded_auto(id, val) values(1, 'aa'), (null, 'bb')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "replace into unsharded_auto(id, val) values(1, 'aa'), (null, 'bb')", "Instructions": { @@ -1941,6 +2013,7 @@ "comment": "insert a row in a multi column vindex table", "query": "insert multicolvin (column_a, column_b, column_c, kid) VALUES (1,2,3,4)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert multicolvin (column_a, column_b, column_c, kid) VALUES (1,2,3,4)", "Instructions": { @@ -1969,6 +2042,7 @@ "comment": "insert for overlapped vindex columns", "query": "insert overlap_vindex (kid, column_a, column_b) VALUES (1,2,3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert overlap_vindex (kid, column_a, column_b) VALUES (1,2,3)", "Instructions": { @@ -1996,6 +2070,7 @@ "comment": "insert multiple rows in a multi column vindex table", "query": "insert multicolvin (column_a, column_b, column_c, kid) VALUES (1,2,3,4), (5,6,7,8)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert multicolvin (column_a, column_b, column_c, kid) VALUES (1,2,3,4), (5,6,7,8)", "Instructions": { @@ -2024,6 +2099,7 @@ "comment": "delete row in a multi column vindex table", "query": "delete from multicolvin where kid=1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from multicolvin where kid=1", "Instructions": { @@ -2054,6 +2130,7 @@ "comment": "update columns of multi column vindex", "query": "update multicolvin set column_b = 1, column_c = 2 where kid = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update multicolvin set column_b = 1, column_c = 2 where kid = 1", "Instructions": { @@ -2087,6 +2164,7 @@ "comment": "update multiple vindexes, with multi column vindex", "query": "update multicolvin set column_a = 0, column_b = 1, column_c = 2 where kid = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update multicolvin set column_a = 0, column_b = 1, column_c = 2 where kid = 1", "Instructions": { @@ -2121,6 +2199,7 @@ "comment": "update with no primary vindex on where clause (scatter update)", "query": "update user_extra set val = 1", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user_extra set val = 1", "Instructions": { @@ -2144,6 +2223,7 @@ "comment": "update with target destination", "query": "update `user[-]`.user_extra set val = 1", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update `user[-]`.user_extra set val = 1", "Instructions": { @@ -2167,6 +2247,7 @@ "comment": "update with no primary vindex on where clause (scatter update) - multi shard autocommit", "query": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user_extra set val = 1", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ user_extra set val = 1", "Instructions": { @@ -2191,6 +2272,7 @@ "comment": "update with no primary vindex on where clause (scatter update) - query timeout", "query": "update /*vt+ QUERY_TIMEOUT_MS=1 */ user_extra set val = 1", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update /*vt+ QUERY_TIMEOUT_MS=1 */ user_extra set val = 1", "Instructions": { @@ -2215,6 +2297,7 @@ "comment": "update with non-comparison expr", "query": "update user_extra set val = 1 where id between 1 and 2", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user_extra set val = 1 where id between 1 and 2", "Instructions": { @@ -2238,6 +2321,7 @@ "comment": "update with primary id through IN clause", "query": "update user_extra set val = 1 where user_id in (1, 2)", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update user_extra set val = 1 where user_id in (1, 2)", "Instructions": { @@ -2265,6 +2349,7 @@ "comment": "update with non-unique key", "query": "update user_extra set val = 1 where name = 'foo'", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user_extra set val = 1 where name = 'foo'", "Instructions": { @@ -2288,6 +2373,7 @@ "comment": "update by lookup with IN clause", "query": "update user_extra set val = 1 where id in (1, 2)", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user_extra set val = 1 where id in (1, 2)", "Instructions": { @@ -2311,6 +2397,7 @@ "comment": "update with where clause with parens", "query": "update user_extra set val = 1 where (name = 'foo' or id = 1)", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user_extra set val = 1 where (name = 'foo' or id = 1)", "Instructions": { @@ -2334,6 +2421,7 @@ "comment": "update with last_insert_id in SET", "query": "update user_extra set col = last_insert_id(123)", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user_extra set col = last_insert_id(123)", "Instructions": { @@ -2357,6 +2445,7 @@ "comment": "delete with last_insert_id in where", "query": "delete from user_extra where col = last_insert_id(123)", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user_extra where col = last_insert_id(123)", "Instructions": { @@ -2380,6 +2469,7 @@ "comment": "delete from with no where clause", "query": "delete from user_extra", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user_extra", "Instructions": { @@ -2403,6 +2493,7 @@ "comment": "delete with target destination", "query": "delete from `user[-]`.user_extra", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from `user[-]`.user_extra", "Instructions": { @@ -2426,6 +2517,7 @@ "comment": "delete with non-comparison expr", "query": "delete from user_extra where user_id between 1 and 2", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user_extra where user_id between 1 and 2", "Instructions": { @@ -2449,6 +2541,7 @@ "comment": "delete from with no index match", "query": "delete from user_extra where name = 'jose'", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user_extra where name = 'jose'", "Instructions": { @@ -2472,6 +2565,7 @@ "comment": "delete from with no index match - multi shard autocommit", "query": "delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete /*vt+ MULTI_SHARD_AUTOCOMMIT=1 */ from user_extra where name = 'jose'", "Instructions": { @@ -2496,6 +2590,7 @@ "comment": "delete from with no index match - query timeout", "query": "delete /*vt+ QUERY_TIMEOUT_MS=1 */ from user_extra where name = 'jose'", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete /*vt+ QUERY_TIMEOUT_MS=1 */ from user_extra where name = 'jose'", "Instructions": { @@ -2520,6 +2615,7 @@ "comment": "delete from with primary id in through IN clause", "query": "delete from user_extra where user_id in (1, 2)", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from user_extra where user_id in (1, 2)", "Instructions": { @@ -2547,6 +2643,7 @@ "comment": "unsharded update where inner query references outer query", "query": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded set col = (select id from unsharded_a where id = unsharded.col) where col = (select id from unsharded_b)", "Instructions": { @@ -2572,6 +2669,7 @@ "comment": "unsharded delete where inner query references outer query", "query": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from unsharded where col = (select id from unsharded_a where id = unsharded.col)", "Instructions": { @@ -2596,6 +2694,7 @@ "comment": "update vindex value to null", "query": "update user set name = null where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set name = null where id = 1", "Instructions": { @@ -2629,6 +2728,7 @@ "comment": "insert using last_insert_id", "query": "insert into unsharded values(last_insert_id(), 2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded values(last_insert_id(), 2)", "Instructions": { @@ -2652,6 +2752,7 @@ "comment": "insert using last_insert_id with argument (already an e2e test for this plan)", "query": "insert into unsharded values(last_insert_id(789), 2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded values(last_insert_id(789), 2)", "Instructions": { @@ -2676,6 +2777,7 @@ "comment": "update vindex value to null with multiple primary keyspace id", "query": "update user set name = null where id in (1, 2, 3)", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update user set name = null where id in (1, 2, 3)", "Instructions": { @@ -2709,6 +2811,7 @@ "comment": "update vindex value to null without a where clause", "query": "update user set name = null", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user set name = null", "Instructions": { @@ -2738,6 +2841,7 @@ "comment": "update vindex value to null with complex where clause", "query": "update user set name = null where id + 1 = 2", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user set name = null where id + 1 = 2", "Instructions": { @@ -2767,6 +2871,7 @@ "comment": "delete from user by primary keyspace id with in clause", "query": "delete from user where id in (1, 2, 3)", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from user where id in (1, 2, 3)", "Instructions": { @@ -2797,6 +2902,7 @@ "comment": "delete from user by complex expression", "query": "delete from user where id + 1 = 2", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user where id + 1 = 2", "Instructions": { @@ -2823,6 +2929,7 @@ "comment": "delete from user without a where clause", "query": "delete from user", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user", "Instructions": { @@ -2849,6 +2956,7 @@ "comment": "delete with single table targets", "query": "delete music from music where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete music from music where id = 1", "Instructions": { @@ -2879,6 +2987,7 @@ "comment": "scatter update table with owned vindexes without changing lookup vindex", "query": "update user set val = 1", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user set val = 1", "Instructions": { @@ -2902,6 +3011,7 @@ "comment": "scatter delete with owned lookup vindex", "query": "delete from user", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user", "Instructions": { @@ -2928,6 +3038,7 @@ "comment": "update multi column vindex, without values for all the vindex columns", "query": "update multicolvin set column_c = 2 where kid = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update multicolvin set column_c = 2 where kid = 1", "Instructions": { @@ -2961,6 +3072,7 @@ "comment": "update with binary value", "query": "update user set name = _binary 'abc' where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set name = _binary 'abc' where id = 1", "Instructions": { @@ -2994,6 +3106,7 @@ "comment": "delete with binary value", "query": "delete from user where name = _binary 'abc'", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from user where name = _binary 'abc'", "Instructions": { @@ -3024,6 +3137,7 @@ "comment": "delete with shard targeting", "query": "delete from `user[-]`.user", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from `user[-]`.user", "Instructions": { @@ -3050,6 +3164,7 @@ "comment": "update with shard targeting", "query": "update `user[-]`.user set name = 'myname'", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update `user[-]`.user set name = 'myname'", "Instructions": { @@ -3079,6 +3194,7 @@ "comment": "update with shard targeting without vindex", "query": "update `user[-]`.user_extra set val = 1", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update `user[-]`.user_extra set val = 1", "Instructions": { @@ -3102,6 +3218,7 @@ "comment": "multi-table delete with single table", "query": "delete u.* from user u where u.id * u.col = u.foo", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete u.* from user u where u.id * u.col = u.foo", "Instructions": { @@ -3146,6 +3263,7 @@ "comment": "INSERT INTO main.user_privacy_consents (user_id, accepted_at) SELECT user_id, accepted_at FROM (SELECT 1 as user_id, 1629194864 as accepted_at) AS tmp WHERE NOT EXISTS (SELECT user_id FROM main.user_privacy_consents WHERE user_id = 1)", "query": "INSERT INTO main.user_privacy_consents (user_id, accepted_at) SELECT user_id, accepted_at FROM (SELECT 1 as user_id, 1629194864 as accepted_at) AS tmp WHERE NOT EXISTS (SELECT user_id FROM main.user_privacy_consents WHERE user_id = 1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO main.user_privacy_consents (user_id, accepted_at) SELECT user_id, accepted_at FROM (SELECT 1 as user_id, 1629194864 as accepted_at) AS tmp WHERE NOT EXISTS (SELECT user_id FROM main.user_privacy_consents WHERE user_id = 1)", "Instructions": { @@ -3170,6 +3288,7 @@ "comment": "Delete on backfilling unique lookup vindex should be a scatter", "query": "delete from zlookup_unique.t1 where c2 = 20", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from zlookup_unique.t1 where c2 = 20", "Instructions": { @@ -3196,6 +3315,7 @@ "comment": "Update on backfilling unique lookup vindex should be a scatter", "query": "update zlookup_unique.t1 set c2 = 1 where c2 = 20", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update zlookup_unique.t1 set c2 = 1 where c2 = 20", "Instructions": { @@ -3225,6 +3345,7 @@ "comment": "Delete on backfilling and non-backfilling unique lookup vindexes should be a delete equal", "query": "delete from zlookup_unique.t1 where c2 = 10 and c3 = 20", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from zlookup_unique.t1 where c2 = 10 and c3 = 20", "Instructions": { @@ -3255,6 +3376,7 @@ "comment": "Update on backfilling and non-backfilling unique lookup vindexes should be an equal", "query": "update zlookup_unique.t1 set c2 = 1 where c2 = 10 and c3 = 20", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update zlookup_unique.t1 set c2 = 1 where c2 = 10 and c3 = 20", "Instructions": { @@ -3288,6 +3410,7 @@ "comment": "Delete EQUAL and IN on backfilling and non-backfilling unique lookup vindexes should be a delete IN", "query": "delete from zlookup_unique.t1 where c2 = 10 and c3 in (20, 21)", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from zlookup_unique.t1 where c2 = 10 and c3 in (20, 21)", "Instructions": { @@ -3318,6 +3441,7 @@ "comment": "Update EQUAL and IN on backfilling and non-backfilling unique lookup vindexes should be an update IN", "query": "update zlookup_unique.t1 set c2 = 1 where c2 = 10 and c3 in (20, 21)", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update zlookup_unique.t1 set c2 = 1 where c2 = 10 and c3 in (20, 21)", "Instructions": { @@ -3351,6 +3475,7 @@ "comment": "update with alias table", "query": "update user u set u.name = 'john' where u.col > 20", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user u set u.name = 'john' where u.col > 20", "Instructions": { @@ -3380,6 +3505,7 @@ "comment": "delete with alias table", "query": "delete from user u where u.col > 20", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from user u where u.col > 20", "Instructions": { @@ -3406,6 +3532,7 @@ "comment": "update with a multicol vindex", "query": "update multicol_tbl set x = 1 where cola = 1 and colb = 2", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update multicol_tbl set x = 1 where cola = 1 and colb = 2", "Instructions": { @@ -3434,6 +3561,7 @@ "comment": "update with a multicol vindex - reverse order", "query": "update multicol_tbl set x = 1 where colb = 2 and cola = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update multicol_tbl set x = 1 where colb = 2 and cola = 1", "Instructions": { @@ -3462,6 +3590,7 @@ "comment": "update with a multicol vindex using an IN clause", "query": "update multicol_tbl set x = 1 where colb IN (1,2) and cola = 1", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update multicol_tbl set x = 1 where colb IN (1,2) and cola = 1", "Instructions": { @@ -3490,6 +3619,7 @@ "comment": "update with a multicol vindex using an IN clause", "query": "update multicol_tbl set x = 1 where colb IN (1,2) and cola IN (3,4)", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update multicol_tbl set x = 1 where colb IN (1,2) and cola IN (3,4)", "Instructions": { @@ -3518,6 +3648,7 @@ "comment": "delete with a multicol vindex", "query": "delete from multicol_tbl where cola = 1 and colb = 2", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from multicol_tbl where cola = 1 and colb = 2", "Instructions": { @@ -3549,6 +3680,7 @@ "comment": "delete with a multicol vindex - reverse order", "query": "delete from multicol_tbl where colb = 2 and cola = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from multicol_tbl where colb = 2 and cola = 1", "Instructions": { @@ -3580,6 +3712,7 @@ "comment": "delete with a multicol vindex using an IN clause", "query": "delete from multicol_tbl where colb IN (1,2) and cola = 1", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from multicol_tbl where colb IN (1,2) and cola = 1", "Instructions": { @@ -3611,6 +3744,7 @@ "comment": "delete with a multicol vindex using an IN clause", "query": "delete from multicol_tbl where colb IN (1,2) and cola IN (3,4)", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from multicol_tbl where colb IN (1,2) and cola IN (3,4)", "Instructions": { @@ -3642,6 +3776,7 @@ "comment": "update with multicol and an owned vindex which changes", "query": "update multicol_tbl set colc = 1 where cola = 1 and colb = 2", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update multicol_tbl set colc = 1 where cola = 1 and colb = 2", "Instructions": { @@ -3676,6 +3811,7 @@ "comment": "update with routing using non-unique lookup vindex", "query": "update multicol_tbl set x = 42 where name = 'foo'", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update multicol_tbl set x = 42 where name = 'foo'", "Instructions": { @@ -3703,6 +3839,7 @@ "comment": "update with routing using subsharding column", "query": "update multicol_tbl set x = 42 where cola = 1", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update multicol_tbl set x = 42 where cola = 1", "Instructions": { @@ -3730,6 +3867,7 @@ "comment": "update with routing using subsharding column on lookup vindex", "query": "update multicol_tbl set name = 'bar' where cola = 1", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update multicol_tbl set name = 'bar' where cola = 1", "Instructions": { @@ -3763,6 +3901,7 @@ "comment": "update with routing using subsharding column with in query", "query": "update multicol_tbl set name = 'bar' where cola in (1,2)", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update multicol_tbl set name = 'bar' where cola in (1,2)", "Instructions": { @@ -3796,6 +3935,7 @@ "comment": "update with routing using subsharding column with in query as lower cost over lookup vindex", "query": "update multicol_tbl set x = 1 where name = 'foo' and cola = 2", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update multicol_tbl set x = 1 where name = 'foo' and cola = 2", "Instructions": { @@ -3823,6 +3963,7 @@ "comment": "delete with routing using non-unique lookup vindex", "query": "delete from multicol_tbl where name = 'foo'", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from multicol_tbl where name = 'foo'", "Instructions": { @@ -3853,6 +3994,7 @@ "comment": "delete with routing using subsharding column", "query": "delete from multicol_tbl where cola = 1", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from multicol_tbl where cola = 1", "Instructions": { @@ -3883,6 +4025,7 @@ "comment": "delete with routing using subsharding column with in query", "query": "delete from multicol_tbl where cola in (1,2)", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from multicol_tbl where cola in (1,2)", "Instructions": { @@ -3913,6 +4056,7 @@ "comment": "delete with routing using subsharding column with in query as lower cost over lookup vindex", "query": "delete from multicol_tbl where name = 'foo' and cola = 2", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from multicol_tbl where name = 'foo' and cola = 2", "Instructions": { @@ -3943,6 +4087,7 @@ "comment": "insert using select with simple table.", "query": "insert into music(id, user_id) select * from user", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into music(id, user_id) select * from user", "Instructions": { @@ -4001,6 +4146,7 @@ "comment": "insert using select with auto-inc column using vitess sequence, sequence column not present", "query": "insert into user_extra(user_id) select id from user", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user_extra(user_id) select id from user", "Instructions": { @@ -4041,6 +4187,7 @@ "comment": "insert using select with auto-inc column using vitess sequence, sequence column present", "query": "insert into user_extra(id, user_id) select null, id from user", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user_extra(id, user_id) select null, id from user", "Instructions": { @@ -4081,6 +4228,7 @@ "comment": "sharded insert from select", "query": "insert into user(id) select 1 from dual", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user(id) select 1 from dual", "Instructions": { @@ -4123,6 +4271,7 @@ "comment": "insert using select with sharding column is autoinc and not present in the insert column query", "query": "insert into user(pattern) SELECT 1", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user(pattern) SELECT 1", "Instructions": { @@ -4171,6 +4320,7 @@ "comment": "sharded same keyspace", "query": "insert into user_extra(user_id, col) select col1, col2 from user", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user_extra(user_id, col) select col1, col2 from user", "Instructions": { @@ -4211,6 +4361,7 @@ "comment": "unsharded same keyspace", "query": "insert into unsharded(col) select col from unsharded_auto", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded(col) select col from unsharded_auto", "Instructions": { @@ -4235,6 +4386,7 @@ "comment": "sharded different keyspace", "query": "insert into user_extra(user_id, col) select col1, col2 from t1", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user_extra(user_id, col) select col1, col2 from t1", "Instructions": { @@ -4275,6 +4427,7 @@ "comment": "sharded insert table, unsharded select table", "query": "insert into user_extra(user_id, col) select col1, col2 from unsharded_tab", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user_extra(user_id, col) select col1, col2 from unsharded_tab", "Instructions": { @@ -4315,6 +4468,7 @@ "comment": "unsharded different keyspace", "query": "insert into unsharded(col) select col from unsharded_tab", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into unsharded(col) select col from unsharded_tab", "Instructions": { @@ -4351,6 +4505,7 @@ "comment": "unsharded insert table, sharded select table", "query": "insert into unsharded(col) select col from t1", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into unsharded(col) select col from t1", "Instructions": { @@ -4387,6 +4542,7 @@ "comment": "unsharded subquery in sharded update, not the same keyspace between outer and inner", "query": "update user set col = (select id from unsharded)", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user set col = (select id from unsharded)", "Instructions": { @@ -4433,6 +4589,7 @@ "comment": "sharded subquery in unsharded update, not the same keyspace", "query": "update unsharded set col = (select id from user)", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update unsharded set col = (select id from user)", "Instructions": { @@ -4479,6 +4636,7 @@ "comment": "sharded join unsharded subqueries in unsharded update", "query": "update unsharded set col = (select id from unsharded join user on unsharded.id = user.id)", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update unsharded set col = (select id from unsharded join user on unsharded.id = user.id)", "Instructions": { @@ -4551,6 +4709,7 @@ "comment": "sharded update with sub query where the sources can be merged into a single query", "query": "update user set col = (select count(*) from user_extra where user_extra.user_id = 5) where id = 5", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set col = (select count(*) from user_extra where user_extra.user_id = 5) where id = 5", "Instructions": { @@ -4579,6 +4738,7 @@ "comment": "merge through correlated subquery", "query": "update user set col = (select count(*) from user_extra where user_extra.user_id = user.id) where id = 5", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user set col = (select count(*) from user_extra where user_extra.user_id = user.id) where id = 5", "Instructions": { @@ -4607,6 +4767,7 @@ "comment": "merge through correlated subquery #2", "query": "update user set col = (select count(*) from user_extra where user_extra.user_id = user.id) where id > 5", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update user set col = (select count(*) from user_extra where user_extra.user_id = user.id) where id > 5", "Instructions": { @@ -4631,6 +4792,7 @@ "comment": "all defaults empty column, empty values", "query": "insert into authoritative () values ()", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into authoritative () values ()", "Instructions": { @@ -4663,6 +4825,7 @@ "comment": "vexplain dml with actually_run_query directive", "query": "vexplain /*vt+ execute_dml_queries */ queries delete from user", "plan": { + "Type": "Complex", "QueryType": "EXPLAIN", "Original": "vexplain /*vt+ execute_dml_queries */ queries delete from user", "Instructions": { @@ -4695,6 +4858,7 @@ "comment": "explain dml with actually_run_query directive - 2", "query": "vexplain /*vt+ eXECUTE_DML_QUERIES */ queries delete from user", "plan": { + "Type": "Complex", "QueryType": "EXPLAIN", "Original": "vexplain /*vt+ eXECUTE_DML_QUERIES */ queries delete from user", "Instructions": { @@ -4727,6 +4891,7 @@ "comment": "delete with join from multi table join subquery", "query": "delete foo from unsharded as foo join (select id from unsharded a join unsharded_b b on a.user_id = b.user_id) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col < 1000", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete foo from unsharded as foo join (select id from unsharded a join unsharded_b b on a.user_id = b.user_id) as keepers on foo.id = keepers.id where keepers.id is null and foo.col is not null and foo.col < 1000", "Instructions": { @@ -4751,6 +4916,7 @@ "comment": "update with routing using multi column vindex", "query": "update user set col = 1 where (name, col) in (('aa', 'bb'), ('cc', 'dd'))", "plan": { + "Type": "MultiShard", "QueryType": "UPDATE", "Original": "update user set col = 1 where (name, col) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { @@ -4778,6 +4944,7 @@ "comment": "delete with routing using multi column vindex", "query": "delete from user where (name, col) in (('aa', 'bb'), ('cc', 'dd'))", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from user where (name, col) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { @@ -4808,6 +4975,7 @@ "comment": "insert into ref; TODO(maxeng) is this a bug?", "query": "insert into ref(col) values(1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into ref(col) values(1)", "Instructions": { @@ -4831,6 +4999,7 @@ "comment": "update using last_insert_id with an argument", "query": "update main.m1 set foo = last_insert_id(foo+1) where id = 12345", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update main.m1 set foo = last_insert_id(foo+1) where id = 12345", "Instructions": { @@ -4854,6 +5023,7 @@ "comment": "unsharded update query with comment directive", "query": "update /*vt+ QUERY_TIMEOUT_MS=1 */ unsharded set val = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update /*vt+ QUERY_TIMEOUT_MS=1 */ unsharded set val = 1", "Instructions": { @@ -4878,6 +5048,7 @@ "comment": "unsharded insert query with comment directive", "query": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into unsharded values ()", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert /*vt+ QUERY_TIMEOUT_MS=1 */ into unsharded values ()", "Instructions": { @@ -4902,6 +5073,7 @@ "comment": "insert with select using same tables, cannot stream parallel", "query": "insert into music(id, user_id) select id, user_id from music where user_id = 1", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into music(id, user_id) select id, user_id from music where user_id = 1", "Instructions": { @@ -4946,6 +5118,7 @@ "comment": "insert + lookup vindex + auto increment on lookup column - not provided", "query": "insert into mixed_tbl(shard_key) values (1),(4),(9)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into mixed_tbl(shard_key) values (1),(4),(9)", "Instructions": { @@ -4974,6 +5147,7 @@ "comment": "insert + lookup vindex + auto increment on lookup column - partially provided", "query": "insert into mixed_tbl(shard_key, lkp_key) values (1, 1),(4, null),(9, 27)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into mixed_tbl(shard_key, lkp_key) values (1, 1),(4, null),(9, 27)", "Instructions": { @@ -5002,6 +5176,7 @@ "comment": "insert + lookup vindex + auto increment on lookup column + select - not provided", "query": "insert into mixed_tbl(shard_key) select foo from user where id = 1", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into mixed_tbl(shard_key) select foo from user where id = 1", "Instructions": { @@ -5047,6 +5222,7 @@ "comment": "insert + lookup vindex + auto increment on lookup column + select - provided", "query": "insert into mixed_tbl(shard_key, lkp_key) select foo, bar from user where id = 1", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into mixed_tbl(shard_key, lkp_key) select foo, bar from user where id = 1", "Instructions": { @@ -5098,6 +5274,7 @@ "comment": "insert with select takes shared lock", "query": "insert into user(id) select id from user", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into user(id) select id from user", "Instructions": { @@ -5170,6 +5347,7 @@ "comment": "insert on duplicate key update with database qualifier", "query": "insert into user.music(id, user_id, col) values (1, 2, 3) on duplicate key update user.music.col = 5", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user.music(id, user_id, col) values (1, 2, 3) on duplicate key update user.music.col = 5", "Instructions": { @@ -5198,6 +5376,7 @@ "comment": "delete from reference table - query send to source table", "query": "delete from user.ref_with_source where col = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from user.ref_with_source where col = 1", "Instructions": { @@ -5221,6 +5400,7 @@ "comment": "delete from reference table - no source", "query": "delete from user.ref", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from user.ref", "Instructions": { @@ -5244,6 +5424,7 @@ "comment": "delete by target destination with limit", "query": "delete from `user[-]`.`user` limit 20", "plan": { + "Type": "MultiShard", "QueryType": "DELETE", "Original": "delete from `user[-]`.`user` limit 20", "Instructions": { @@ -5270,6 +5451,7 @@ "comment": "delete sharded table with join with reference table", "query": "delete u from user u join ref_with_source r on u.col = r.col", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete u from user u join ref_with_source r on u.col = r.col", "Instructions": { @@ -5297,6 +5479,7 @@ "comment": "delete sharded table with join with another sharded table on vindex column", "query": "delete u from user u join music m on u.id = m.user_id", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete u from user u join music m on u.id = m.user_id", "Instructions": { @@ -5324,6 +5507,7 @@ "comment": "multi delete multi table", "query": "delete user from user join user_extra on user.id = user_extra.id where user.name = 'foo'", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete user from user join user_extra on user.id = user_extra.id where user.name = 'foo'", "Instructions": { @@ -5401,6 +5585,7 @@ "comment": "multi delete multi table with alias", "query": "delete u from user u join music m on u.col = m.col", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u from user u join music m on u.col = m.col", "Instructions": { @@ -5474,6 +5659,7 @@ "comment": "reverse the join order for delete", "query": "delete u from music m join user u where u.col = m.col and m.foo = 42", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u from music m join user u where u.col = m.col and m.foo = 42", "Instructions": { @@ -5547,6 +5733,7 @@ "comment": "multi table delete with join on vindex column", "query": "delete u from user u join music m where u.id = m.user_id and m.foo = 42", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete u from user u join music m where u.id = m.user_id and m.foo = 42", "Instructions": { @@ -5574,6 +5761,7 @@ "comment": "delete 3 way join with sharding key and primary key same", "query": "delete u from user u join music m on u.col = m.col join user_extra ue on m.user_id = ue.user_id where ue.foo = 20 and u.col = 30 and m.bar = 40", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u from user u join music m on u.col = m.col join user_extra ue on m.user_id = ue.user_id where ue.foo = 20 and u.col = 30 and m.bar = 40", "Instructions": { @@ -5648,6 +5836,7 @@ "comment": "delete 3 way join with sharding key and primary key different", "query": "delete m from user u join music m on u.col = m.col join user_extra ue on m.user_id = ue.user_id where ue.foo = 20 and u.col = 30 and m.bar = 40", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete m from user u join music m on u.col = m.col join user_extra ue on m.user_id = ue.user_id where ue.foo = 20 and u.col = 30 and m.bar = 40", "Instructions": { @@ -5722,6 +5911,7 @@ "comment": "sharded delete with limit clause", "query": "delete from user limit 10", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from user limit 10", "Instructions": { @@ -5778,6 +5968,7 @@ "comment": "sharded delete with order by and limit clause", "query": "delete from user order by name, col limit 5", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from user order by name, col limit 5", "Instructions": { @@ -5835,6 +6026,7 @@ "comment": "update with limit clause", "query": "update user set val = 1 where (name = 'foo' or id = 1) limit 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user set val = 1 where (name = 'foo' or id = 1) limit 1", "Instructions": { @@ -5888,6 +6080,7 @@ "comment": "update a vindex column with limit", "query": "update user set name = 'abc' where id > 10 limit 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user set name = 'abc' where id > 10 limit 1", "Instructions": { @@ -5947,6 +6140,7 @@ "comment": "update with multi table join with single target", "query": "update user as u, user_extra as ue set u.name = 'foo' where u.id = ue.id", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user as u, user_extra as ue set u.name = 'foo' where u.id = ue.id", "Instructions": { @@ -6027,6 +6221,7 @@ "comment": "update with multi table join with single target modifying lookup vindex", "query": "update user join user_extra on user.id = user_extra.id set user.name = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user join user_extra on user.id = user_extra.id set user.name = 'foo'", "Instructions": { @@ -6107,6 +6302,7 @@ "comment": "update with multi table join with single target having dependent column update", "query": "update user as u, user_extra as ue set u.col = ue.col where u.id = ue.id", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user as u, user_extra as ue set u.col = ue.col where u.id = ue.id", "Instructions": { @@ -6184,6 +6380,7 @@ "comment": "update with multi table join with single target having multiple dependent column update", "query": "update user as u, user_extra as ue set u.col = ue.foo + ue.bar + u.baz where u.id = ue.id", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user as u, user_extra as ue set u.col = ue.foo + ue.bar + u.baz where u.id = ue.id", "Instructions": { @@ -6261,6 +6458,7 @@ "comment": "update with multi table join with multi target having dependent column update", "query": "update user, user_extra ue set user.name = ue.id + 'foo', ue.bar = user.baz where user.id = ue.id and user.id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update user, user_extra ue set user.name = ue.id + 'foo', ue.bar = user.baz where user.id = ue.id and user.id = 1", "Instructions": { @@ -6373,6 +6571,7 @@ "comment": "Delete with routed table on music", "query": "delete from second_user.bar", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from second_user.bar", "Instructions": { @@ -6399,6 +6598,7 @@ "comment": "Update with routed table on music", "query": "update second_user.bar set col = 23", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update second_user.bar set col = 23", "Instructions": { @@ -6422,6 +6622,7 @@ "comment": "Insert with routed table on music", "query": "insert into second_user.bar(id) values (2)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into second_user.bar(id) values (2)", "Instructions": { @@ -6449,6 +6650,7 @@ "comment": "sharded subquery in sharded delete", "query": "delete from user where id = (select id from music where user_id = 1)", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from user where id = (select id from music where user_id = 1)", "Instructions": { @@ -6506,6 +6708,7 @@ "comment": "unsharded subquery in sharded delete", "query": "delete from user where col = (select id from unsharded)", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from user where col = (select id from unsharded)", "Instructions": { @@ -6555,6 +6758,7 @@ "comment": "sharded subquery in unsharded delete", "query": "delete from unsharded where col = (select id from user)", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from unsharded where col = (select id from user)", "Instructions": { @@ -6601,6 +6805,7 @@ "comment": "sharded subquery in unsharded subquery in unsharded delete", "query": "delete from unsharded where col = (select id from unsharded where id = (select id from user))", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from unsharded where col = (select id from unsharded where id = (select id from user))", "Instructions": { @@ -6669,6 +6874,7 @@ "comment": "sharded join unsharded subquery in unsharded delete", "query": "delete from unsharded where col = (select id from unsharded join user on unsharded.id = user.id)", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from unsharded where col = (select id from unsharded join user on unsharded.id = user.id)", "Instructions": { @@ -6741,6 +6947,7 @@ "comment": "multi target delete on sharded table", "query": "delete u, m from user u, music m where u.col = m.col and u.foo = m.bar and u.baz = 12 and m.baz = 21", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u, m from user u, music m where u.col = m.col and u.foo = m.bar and u.baz = 12 and m.baz = 21", "Instructions": { @@ -6834,6 +7041,7 @@ "comment": "delete with multi-table targets", "query": "delete music,user from music inner join user where music.id = user.id", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete music,user from music inner join user where music.id = user.id", "Instructions": { @@ -6930,6 +7138,7 @@ "comment": "multi table delete with 2 sharded tables join on vindex column", "query": "delete u, m from user u join music m on u.id = m.user_id", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u, m from user u join music m on u.id = m.user_id", "Instructions": { @@ -7000,6 +7209,7 @@ "comment": "multi table delete with 2 sharded tables join on non-vindex column", "query": "delete u, m from user u join music m on u.col = m.col", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u, m from user u join music m on u.col = m.col", "Instructions": { @@ -7092,6 +7302,7 @@ "comment": "multi target delete with composite primary key having single column vindex", "query": "delete u, ue from user u join user_extra ue on u.id = ue.user_id", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u, ue from user u join user_extra ue on u.id = ue.user_id", "Instructions": { @@ -7159,6 +7370,7 @@ "comment": "multi target delete with composite primary key with lookup vindex as sharding column", "query": "delete o, ev from `order` o join order_event ev where o.oid = ev.oid and ev.ename = 'a'", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete o, ev from `order` o join order_event ev where o.oid = ev.oid and ev.ename = 'a'", "Instructions": { @@ -7226,6 +7438,7 @@ "comment": "update with multi table reference with multi target update", "query": "update ignore user u, music m set u.foo = 21, m.bar = 'abc' where u.col = m.col", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update ignore user u, music m set u.foo = 21, m.bar = 'abc' where u.col = m.col", "Instructions": { @@ -7312,6 +7525,7 @@ "comment": "RowAlias in INSERT", "query": "INSERT INTO authoritative (user_id,col1,col2) VALUES (1,'2',3),(4,'5',6) AS new ON DUPLICATE KEY UPDATE col2 = new.user_id+new.col1", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO authoritative (user_id,col1,col2) VALUES (1,'2',3),(4,'5',6) AS new ON DUPLICATE KEY UPDATE col2 = new.user_id+new.col1", "Instructions": { @@ -7339,6 +7553,7 @@ "comment": "RowAlias with explicit columns in INSERT", "query": "INSERT INTO authoritative (user_id,col1,col2) VALUES (1,'2',3),(4,'5',6) AS new(a,b,c) ON DUPLICATE KEY UPDATE col1 = a+c", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO authoritative (user_id,col1,col2) VALUES (1,'2',3),(4,'5',6) AS new(a,b,c) ON DUPLICATE KEY UPDATE col1 = a+c", "Instructions": { @@ -7366,6 +7581,7 @@ "comment": "RowAlias in INSERT (no column list)", "query": "INSERT INTO authoritative VALUES (1,'2',3),(4,'5',6) AS new ON DUPLICATE KEY UPDATE col2 = new.user_id+new.col1", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO authoritative VALUES (1,'2',3),(4,'5',6) AS new ON DUPLICATE KEY UPDATE col2 = new.user_id+new.col1", "Instructions": { @@ -7393,6 +7609,7 @@ "comment": "RowAlias with explicit columns in INSERT (no column list)", "query": "INSERT INTO authoritative VALUES (1,'2',3),(4,'5',6) AS new(a,b,c) ON DUPLICATE KEY UPDATE col1 = a+c", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO authoritative VALUES (1,'2',3),(4,'5',6) AS new(a,b,c) ON DUPLICATE KEY UPDATE col1 = a+c", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/dml_cases_with_user_as_default.json b/go/vt/vtgate/planbuilder/testdata/dml_cases_with_user_as_default.json index ff66967c2ce..cf956a1685b 100644 --- a/go/vt/vtgate/planbuilder/testdata/dml_cases_with_user_as_default.json +++ b/go/vt/vtgate/planbuilder/testdata/dml_cases_with_user_as_default.json @@ -3,6 +3,7 @@ "comment": "Update reference table from sharded keyspace to unsharded keyspace", "query": "update ambiguous_ref_with_source set done = true where id = 1;", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update ambiguous_ref_with_source set done = true where id = 1;", "Instructions": { @@ -21,4 +22,4 @@ ] } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.json b/go/vt/vtgate/planbuilder/testdata/filter_cases.json index 72b6c4ddd46..7bc13106706 100644 --- a/go/vt/vtgate/planbuilder/testdata/filter_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.json @@ -3,6 +3,7 @@ "comment": "No where clause", "query": "select id from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user", "Instructions": { @@ -25,6 +26,7 @@ "comment": "Query that always return empty", "query": "select id from user where someColumn = null", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select id from user where someColumn = null", "Instructions": { @@ -47,6 +49,7 @@ "comment": "Null Safe Equality Operator is handled correctly", "query": "SELECT id from user where someColumn <=> null", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT id from user where someColumn <=> null", "Instructions": { @@ -69,6 +72,7 @@ "comment": "Single table unique vindex route", "query": "select id from user where user.id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where user.id = 5", "Instructions": { @@ -95,6 +99,7 @@ "comment": "Single table unique vindex route, but complex expr", "query": "select id from user where user.id = 5+5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where user.id = 5+5", "Instructions": { @@ -121,6 +126,7 @@ "comment": "Single table multiple unique vindex match", "query": "select id from music where id = 5 and user_id = 4", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from music where id = 5 and user_id = 4", "Instructions": { @@ -147,6 +153,7 @@ "comment": "Single table multiple non-unique vindex match", "query": "select id from user where costly = 'aa' and name = 'bb'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where costly = 'aa' and name = 'bb'", "Instructions": { @@ -198,6 +205,7 @@ "comment": "Single table multiple non-unique vindex match for IN clause", "query": "select id from user where costly in ('aa', 'bb') and name in ('aa', 'bb')", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where costly in ('aa', 'bb') and name in ('aa', 'bb')", "Instructions": { @@ -249,6 +257,7 @@ "comment": "Composite IN clause", "query": "select id from user where (name, col) in (('aa', 'bb'), ('cc', 'dd'))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (name, col) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { @@ -300,6 +309,7 @@ "comment": "Composite IN clause, swapped columns", "query": "select id from user where (col, name) in (('aa', 'bb'), ('cc', 'dd'))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (col, name) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { @@ -351,6 +361,7 @@ "comment": "Composite IN clause, choose cost within tuple", "query": "select id from user where (costly, name) in (('aa', 'bb'), ('cc', 'dd'))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (costly, name) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { @@ -402,6 +413,7 @@ "comment": "Composite IN clause, choose cost within tuple, swapped", "query": "select id from user where (name, costly) in (('aa', 'bb'), ('cc', 'dd'))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (name, costly) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { @@ -453,6 +465,7 @@ "comment": "Composite IN clause, choose cost", "query": "select id from user where (col, costly) in (('aa', 'bb')) and (col, name) in (('cc', 'dd'))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (col, costly) in (('aa', 'bb')) and (col, name) in (('cc', 'dd'))", "Instructions": { @@ -504,6 +517,7 @@ "comment": "Composite IN clause vs equality", "query": "select id from user where (col, name) in (('aa', 'bb')) and id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where (col, name) in (('aa', 'bb')) and id = 5", "Instructions": { @@ -530,6 +544,7 @@ "comment": "Composite IN: multiple vindex matches", "query": "select id from user where (costly, name) in (('aa', 'bb'), ('cc', 'dd'))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (costly, name) in (('aa', 'bb'), ('cc', 'dd'))", "Instructions": { @@ -581,6 +596,7 @@ "comment": "Composite IN: tuple inside tuple", "query": "select id from user where ((col1, name), col2) in ((('aa', 'bb'), 'cc'), (('dd', 'ee'), 'ff'))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where ((col1, name), col2) in ((('aa', 'bb'), 'cc'), (('dd', 'ee'), 'ff'))", "Instructions": { @@ -632,6 +648,7 @@ "comment": "Composite IN: tuple inside tuple, but no match in tuple", "query": "select id from user where (name, (col1, col2)) in (('aa', ('bb', 'cc')), ('dd', ('ee', 'ff')))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (name, (col1, col2)) in (('aa', ('bb', 'cc')), ('dd', ('ee', 'ff')))", "Instructions": { @@ -683,6 +700,7 @@ "comment": "Composite IN: tuple inside tuple, mismiatched values", "query": "select id from user where ((col1, name), col2) in (('aa', 'bb', 'cc'), (('dd', 'ee'), 'ff'))", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user where ((col1, name), col2) in (('aa', 'bb', 'cc'), (('dd', 'ee'), 'ff'))", "Instructions": { @@ -706,6 +724,7 @@ "comment": "Composite IN: RHS not tuple", "query": "select id from user where (col1, name) in (select * from music where music.user_id=user.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user where (col1, name) in (select * from music where music.user_id=user.id)", "Instructions": { @@ -724,12 +743,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Composite IN: RHS has no simple values", "query": "select id from user where (col1, name) in (('aa', 1+1))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (col1, name) in (('aa', 1+1))", "Instructions": { @@ -781,6 +801,7 @@ "comment": "IN clause: LHS is neither column nor composite tuple", "query": "select Id from user where 1 in ('aa', 'bb')", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select Id from user where 1 in ('aa', 'bb')", "Instructions": { @@ -803,6 +824,7 @@ "comment": "Disjunction of conjunctions with 4 or more disjunctions", "query": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff') OR (col = 'gg' AND name = 'hh')", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff') OR (col = 'gg' AND name = 'hh')", "Instructions": { @@ -854,6 +876,7 @@ "comment": "Disjunction of conjunctions with 3 or less disjunctions", "query": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff')", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where (col = 'aa' AND name = 'bb') OR (col = 'cc' AND name = 'dd') OR (col = 'ee' AND name = 'ff')", "Instructions": { @@ -905,6 +928,7 @@ "comment": "Single table complex in clause", "query": "select id from user where name in (col, 'bb')", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user where name in (col, 'bb')", "Instructions": { @@ -927,6 +951,7 @@ "comment": "Single table equality route with val arg", "query": "select id from user where name = :a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where name = :a", "Instructions": { @@ -973,12 +998,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Merging subqueries should remove keyspace from query", "query": "select u.id from user.user as u where not exists (select 1 from user.user_extra as ue where u.id = ue.user_id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select u.id from user.user as u where not exists (select 1 from user.user_extra as ue where u.id = ue.user_id)", "Instructions": { @@ -1002,6 +1028,7 @@ "comment": "Single table equality route with unsigned value", "query": "select id from user where name = 18446744073709551615", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where name = 18446744073709551615", "Instructions": { @@ -1053,6 +1080,7 @@ "comment": "Single table in clause list arg", "query": "select id from user where name in ::list", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where name in ::list", "Instructions": { @@ -1105,6 +1133,7 @@ "comment": "Multi-table unique vindex constraint", "query": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user.id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user.id = 5", "Instructions": { @@ -1132,6 +1161,7 @@ "comment": "Multi-table unique vindex constraint on right table", "query": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user_extra.id from user join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { @@ -1159,6 +1189,7 @@ "comment": "Multi-table unique vindex constraint on left table of left join", "query": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user.id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user.id = 5", "Instructions": { @@ -1186,6 +1217,7 @@ "comment": "Multi-table unique vindex constraint on left-joined right table", "query": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user_extra.id from user left join user_extra on user.id = user_extra.user_id where user_extra.user_id = 5", "Instructions": { @@ -1213,6 +1245,7 @@ "comment": "Multi-route unique vindex constraint", "query": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5", "Instructions": { @@ -1257,12 +1290,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Multi-route unique vindex route on both routes", "query": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5 and user_extra.user_id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user.id = 5 and user_extra.user_id = 5", "Instructions": { @@ -1285,12 +1319,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Multi-route with cross-route constraint", "query": "select user_extra.id from user join user_extra on user.col = user_extra.col where user_extra.user_id = user.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where user_extra.user_id = user.col", "Instructions": { @@ -1335,12 +1370,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Multi-route with non-route constraint, should use first route.", "query": "select user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_extra.id from user join user_extra on user.col = user_extra.col where 1 = 1", "Instructions": { @@ -1381,12 +1417,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Route with multiple route constraints, SelectIN is the best constraint.", "query": "select id from user where user.col = 5 and user.id in (1, 2)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select id from user where user.col = 5 and user.id in (1, 2)", "Instructions": { @@ -1413,6 +1450,7 @@ "comment": "Route with multiple route constraints and boolean, SelectIN is the best constraint.", "query": "select id from user where user.col = case user.col when 'foo' then true else false end and user.id in (1, 2)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select id from user where user.col = case user.col when 'foo' then true else false end and user.id in (1, 2)", "Instructions": { @@ -1439,6 +1477,7 @@ "comment": "Route with multiple route constraints and boolean, SelectEqual is the best constraint.", "query": "select (id or col) as val from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select (id or col) as val from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa'", "Instructions": { @@ -1490,6 +1529,7 @@ "comment": "Route with multiple route constraints, SelectEqual is the best constraint.", "query": "select id from user where user.col = false and user.id in (1, 2) and user.name = 'aa'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where user.col = false and user.id in (1, 2) and user.name = 'aa'", "Instructions": { @@ -1541,6 +1581,7 @@ "comment": "Route with multiple route constraints, SelectEqualUnique is the best constraint.", "query": "select id from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa' and user.id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where user.col = 5 and user.id in (1, 2) and user.name = 'aa' and user.id = 1", "Instructions": { @@ -1567,6 +1608,7 @@ "comment": "Route with multiple route constraints, SelectEqualUnique is the best constraint, order reversed.", "query": "select id from user where user.id = 1 and user.name = 'aa' and user.id in (1, 2) and user.col = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where user.id = 1 and user.name = 'aa' and user.id in (1, 2) and user.col = 5", "Instructions": { @@ -1593,6 +1635,7 @@ "comment": "Route with OR and AND clause, must parenthesize correctly.", "query": "select id from user where user.id = 1 or user.name = 'aa' and user.id in (1, 2)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select id from user where user.id = 1 or user.name = 'aa' and user.id in (1, 2)", "Instructions": { @@ -1619,6 +1662,7 @@ "comment": "Unsharded route", "query": "select unsharded.id from user join unsharded where unsharded.id = user.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select unsharded.id from user join unsharded where unsharded.id = user.id", "Instructions": { @@ -1663,12 +1707,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "routing rules: choose the redirected table", "query": "select col from route1 where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from route1 where id = 1", "Instructions": { @@ -1690,12 +1735,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "subquery", "query": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id and user_extra.col = user.col) and u.id in (user_extra.col, 1)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id and user_extra.col = user.col) and u.id in (user_extra.col, 1)", "Instructions": { @@ -1740,12 +1786,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "correlated subquery merge-able into a route of a join tree", "query": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id) and u.id in (user_extra.col, 1)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id) and u.id in (user_extra.col, 1)", "Instructions": { @@ -1790,12 +1837,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "ensure subquery reordering gets us a better plan", "query": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = 5) and u.id = 5", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = 5) and u.id = 5", "Instructions": { @@ -1837,12 +1885,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "nested subquery", "query": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id and user_extra.col = user.col and user.id in (select m3 from user_extra where user_extra.user_id = user.id)) and u.id in (user_extra.col, 1)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.m from user_extra join user u where u.id in (select m2 from user where user.id = u.id and user_extra.col = user.col and user.id in (select m3 from user_extra where user_extra.user_id = user.id)) and u.id in (user_extra.col, 1)", "Instructions": { @@ -1887,12 +1936,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Correlated subquery in where clause", "query": "select id from user where user.col in (select user_extra.col from user_extra where user_extra.user_id = user.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user where user.col in (select user_extra.col from user_extra where user_extra.user_id = user.id)", "Instructions": { @@ -1911,12 +1961,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "outer and inner subquery route by same int val", "query": "select id from user where id = 5 and user.col in (select user_extra.col from user_extra where user_extra.user_id = 5)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where id = 5 and user.col in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Instructions": { @@ -1939,12 +1990,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "outer and inner subquery route by same str val", "query": "select id from user where id = 'aa' and user.col in (select user_extra.col from user_extra where user_extra.user_id = 'aa')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where id = 'aa' and user.col in (select user_extra.col from user_extra where user_extra.user_id = 'aa')", "Instructions": { @@ -1967,12 +2019,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "outer and inner subquery route by same val arg", "query": "select id from user where id = :a and user.col in (select user_extra.col from user_extra where user_extra.user_id = :a)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where id = :a and user.col in (select user_extra.col from user_extra where user_extra.user_id = :a)", "Instructions": { @@ -1995,18 +2048,19 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "unresolved symbol in inner subquery.", "query": "select id from user where id = :a and user.col in (select user_extra.col from user_extra where user_extra.user_id = :a and foo.id = 1)", "plan": "column 'foo.id' not found", - "skip_e2e":true + "skip_e2e": true }, { "comment": "outer and inner subquery route by same outermost column value", "query": "select id2 from user uu where id in (select id from user where id = uu.id and user.col in (select user_extra.col from user_extra where user_extra.user_id = uu.id))", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id2 from user uu where id in (select id from user where id = uu.id and user.col in (select user_extra.col from user_extra where user_extra.user_id = uu.id))", "Instructions": { @@ -2025,12 +2079,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "cross-shard subquery in IN clause.\n# Note the improved Underlying plan as SelectIN.", "query": "select id from user where id in (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id in (select col from user)", "Instructions": { @@ -2080,6 +2135,7 @@ "comment": "cross-shard subquery in NOT IN clause.", "query": "select id from user where id not in (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id not in (select col from user)", "Instructions": { @@ -2125,6 +2181,7 @@ "comment": "cross-shard subquery in EXISTS clause.", "query": "select id from user where exists (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where exists (select col from user)", "Instructions": { @@ -2175,6 +2232,7 @@ "comment": "cross-shard subquery as expression", "query": "select id from user where id = (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id = (select col from user)", "Instructions": { @@ -2223,6 +2281,7 @@ "comment": "multi-level pullout", "query": "select id1 from user where id = (select id2 from user where id2 in (select id3 from user))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id1 from user where id = (select id2 from user where id2 in (select id3 from user))", "Instructions": { @@ -2294,6 +2353,7 @@ "comment": "routing rules subquery merge", "query": "select col from user where id = (select id from route1 where route1.id = user.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from user where id = (select id from route1 where route1.id = user.id)", "Instructions": { @@ -2311,12 +2371,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "routing rules subquery pullout", "query": "select col from user where id = (select id from route2)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user where id = (select id from route2)", "Instructions": { @@ -2361,12 +2422,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "Case preservation test", "query": "select user_extra.Id from user join user_extra on user.iD = user_extra.User_Id where user.Id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user_extra.Id from user join user_extra on user.iD = user_extra.User_Id where user.Id = 5", "Instructions": { @@ -2389,12 +2451,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "database() call in where clause.", "query": "select id from user where database()", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user where database()", "Instructions": { @@ -2417,6 +2480,7 @@ "comment": "Select with equals null", "query": "select id from music where id = null", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select id from music where id = null", "Instructions": { @@ -2439,6 +2503,7 @@ "comment": "SELECT with IS NULL", "query": "select id from music where id is null", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from music where id is null", "Instructions": { @@ -2461,6 +2526,7 @@ "comment": "SELECT with IS NOT NULL", "query": "select id from music where id is not null", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from music where id is not null", "Instructions": { @@ -2483,6 +2549,7 @@ "comment": "Single table with unique vindex match and null match", "query": "select id from music where user_id = 4 and id = null", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select id from music where user_id = 4 and id = null", "Instructions": { @@ -2505,6 +2572,7 @@ "comment": "Single table with unique vindex match and IN (null)", "query": "select id from music where user_id = 4 and id IN (null)", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select id from music where user_id = 4 and id IN (null)", "Instructions": { @@ -2527,6 +2595,7 @@ "comment": "Single table with unique vindex match and IN (null, 1, 2)", "query": "select id from music where user_id = 4 and id IN (null, 1, 2)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from music where user_id = 4 and id IN (null, 1, 2)", "Instructions": { @@ -2553,6 +2622,7 @@ "comment": "Single table with unique vindex match and NOT IN (null, 1, 2)", "query": "select id from music where user_id = 4 and id NOT IN (null, 1, 2)", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select id from music where user_id = 4 and id NOT IN (null, 1, 2)", "Instructions": { @@ -2575,6 +2645,7 @@ "comment": "Single table with unique vindex match and NOT IN (null, 1, 2) predicates inverted", "query": "select id from music where id NOT IN (null, 1, 2) and user_id = 4", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select id from music where id NOT IN (null, 1, 2) and user_id = 4", "Instructions": { @@ -2597,6 +2668,7 @@ "comment": "pullout sq after pullout sq", "query": "select id from user where not id in (select user_extra.col from user_extra where user_extra.user_id = 42) and id in (select user_extra.col from user_extra where user_extra.user_id = 411)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where not id in (select user_extra.col from user_extra where user_extra.user_id = 42) and id in (select user_extra.col from user_extra where user_extra.user_id = 411)", "Instructions": { @@ -2673,12 +2745,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "solving LIKE query with a CFC prefix vindex", "query": "select c2 from cfc_vindex_col where c1 like 'A%'", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select c2 from cfc_vindex_col where c1 like 'A%'", "Instructions": { @@ -2705,6 +2778,7 @@ "comment": "select * from samecolvin where col = :col", "query": "select * from samecolvin where col = :col", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from samecolvin where col = :col", "Instructions": { @@ -2726,12 +2800,13 @@ "user.samecolvin" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "non unique predicate on vindex", "query": "select id from user where user.id > 5", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user where user.id > 5", "Instructions": { @@ -2754,6 +2829,7 @@ "comment": "select from unsharded keyspace with uncorrelated subquery which should be merged to a single route", "query": "select unsharded.id from unsharded where unsharded.name in (select name from unsharded_a)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select unsharded.id from unsharded where unsharded.name in (select name from unsharded_a)", "Instructions": { @@ -2777,6 +2853,7 @@ "comment": "in subquery the id will be scoped to local table as there is no qualifier associated with it.", "query": "select id from user where id in (select col from unsharded where col = id)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id in (select col from unsharded where col = id)", "Instructions": { @@ -2827,6 +2904,7 @@ "comment": "correlated subquery with same keyspace", "query": "select u.id from user as u where u.col in (select ue.user_id from user_extra as ue where ue.user_id = u.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select u.id from user as u where u.col in (select ue.user_id from user_extra as ue where ue.user_id = u.id)", "Instructions": { @@ -2845,12 +2923,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "SelectDBA with uncorrelated subqueries", "query": "select t.table_schema from information_schema.tables as t where t.table_schema in (select c.column_name from information_schema.columns as c)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t.table_schema from information_schema.tables as t where t.table_schema in (select c.column_name from information_schema.columns as c)", "Instructions": { @@ -2871,6 +2950,7 @@ "comment": "SelectReference with uncorrelated subqueries", "query": "select ref.col from ref where ref.col in (select ref.col from ref)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select ref.col from ref where ref.col in (select ref.col from ref)", "Instructions": { @@ -2893,6 +2973,7 @@ "comment": "SelectEqualUnique with uncorrelated subqueries", "query": "select u1.col from user as u1 where u1.id = 5 and u1.name in (select u2.name from user u2 where u2.id = 5)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u1.col from user as u1 where u1.id = 5 and u1.name in (select u2.name from user u2 where u2.id = 5)", "Instructions": { @@ -2919,6 +3000,7 @@ "comment": "SelectEqualUnique with EXISTS uncorrelated subquery", "query": "select u1.col from user as u1 where u1.id = 5 and exists (select u2.name from user u2 where u2.id = 5)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u1.col from user as u1 where u1.id = 5 and exists (select u2.name from user u2 where u2.id = 5)", "Instructions": { @@ -2945,6 +3027,7 @@ "comment": "SelectEqualUnique with NOT EXISTS uncorrelated subquery", "query": "select u1.col from user as u1 where u1.id = 5 and not exists (select u2.name from user u2 where u2.id = 5)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u1.col from user as u1 where u1.id = 5 and not exists (select u2.name from user u2 where u2.id = 5)", "Instructions": { @@ -2971,6 +3054,7 @@ "comment": "SelectScatter with NOT EXISTS uncorrelated subquery", "query": "select u1.col from user as u1 where not exists (select u2.name from user u2 where u2.id = 5)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u1.col from user as u1 where not exists (select u2.name from user u2 where u2.id = 5)", "Instructions": { @@ -3019,6 +3103,7 @@ "comment": "The outer and first inner are SelectEqualUnique with same Vindex value, the second inner has different Vindex value", "query": "select id from user where id = 5 and not id in (select user_extra.col from user_extra where user_extra.user_id = 5) and id in (select user_extra.col from user_extra where user_extra.user_id = 4)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id = 5 and not id in (select user_extra.col from user_extra where user_extra.user_id = 5) and id in (select user_extra.col from user_extra where user_extra.user_id = 4)", "Instructions": { @@ -3068,12 +3153,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "The outer and second inner are SelectEqualUnique with same Vindex value, the first inner has different Vindex value", "query": "select id from user where id = 5 and not id in (select user_extra.col from user_extra where user_extra.user_id = 4) and id in (select user_extra.col from user_extra where user_extra.user_id = 5)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id = 5 and not id in (select user_extra.col from user_extra where user_extra.user_id = 4) and id in (select user_extra.col from user_extra where user_extra.user_id = 5)", "Instructions": { @@ -3123,12 +3209,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "two correlated subqueries that can be merge in a single route", "query": "select u.id from user as u where u.col in (select ue.user_id from user_extra as ue where ue.user_id = u.id) and u.col2 in (select ue.user_id from user_extra as ue where ue.user_id = u.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select u.id from user as u where u.col in (select ue.user_id from user_extra as ue where ue.user_id = u.id) and u.col2 in (select ue.user_id from user_extra as ue where ue.user_id = u.id)", "Instructions": { @@ -3147,12 +3234,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "transitive closures for the win", "query": "select id from user where user.id = user.col and user.col = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where user.id = user.col and user.col = 5", "Instructions": { @@ -3179,6 +3267,7 @@ "comment": "join with transitive closures", "query": "select id from user, user_extra where user.id = user_extra.col and user_extra.col = user_extra.user_id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user, user_extra where user.id = user_extra.col and user_extra.col = user_extra.user_id", "Instructions": { @@ -3197,12 +3286,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "not supported transitive closures with equality inside of an OR", "query": "select id from user, user_extra where user.id = user_extra.col and (user_extra.col = user_extra.user_id or user_extra.col2 = user_extra.name)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select id from user, user_extra where user.id = user_extra.col and (user_extra.col = user_extra.user_id or user_extra.col2 = user_extra.name)", "Instructions": { @@ -3247,12 +3337,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "routing rules subquery merge with alias", "query": "select col from user where id = (select id from route1 as a where a.id = user.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from user where id = (select id from route1 as a where a.id = user.id)", "Instructions": { @@ -3270,12 +3361,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "left join where clauses where we can optimize into an inner join", "query": "select user.id from user left join user_extra on user.col = user_extra.col where user_extra.foobar = 5", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.id from user left join user_extra on user.col = user_extra.col where user_extra.foobar = 5", "Instructions": { @@ -3316,18 +3408,19 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "this query lead to a nil pointer error", "query": "select user.id from user left join user_extra on user.col = user_extra.col where foo(user_extra.foobar)", "plan": "expr cannot be translated, not supported: foo(user_extra.foobar)", - "skip_e2e" :true + "skip_e2e": true }, { "comment": "filter after outer join", "query": "select user.id from user left join user_extra on user.col = user_extra.col where user_extra.id is null", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.id from user left join user_extra on user.col = user_extra.col where user_extra.id is null", "Instructions": { @@ -3375,12 +3468,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "subquery on other table", "query": "select distinct user.id, user.col from user where user.col in (select id from music where col2 = 'a')", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct user.id, user.col from user where user.col in (select id from music where col2 = 'a')", "Instructions": { @@ -3437,6 +3531,7 @@ "comment": "should use colb_colc_map as first column of the vindex is present in predicate", "query": "select * from multicolvin where column_b = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from multicolvin where column_b = 1", "Instructions": { @@ -3488,6 +3583,7 @@ "comment": "should only use first column of the vindex colb_colc_map", "query": "select * from multicolvin where column_b = 1 and column_c = 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from multicolvin where column_b = 1 and column_c = 2", "Instructions": { @@ -3539,6 +3635,7 @@ "comment": "uses vindex colb_colc_map", "query": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from multicolvin where column_b = 1 and column_c = 2 and column_a = 3", "Instructions": { @@ -3590,6 +3687,7 @@ "comment": "colb_colc_map vindex for routing", "query": "select * from multicolvin where column_a = 3 and column_b = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from multicolvin where column_a = 3 and column_b = 1", "Instructions": { @@ -3641,6 +3739,7 @@ "comment": "multi column vindex produces Equal plan", "query": "select * from multicol_tbl where cola = 1 and colb = 2", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from multicol_tbl where cola = 1 and colb = 2", "Instructions": { @@ -3668,6 +3767,7 @@ "comment": "multi column vindex with different order places the vindex keys in correct order", "query": "select * from multicol_tbl where colb = 2 and cola = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from multicol_tbl where colb = 2 and cola = 1", "Instructions": { @@ -3695,6 +3795,7 @@ "comment": "multi column vindex produces IN plan", "query": "select * from multicol_tbl where cola in (1,2) and colb in (3,4)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where cola in (1,2) and colb in (3,4)", "Instructions": { @@ -3722,6 +3823,7 @@ "comment": "multi column vindex with different order places the vindex keys in correct order in IN plan", "query": "select * from multicol_tbl where colb in (3,4) and cola in (1,2)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where colb in (3,4) and cola in (1,2)", "Instructions": { @@ -3749,6 +3851,7 @@ "comment": "multi column vindex with different order with one IN predicate and one equality", "query": "select * from multicol_tbl where colb = 1 and cola in (3,4)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where colb = 1 and cola in (3,4)", "Instructions": { @@ -3776,6 +3879,7 @@ "comment": "deconstruct tuple equality comparisons", "query": "select id from user where (id, name) = (34, 'apa')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where (id, name) = (34, 'apa')", "Instructions": { @@ -3802,6 +3906,7 @@ "comment": "multi column vindex with both IN predicate and equality predicate", "query": "select * from multicol_tbl where cola in (1,10) and cola = 4 and colb in (5,6) and colb = 7", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from multicol_tbl where cola in (1,10) and cola = 4 and colb in (5,6) and colb = 7", "Instructions": { @@ -3829,6 +3934,7 @@ "comment": "multi column vindex with one column with equal followed by IN predicate, ordering matters for now", "query": "select * from multicol_tbl where colb = 4 and colb in (1,10) and cola in (5,6)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where colb = 4 and colb in (1,10) and cola in (5,6)", "Instructions": { @@ -3856,6 +3962,7 @@ "comment": "multi column vindex with one column with IN followed by equal predicate, ordering matters for now", "query": "select * from multicol_tbl where colb in (1,10) and colb = 4 and cola in (5,6)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where colb in (1,10) and colb = 4 and cola in (5,6)", "Instructions": { @@ -3883,6 +3990,7 @@ "comment": "multi column vindex with better plan selection", "query": "select * from multicol_tbl where colb in (1,2) and cola IN (3,4) and cola = 5 and colb = 6", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from multicol_tbl where colb in (1,2) and cola IN (3,4) and cola = 5 and colb = 6", "Instructions": { @@ -3910,6 +4018,7 @@ "comment": "multi column vindex as tuple", "query": "select * from multicol_tbl where (cola,colb) in ((1,2),(3,4))", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where (cola,colb) in ((1,2),(3,4))", "Instructions": { @@ -3937,6 +4046,7 @@ "comment": "multi column vindex, partial vindex with SelectEqual", "query": "select * from multicol_tbl where cola = 1", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where cola = 1", "Instructions": { @@ -3963,6 +4073,7 @@ "comment": "multi column vindex, partial vindex with SelectEqual over full vindex with SelectIN", "query": "select * from multicol_tbl where cola = 1 and colb in (2,3)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select * from multicol_tbl where cola = 1 and colb in (2,3)", "Instructions": { @@ -3990,6 +4101,7 @@ "comment": "left join with where clause", "query": "select 0 from unsharded_a left join unsharded_b on unsharded_a.col = unsharded_b.col where coalesce(unsharded_b.col, 4) = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select 0 from unsharded_a left join unsharded_b on unsharded_a.col = unsharded_b.col where coalesce(unsharded_b.col, 4) = 5", "Instructions": { @@ -4013,6 +4125,7 @@ "comment": "filter on outer join should not be used for routing", "query": "select user.col from user_extra left outer join user on user_extra.user_id = user.id WHERE user.id IS NULL", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user_extra left outer join user on user_extra.user_id = user.id WHERE user.id IS NULL", "Instructions": { @@ -4031,12 +4144,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "conditions following a null safe comparison operator can be used for routing", "query": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE user.id <=> NULL AND music.user_id = 10", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE user.id <=> NULL AND music.user_id = 10", "Instructions": { @@ -4064,6 +4178,7 @@ "comment": "For left joins, where conditions using both sides of the join are not pulled into the join conditions", "query": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE (user.name = 'Trent Reznor' OR music.genre = 'pop') AND music.user_id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE (user.name = 'Trent Reznor' OR music.genre = 'pop') AND music.user_id = 5", "Instructions": { @@ -4091,6 +4206,7 @@ "comment": "For left joins, where conditions using both sides of the join are not pulled into the join conditions (swapped order)", "query": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE music.user_id = 5 AND (user.name = 'Trent Reznor' OR music.genre = 'pop')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE music.user_id = 5 AND (user.name = 'Trent Reznor' OR music.genre = 'pop')", "Instructions": { @@ -4118,6 +4234,7 @@ "comment": "For left joins, null intolerant where conditions using both sides of the join are transformed to inner joins", "query": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE music.user_id = 5 AND music.componist = user.name", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music LEFT OUTER JOIN user ON music.user_id = user.id WHERE music.user_id = 5 AND music.componist = user.name", "Instructions": { @@ -4145,6 +4262,7 @@ "comment": "For left joins, null intolerant where conditions using `IS NOT NULL` allow outer join simplification", "query": "SELECT music.id FROM music LEFT OUTER JOIN user ON user.id = music.user_id WHERE music.user_id = 5 AND user.id IS NOT NULL", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music LEFT OUTER JOIN user ON user.id = music.user_id WHERE music.user_id = 5 AND user.id IS NOT NULL", "Instructions": { @@ -4172,6 +4290,7 @@ "comment": "optimize ORs to IN route op codes #1", "query": "select col from user where id = 1 or id = 2", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select col from user where id = 1 or id = 2", "Instructions": { @@ -4198,6 +4317,7 @@ "comment": "optimize ORs to IN route op codes #2", "query": "select col from user where id = 1 or id = 2 or id = 3", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select col from user where id = 1 or id = 2 or id = 3", "Instructions": { @@ -4224,6 +4344,7 @@ "comment": "optimize ORs to IN route op codes #3", "query": "select col from user where (id = 1 or id = 2) or (id = 3 or id = 4)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select col from user where (id = 1 or id = 2) or (id = 3 or id = 4)", "Instructions": { @@ -4250,6 +4371,7 @@ "comment": "Don't pick a vindex for an IS NULL predicate if it's a lookup vindex", "query": "select id from music where id is null and user_id in (1,2)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select id from music where id is null and user_id in (1,2)", "Instructions": { @@ -4276,6 +4398,7 @@ "comment": "Self referencing columns in HAVING should work", "query": "select a+2 as a from user having a = 42", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select a+2 as a from user having a = 42", "Instructions": { @@ -4298,6 +4421,7 @@ "comment": "Order by aliases are expanded", "query": "select a+2 as a from user order by a", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select a+2 as a from user order by a", "Instructions": { @@ -4322,6 +4446,7 @@ "comment": "HAVING predicates that use table columns are safe to rewrite if we can move them to the WHERE clause", "query": "select user.col + 2 as a from user having a = 42", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col + 2 as a from user having a = 42", "Instructions": { @@ -4344,6 +4469,7 @@ "comment": "HAVING predicates that use table columns should not get rewritten on unsharded keyspaces", "query": "select col + 2 as a from unsharded having a = 42", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col + 2 as a from unsharded having a = 42", "Instructions": { @@ -4366,6 +4492,7 @@ "comment": "Single table unique vindex route hiding behind a silly OR", "query": "select id from user where (id = 5 and name ='apa') or (id = 5 and foo = 'bar')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from user where (id = 5 and name ='apa') or (id = 5 and foo = 'bar')", "Instructions": { @@ -4392,6 +4519,7 @@ "comment": "Single table IN vindex route hiding behind OR", "query": "select id from user where (id = 5 and name ='foo') or (id = 12 and name = 'bar')", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select id from user where (id = 5 and name ='foo') or (id = 12 and name = 'bar')", "Instructions": { @@ -4418,6 +4546,7 @@ "comment": "Like clause evaluated on the vtgate", "query": "select a.textcol1 from user a join user b where a.textcol1 = b.textcol2 group by a.textcol1 having repeat(a.textcol1,sum(a.id)) like \"And%res\"", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a.textcol1 from user a join user b where a.textcol1 = b.textcol2 group by a.textcol1 having repeat(a.textcol1,sum(a.id)) like \"And%res\"", "Instructions": { @@ -4482,12 +4611,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "two predicates that mean the same thing", "query": "select textcol1 from user where foo = 42 and user.foo = 42", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select textcol1 from user where foo = 42 and user.foo = 42", "Instructions": { @@ -4510,6 +4640,7 @@ "comment": "must merge subquery with the right side of the join", "query": "select 1 from unsharded join user u1 where exists (select 1 from unsharded u2 where u1.bar = u2.baz)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select 1 from unsharded join user u1 where exists (select 1 from unsharded u2 where u1.bar = u2.baz)", "Instructions": { @@ -4575,6 +4706,7 @@ "comment": "push filter under aggregation", "query": "select count(*) from user left join user_extra on user.id = user_extra.bar where IFNULL(user_extra.collections_status, 'NOTSET') != 'collections_lock'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user left join user_extra on user.id = user_extra.bar where IFNULL(user_extra.collections_status, 'NOTSET') != 'collections_lock'", "Instructions": { @@ -4638,12 +4770,13 @@ "user.user_extra" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "query that would time out because planning was too slow", "query": "select 1 from user where shard_key = 1 and is_removed = 1 and cmd in ('A','B','C') and not (user_id = 1 and user_id is not null and ts >= 1 and ts <= 2) and not (user_id = 1 and user_id is not null and ts >= 12 and ts <= 13) and not (user_id = 1 and user_id is not null and ts >= 14 and ts <= 15) and not (user_id = 1 and user_id is not null and ts >= 16 and ts <= 17) and not (user_id = 1 and user_id is not null and ts >= 18 and ts <= 19) and not (user_id = 1 and user_id is not null and ts >= 110 and ts <= 111) and not (user_id = 1 and user_id is not null and ts >= 112 and ts <= 113) and not (user_id = 1 and user_id is not null and ts >= 114 and ts <= 115) and not (user_id = 1 and user_id is not null and ts >= 116 and ts <= 117) and not (user_id = 1 and user_id is not null and ts >= 118 and ts <= 119) and not (user_id = 1 and user_id is not null and ts >= 120 and ts <= 121) and not (user_id = 1 and user_id is not null and ts >= 122 and ts <= 123) and not (user_id = 1 and user_id is not null and ts >= 124 and ts <= 125) and not (user_id = 1 and user_id is not null and ts >= 126 and ts <= 127) and not (user_id = 1 and user_id is not null and ts >= 128 and ts <= 129) and not (user_id = 1 and user_id is not null and ts >= 130 and ts <= 131) and not (user_id = 1 and user_id is not null and ts >= 132 and ts <= 133) and not (user_id = 1 and user_id is not null and ts >= 134 and ts <= 135) and not (user_id = 1 and user_id is not null and ts >= 136 and ts <= 137) and not (user_id = 1 and user_id is not null and ts >= 138 and ts <= 139) and not (user_id = 1 and user_id is not null and ts >= 140 and ts <= 141) and not (user_id = 1 and user_id is not null and ts >= 142 and ts <= 143) and not (user_id = 1 and user_id is not null and ts >= 144 and ts <= 145) and not (user_id = 1 and user_id is not null and ts >= 146 and ts <= 147) and not (user_id = 1 and user_id is not null and ts >= 148 and ts <= 149) and not (user_id = 1 and user_id is not null and ts >= 150 and ts <= 151) and not (user_id = 1 and user_id is not null and ts >= 152 and ts <= 153) and not (user_id = 1 and user_id is not null and ts >= 154 and ts <= 155) and not (user_id = 1 and user_id is not null and ts >= 156 and ts <= 157) and not (user_id = 1 and user_id is not null and ts >= 158 and ts <= 159) and not (user_id = 1 and user_id is not null and ts >= 160 and ts <= 161) and not (user_id = 1 and user_id is not null and ts >= 162 and ts <= 163) and not (user_id = 1 and user_id is not null and ts >= 164 and ts <= 165) and not (user_id = 1 and user_id is not null and ts >= 166 and ts <= 167) and not (user_id = 1 and user_id is not null and ts >= 168 and ts <= 169) and not (user_id = 1 and user_id is not null and ts >= 170 and ts <= 171) and not (user_id = 1 and user_id is not null and ts >= 172 and ts <= 173) and not (user_id = 1 and user_id is not null and ts >= 174 and ts <= 175) and not (user_id = 1 and user_id is not null and ts >= 176 and ts <= 177) and not (user_id = 1 and user_id is not null and ts >= 178 and ts <= 179) and not (user_id = 1 and user_id is not null and ts >= 180 and ts <= 181) and not (user_id = 1 and user_id is not null and ts >= 182 and ts <= 183) and not (user_id = 1 and user_id is not null and ts >= 184 and ts <= 185) and not (user_id = 1 and user_id is not null and ts >= 186 and ts <= 187) and not (user_id = 1 and user_id is not null and ts >= 188 and ts <= 189) and not (user_id = 1 and user_id is not null and ts >= 190 and ts <= 191) and not (user_id = 1 and user_id is not null and ts >= 192 and ts <= 193) and not (user_id = 1 and user_id is not null and ts >= 194 and ts <= 195) and not (user_id = 1 and user_id is not null and ts >= 196 and ts <= 197) and not (user_id = 1 and user_id is not null and ts >= 198 and ts <= 199) and not (user_id = 1 and user_id is not null and ts >= 1100 and ts <= 1101) and not (user_id = 1 and user_id is not null and ts >= 1102 and ts <= 1103) and not (user_id = 1 and user_id is not null and ts >= 1104 and ts <= 1105) and not (user_id = 1 and user_id is not null and ts >= 1106 and ts <= 1107) and not (user_id = 1 and user_id is not null and ts >= 1108 and ts <= 1109) and not (user_id = 1 and user_id is not null and ts >= 1110 and ts <= 1111) and not (user_id = 1 and user_id is not null and ts >= 1112 and ts <= 1113) and not (user_id = 1 and user_id is not null and ts >= 1114 and ts <= 1115) and not (user_id = 1 and user_id is not null and ts >= 1116 and ts <= 1117) and not (user_id = 1 and user_id is not null and ts >= 1118 and ts <= 1119) and not (user_id = 1 and user_id is not null and ts >= 1120 and ts <= 1121) and not (user_id = 1 and user_id is not null and ts >= 1122 and ts <= 1123) and not (user_id = 1 and user_id is not null and ts >= 1124 and ts <= 1125) and not (user_id = 1 and user_id is not null and ts >= 1126 and ts <= 1127) and not (user_id = 1 and user_id is not null and ts >= 1128 and ts <= 1129) and not (user_id = 1 and user_id is not null and ts >= 1130 and ts <= 1131) and not (user_id = 1 and user_id is not null and ts >= 1132 and ts <= 1133) and not (user_id = 1 and user_id is not null and ts >= 1134 and ts <= 1135) and not (user_id = 1 and user_id is not null and ts >= 1136 and ts <= 1137) and not (user_id = 1 and user_id is not null and ts >= 1138 and ts <= 1139) and not (user_id = 1 and user_id is not null and ts >= 1140 and ts <= 1141) and not (user_id = 1 and user_id is not null and ts >= 1142 and ts <= 1143) and not (user_id = 1 and user_id is not null and ts >= 1144 and ts <= 1145) and not (user_id = 1 and user_id is not null and ts >= 1146 and ts <= 1147) and not (user_id = 1 and user_id is not null and ts >= 1148 and ts <= 1149) and not (user_id = 1 and user_id is not null and ts >= 1150 and ts <= 1151) and not (user_id = 1 and user_id is not null and ts >= 1152 and ts <= 1153) and not (user_id = 1 and user_id is not null and ts >= 1154 and ts <= 1155) and not (user_id = 1 and user_id is not null and ts >= 1156 and ts <= 1157) and not (user_id = 1 and user_id is not null and ts >= 1158 and ts <= 1159) and not (user_id = 1 and user_id is not null and ts >= 1160 and ts <= 1161) and not (user_id = 1 and user_id is not null and ts >= 1162 and ts <= 1163) and not (user_id = 1 and user_id is not null and ts >= 1164 and ts <= 1165) and not (user_id = 1 and user_id is not null and ts >= 1166 and ts <= 1167) and not (user_id = 1 and user_id is not null and ts >= 1168 and ts <= 1169) and not (user_id = 1 and user_id is not null and ts >= 1170 and ts <= 1171) and not (user_id = 1 and user_id is not null and ts >= 1172 and ts <= 1173) and not (user_id = 1 and user_id is not null and ts >= 1174 and ts <= 1175) and not (user_id = 1 and user_id is not null and ts >= 1176 and ts <= 1177) and not (user_id = 1 and user_id is not null and ts >= 1178 and ts <= 1179) and not (user_id = 1 and user_id is not null and ts >= 1180 and ts <= 1181) and not (user_id = 1 and user_id is not null and ts >= 1182 and ts <= 1183) and not (user_id = 1 and user_id is not null and ts >= 1184 and ts <= 1185) and not (user_id = 1 and user_id is not null and ts >= 1186 and ts <= 1187) and not (user_id = 1 and user_id is not null and ts >= 1188 and ts <= 1189) and not (user_id = 1 and user_id is not null and ts >= 1190 and ts <= 1191) and not (user_id = 1 and user_id is not null and ts >= 1192 and ts <= 1193) and not (user_id = 1 and user_id is not null and ts >= 1194 and ts <= 1195) and not (user_id = 1 and user_id is not null and ts >= 1196 and ts <= 1197) and not (user_id = 1 and user_id is not null and ts >= 1198 and ts <= 1199) and not (user_id = 1 and user_id is not null and ts >= 1200 and ts <= 1201) and not (user_id = 1 and user_id is not null and ts >= 1202 and ts <= 1203) and not (user_id = 1 and user_id is not null and ts >= 1204 and ts <= 1205) and not (user_id = 1 and user_id is not null and ts >= 1206 and ts <= 1207) and not (user_id = 1 and user_id is not null and ts >= 1208 and ts <= 1209) and not (user_id = 1 and user_id is not null and ts >= 1210 and ts <= 1211) and not (user_id = 1 and user_id is not null and ts >= 1212 and ts <= 1213) and not (user_id = 1 and user_id is not null and ts >= 1214 and ts <= 1215) and not (user_id = 1 and user_id is not null and ts >= 1216 and ts <= 1217) and not (user_id = 1 and user_id is not null and ts >= 1218 and ts <= 1219) and not (user_id = 1 and user_id is not null and ts >= 1220 and ts <= 1221) and not (user_id = 1 and user_id is not null and ts >= 1222 and ts <= 1223) and not (user_id = 1 and user_id is not null and ts >= 1224 and ts <= 1225) and not (user_id = 1 and user_id is not null and ts >= 1226 and ts <= 1227) and not (user_id = 1 and user_id is not null and ts >= 1228 and ts <= 1229) and not (user_id = 1 and user_id is not null and ts >= 1230 and ts <= 1231) and not (user_id = 1 and user_id is not null and ts >= 1232 and ts <= 1233) and not (user_id = 1 and user_id is not null and ts >= 1234 and ts <= 1235) and not (user_id = 1 and user_id is not null and ts >= 1236 and ts <= 1237) and not (user_id = 1 and user_id is not null and ts >= 1238 and ts <= 1239) and not (user_id = 1 and user_id is not null and ts >= 1240 and ts <= 1241) and not (user_id = 1 and user_id is not null and ts >= 1242 and ts <= 1243) and not (user_id = 1 and user_id is not null and ts >= 1244 and ts <= 1245) and not (user_id = 1 and user_id is not null and ts >= 1246 and ts <= 1247) and not (user_id = 1 and user_id is not null and ts >= 1248 and ts <= 1249) and not (user_id = 1 and user_id is not null and ts >= 1250 and ts <= 1251) and not (user_id = 1 and user_id is not null and ts >= 1252 and ts <= 1253) and not (user_id = 1 and user_id is not null and ts >= 1254 and ts <= 1255) and not (user_id = 1 and user_id is not null and ts >= 1256 and ts <= 1257) and not (user_id = 1 and user_id is not null and ts >= 1258 and ts <= 1259) and not (user_id = 1 and user_id is not null and ts >= 1260 and ts <= 1261) and not (user_id = 1 and user_id is not null and ts >= 1262 and ts <= 1263) and not (user_id = 1 and user_id is not null and ts >= 1264 and ts <= 1265) and not (user_id = 1 and user_id is not null and ts >= 1266 and ts <= 1267) and not (user_id = 1 and user_id is not null and ts >= 1268 and ts <= 1269) and not (user_id = 1 and user_id is not null and ts >= 1270 and ts <= 1271) and not (user_id = 1 and user_id is not null and ts >= 1272 and ts <= 1273) and not (user_id = 1 and user_id is not null and ts >= 1274 and ts <= 1275) and not (user_id = 1 and user_id is not null and ts >= 1276 and ts <= 1277) and not (user_id = 1 and user_id is not null and ts >= 1278 and ts <= 1279) and not (user_id = 1 and user_id is not null and ts >= 1280 and ts <= 1281) and not (user_id = 1 and user_id is not null and ts >= 1282 and ts <= 1283) and not (user_id = 1 and user_id is not null and ts >= 1284 and ts <= 1285) and not (user_id = 1 and user_id is not null and ts >= 1286 and ts <= 1287) and not (user_id = 1 and user_id is not null and ts >= 1288 and ts <= 1289) and not (user_id = 1 and user_id is not null and ts >= 1290 and ts <= 1291) and not (user_id = 1 and user_id is not null and ts >= 1292 and ts <= 1293) and not (user_id = 1 and user_id is not null and ts >= 1294 and ts <= 1295) and not (user_id = 1 and user_id is not null and ts >= 1296 and ts <= 1297) and not (user_id = 1 and user_id is not null and ts >= 1298 and ts <= 1299) and not (user_id = 1 and user_id is not null and ts >= 1300 and ts <= 1301) and not (user_id = 1 and user_id is not null and ts >= 1302 and ts <= 1303) and not (user_id = 1 and user_id is not null and ts >= 1304 and ts <= 1305) and not (user_id = 1 and user_id is not null and ts >= 1306 and ts <= 1307) and not (user_id = 1 and user_id is not null and ts >= 1308 and ts <= 1309) and not (user_id = 1 and user_id is not null and ts >= 1310 and ts <= 1311) and not (user_id = 1 and user_id is not null and ts >= 1312 and ts <= 1313) and not (user_id = 1 and user_id is not null and ts >= 1314 and ts <= 1315) and not (user_id = 1 and user_id is not null and ts >= 1316 and ts <= 1317) and not (user_id = 1 and user_id is not null and ts >= 1318 and ts <= 1319) and not (user_id = 1 and user_id is not null and ts >= 1320 and ts <= 1321) and not (user_id = 1 and user_id is not null and ts >= 1322 and ts <= 1323) and not (user_id = 1 and user_id is not null and ts >= 1324 and ts <= 1325) and not (user_id = 1 and user_id is not null and ts >= 1326 and ts <= 1327) and not (user_id = 1 and user_id is not null and ts >= 1328 and ts <= 1329) and not (user_id = 1 and user_id is not null and ts >= 1330 and ts <= 1331) and not (user_id = 1 and user_id is not null and ts >= 1332 and ts <= 1333) and not (user_id = 1 and user_id is not null and ts >= 1334 and ts <= 1335) and not (user_id = 1 and user_id is not null and ts >= 1336 and ts <= 1337) and not (user_id = 1 and user_id is not null and ts >= 1338 and ts <= 1339) and not (user_id = 1 and user_id is not null and ts >= 1340 and ts <= 1341) and not (user_id = 1 and user_id is not null and ts >= 1342 and ts <= 1343) and not (user_id = 1 and user_id is not null and ts >= 1344 and ts <= 1345) and not (user_id = 1 and user_id is not null and ts >= 1346 and ts <= 1347) and not (user_id = 1 and user_id is not null and ts >= 1348 and ts <= 1349) and not (user_id = 1 and user_id is not null and ts >= 1350 and ts <= 1351) and not (user_id = 1 and user_id is not null and ts >= 1352 and ts <= 1353) and not (user_id = 1 and user_id is not null and ts >= 1354 and ts <= 1355) and not (user_id = 1 and user_id is not null and ts >= 1356 and ts <= 1357) and not (user_id = 1 and user_id is not null and ts >= 1358 and ts <= 1359) and not (user_id = 1 and user_id is not null and ts >= 1360 and ts <= 1361) and not (user_id = 1 and user_id is not null and ts >= 1362 and ts <= 1363) and not (user_id = 1 and user_id is not null and ts >= 1364 and ts <= 1365) and not (user_id = 1 and user_id is not null and ts >= 1366 and ts <= 1367) and not (user_id = 1 and user_id is not null and ts >= 1368 and ts <= 1369) and not (user_id = 1 and user_id is not null and ts >= 1370 and ts <= 1371) and not (user_id = 1 and user_id is not null and ts >= 1372 and ts <= 1373) and not (user_id = 1 and user_id is not null and ts >= 1374 and ts <= 1375) and not (user_id = 1 and user_id is not null and ts >= 1376 and ts <= 1377) and not (user_id = 1 and user_id is not null and ts >= 1378 and ts <= 1379) and not (user_id = 1 and user_id is not null and ts >= 1380 and ts <= 1381) and not (user_id = 1 and user_id is not null and ts >= 1382 and ts <= 1383) and not (user_id = 1 and user_id is not null and ts >= 1384 and ts <= 1385) and not (user_id = 1 and user_id is not null and ts >= 1386 and ts <= 1387) and not (user_id = 1 and user_id is not null and ts >= 1388 and ts <= 1389) and not (user_id = 1 and user_id is not null and ts >= 1390 and ts <= 1391) and not (user_id = 1 and user_id is not null and ts >= 1392 and ts <= 1393) and not (user_id = 1 and user_id is not null and ts >= 1394 and ts <= 1395) and not (user_id = 1 and user_id is not null and ts >= 1396 and ts <= 1397) and not (user_id = 1 and user_id is not null and ts >= 1398 and ts <= 1399) and not (user_id = 1 and user_id is not null and ts >= 1400 and ts <= 1401) and not (user_id = 1 and user_id is not null and ts >= 1402 and ts <= 1403) and not (user_id = 1 and user_id is not null and ts >= 1404 and ts <= 1405) and not (user_id = 1 and user_id is not null and ts >= 1406 and ts <= 1407) and not (user_id = 1 and user_id is not null and ts >= 1408 and ts <= 1409) and not (user_id = 1 and user_id is not null and ts >= 1410 and ts <= 1411) and not (user_id = 1 and user_id is not null and ts >= 1412 and ts <= 1413) and not (user_id = 1 and user_id is not null and ts >= 1414 and ts <= 1415) and not (user_id = 1 and user_id is not null and ts >= 1416 and ts <= 1417) and not (user_id = 1 and user_id is not null and ts >= 1418 and ts <= 1419) and not (user_id = 1 and user_id is not null and ts >= 1420 and ts <= 1421) and not (user_id = 1 and user_id is not null and ts >= 1422 and ts <= 1423) and not (user_id = 1 and user_id is not null and ts >= 1424 and ts <= 1425) and not (user_id = 1 and user_id is not null and ts >= 1426 and ts <= 1427) and not (user_id = 1 and user_id is not null and ts >= 1428 and ts <= 1429) and not (user_id = 1 and user_id is not null and ts >= 1430 and ts <= 1431) and not (user_id = 1 and user_id is not null and ts >= 1432 and ts <= 1433) and not (user_id = 1 and user_id is not null and ts >= 1434 and ts <= 1435) and not (user_id = 1 and user_id is not null and ts >= 1436 and ts <= 1437) and not (user_id = 1 and user_id is not null and ts >= 1438 and ts <= 1439) and not (user_id = 1 and user_id is not null and ts >= 1440 and ts <= 1441) and not (user_id = 1 and user_id is not null and ts >= 1442 and ts <= 1443) and not (user_id = 1 and user_id is not null and ts >= 1444 and ts <= 1445) and not (user_id = 1 and user_id is not null and ts >= 1446 and ts <= 1447) and not (user_id = 1 and user_id is not null and ts >= 1448 and ts <= 1449) and not (user_id = 1 and user_id is not null and ts >= 1450 and ts <= 1451) and not (user_id = 1 and user_id is not null and ts >= 1452 and ts <= 1453) and not (user_id = 1 and user_id is not null and ts >= 1454 and ts <= 1455) and not (user_id = 1 and user_id is not null and ts >= 1456 and ts <= 1457) and not (user_id = 1 and user_id is not null and ts >= 1458 and ts <= 1459) and not (user_id = 1 and user_id is not null and ts >= 1460 and ts <= 1461) and not (user_id = 1 and user_id is not null and ts >= 1462 and ts <= 1463) and not (user_id = 1 and user_id is not null and ts >= 1464 and ts <= 1465) and not (user_id = 1 and user_id is not null and ts >= 1466 and ts <= 1467) and not (user_id = 1 and user_id is not null and ts >= 1468 and ts <= 1469) and not (user_id = 1 and user_id is not null and ts >= 1470 and ts <= 1471) and not (user_id = 1 and user_id is not null and ts >= 1472 and ts <= 1473) and not (user_id = 1 and user_id is not null and ts >= 1474 and ts <= 1475) and not (user_id = 1 and user_id is not null and ts >= 1476 and ts <= 1477) and not (user_id = 1 and user_id is not null and ts >= 1478 and ts <= 1479) and not (user_id = 1 and user_id is not null and ts >= 1480 and ts <= 1481) and not (user_id = 1 and user_id is not null and ts >= 1482 and ts <= 1483) and not (user_id = 1 and user_id is not null and ts >= 1484 and ts <= 1485) and not (user_id = 1 and user_id is not null and ts >= 1486 and ts <= 1487) and not (user_id = 1 and user_id is not null and ts >= 1488 and ts <= 1489) and not (user_id = 1 and user_id is not null and ts >= 1490 and ts <= 1491) and not (user_id = 1 and user_id is not null and ts >= 1492 and ts <= 1493) and not (user_id = 1 and user_id is not null and ts >= 1494 and ts <= 1495) and not (user_id = 1 and user_id is not null and ts >= 1496 and ts <= 1497) and not (user_id = 1 and user_id is not null and ts >= 1498 and ts <= 1499) and not (user_id = 1 and user_id is not null and ts >= 1500 and ts <= 1501) and not (user_id = 1 and user_id is not null and ts >= 1502 and ts <= 1503) and not (user_id = 1 and user_id is not null and ts >= 1504 and ts <= 1505) and not (user_id = 1 and user_id is not null and ts >= 1506 and ts <= 1507) and not (user_id = 1 and user_id is not null and ts >= 1508 and ts <= 1509) and not (user_id = 1 and user_id is not null and ts >= 1510 and ts <= 1511) and not (user_id = 1 and user_id is not null and ts >= 1512 and ts <= 1513) and not (user_id = 1 and user_id is not null and ts >= 1514 and ts <= 1515) and not (user_id = 1 and user_id is not null and ts >= 1516 and ts <= 1517) and not (user_id = 1 and user_id is not null and ts >= 1518 and ts <= 1519) and not (user_id = 1 and user_id is not null and ts >= 1520 and ts <= 1521) and not (user_id = 1 and user_id is not null and ts >= 1522 and ts <= 1523) and not (user_id = 1 and user_id is not null and ts >= 1524 and ts <= 1525) and not (user_id = 1 and user_id is not null and ts >= 1526 and ts <= 1527) and not (user_id = 1 and user_id is not null and ts >= 1528 and ts <= 1529) and not (user_id = 1 and user_id is not null and ts >= 1530 and ts <= 1531) and not (user_id = 1 and user_id is not null and ts >= 1532 and ts <= 1533) and not (user_id = 1 and user_id is not null and ts >= 1534 and ts <= 1535) and not (user_id = 1 and user_id is not null and ts >= 1536 and ts <= 1537) and not (user_id = 1 and user_id is not null and ts >= 1538 and ts <= 1539) and not (user_id = 1 and user_id is not null and ts >= 1540 and ts <= 1541) and not (user_id = 1 and user_id is not null and ts >= 1542 and ts <= 1543) and not (user_id = 1 and user_id is not null and ts >= 1544 and ts <= 1545) and not (user_id = 1 and user_id is not null and ts >= 1546 and ts <= 1547) and not (user_id = 1 and user_id is not null and ts >= 1548 and ts <= 1549) and not (user_id = 1 and user_id is not null and ts >= 1550 and ts <= 1551) and not (user_id = 1 and user_id is not null and ts >= 1552 and ts <= 1553) and not (user_id = 1 and user_id is not null and ts >= 1554 and ts <= 1555) and not (user_id = 1 and user_id is not null and ts >= 1556 and ts <= 1557) and not (user_id = 1 and user_id is not null and ts >= 1558 and ts <= 1559) and not (user_id = 1 and user_id is not null and ts >= 1560 and ts <= 1561) and not (user_id = 1 and user_id is not null and ts >= 1562 and ts <= 1563) and not (user_id = 1 and user_id is not null and ts >= 1564 and ts <= 1565) and not (user_id = 1 and user_id is not null and ts >= 1566 and ts <= 1567) and not (user_id = 1 and user_id is not null and ts >= 1568 and ts <= 1569) and not (user_id = 1 and user_id is not null and ts >= 1570 and ts <= 1571) and not (user_id = 1 and user_id is not null and ts >= 1572 and ts <= 1573) and not (user_id = 1 and user_id is not null and ts >= 1574 and ts <= 1575) and not (user_id = 1 and user_id is not null and ts >= 1576 and ts <= 1577) and not (user_id = 1 and user_id is not null and ts >= 1578 and ts <= 1579) and not (user_id = 1 and user_id is not null and ts >= 1580 and ts <= 1581) and not (user_id = 1 and user_id is not null and ts >= 1582 and ts <= 1583) and not (user_id = 1 and user_id is not null and ts >= 1584 and ts <= 1585) and not (user_id = 1 and user_id is not null and ts >= 1586 and ts <= 1587) and not (user_id = 1 and user_id is not null and ts >= 1588 and ts <= 1589) and not (user_id = 1 and user_id is not null and ts >= 1590 and ts <= 1591) and not (user_id = 1 and user_id is not null and ts >= 1592 and ts <= 1593) and not (user_id = 1 and user_id is not null and ts >= 1594 and ts <= 1595) and not (user_id = 1 and user_id is not null and ts >= 1596 and ts <= 1597) and not (user_id = 1 and user_id is not null and ts >= 1598 and ts <= 1599) and not (user_id = 1 and user_id is not null and ts >= 1600 and ts <= 1601) and not (user_id = 1 and user_id is not null and ts >= 1602 and ts <= 1603) and not (user_id = 1 and user_id is not null and ts >= 1604 and ts <= 1605) and not (user_id = 1 and user_id is not null and ts >= 1606 and ts <= 1607) and not (user_id = 1 and user_id is not null and ts >= 1608 and ts <= 1609) and not (user_id = 1 and user_id is not null and ts >= 1610 and ts <= 1611) and not (user_id = 1 and user_id is not null and ts >= 1612 and ts <= 1613) and not (user_id = 1 and user_id is not null and ts >= 1614 and ts <= 1615) and not (user_id = 1 and user_id is not null and ts >= 1616 and ts <= 1617) and not (user_id = 1 and user_id is not null and ts >= 1618 and ts <= 1619) and not (user_id = 1 and user_id is not null and ts >= 1620 and ts <= 1621) and not (user_id = 1 and user_id is not null and ts >= 1622 and ts <= 1623) and not (user_id = 1 and user_id is not null and ts >= 1624 and ts <= 1625) and not (user_id = 1 and user_id is not null and ts >= 1626 and ts <= 1627) and not (user_id = 1 and user_id is not null and ts >= 1628 and ts <= 1629) and not (user_id = 1 and user_id is not null and ts >= 1630 and ts <= 1631) and not (user_id = 1 and user_id is not null and ts >= 1632 and ts <= 1633) and not (user_id = 1 and user_id is not null and ts >= 1634 and ts <= 1635) and not (user_id = 1 and user_id is not null and ts >= 1636 and ts <= 1637) and not (user_id = 1 and user_id is not null and ts >= 1638 and ts <= 1639) and not (user_id = 1 and user_id is not null and ts >= 1640 and ts <= 1641) and not (user_id = 1 and user_id is not null and ts >= 1642 and ts <= 1643) and not (user_id = 1 and user_id is not null and ts >= 1644 and ts <= 1645) and not (user_id = 1 and user_id is not null and ts >= 1646 and ts <= 1647) and not (user_id = 1 and user_id is not null and ts >= 1648 and ts <= 1649) and not (user_id = 1 and user_id is not null and ts >= 1650 and ts <= 1651) and not (user_id = 1 and user_id is not null and ts >= 1652 and ts <= 1653) and not (user_id = 1 and user_id is not null and ts >= 1654 and ts <= 1655) and not (user_id = 1 and user_id is not null and ts >= 1656 and ts <= 1657) and not (user_id = 1 and user_id is not null and ts >= 1658 and ts <= 1659) and not (user_id = 1 and user_id is not null and ts >= 1660 and ts <= 1661) and not (user_id = 1 and user_id is not null and ts >= 1662 and ts <= 1663) and not (user_id = 1 and user_id is not null and ts >= 1664 and ts <= 1665) and not (user_id = 1 and user_id is not null and ts >= 1666 and ts <= 1667) and not (user_id = 1 and user_id is not null and ts >= 1668 and ts <= 1669) and not (user_id = 1 and user_id is not null and ts >= 1670 and ts <= 1671) and not (user_id = 1 and user_id is not null and ts >= 1672 and ts <= 1673) and not (user_id = 1 and user_id is not null and ts >= 1674 and ts <= 1675) and not (user_id = 1 and user_id is not null and ts >= 1676 and ts <= 1677) and not (user_id = 1 and user_id is not null and ts >= 1678 and ts <= 1679) and not (user_id = 1 and user_id is not null and ts >= 1680 and ts <= 1681) and not (user_id = 1 and user_id is not null and ts >= 1682 and ts <= 1683) and not (user_id = 1 and user_id is not null and ts >= 1684 and ts <= 1685) and not (user_id = 1 and user_id is not null and ts >= 1686 and ts <= 1687) and not (user_id = 1 and user_id is not null and ts >= 1688 and ts <= 1689) and not (user_id = 1 and user_id is not null and ts >= 1690 and ts <= 1691) and not (user_id = 1 and user_id is not null and ts >= 1692 and ts <= 1693) and not (user_id = 1 and user_id is not null and ts >= 1694 and ts <= 1695) and not (user_id = 1 and user_id is not null and ts >= 1696 and ts <= 1697) and not (user_id = 1 and user_id is not null and ts >= 1698 and ts <= 1699) and not (user_id = 1 and user_id is not null and ts >= 1700 and ts <= 1701) and not (user_id = 1 and user_id is not null and ts >= 1702 and ts <= 1703) and not (user_id = 1 and user_id is not null and ts >= 1704 and ts <= 1705) and not (user_id = 1 and user_id is not null and ts >= 1706 and ts <= 1707) and not (user_id = 1 and user_id is not null and ts >= 1708 and ts <= 1709) and not (user_id = 1 and user_id is not null and ts >= 1710 and ts <= 1711) and not (user_id = 1 and user_id is not null and ts >= 1712 and ts <= 1713) and not (user_id = 1 and user_id is not null and ts >= 1714 and ts <= 1715) and not (user_id = 1 and user_id is not null and ts >= 1716 and ts <= 1717) and not (user_id = 1 and user_id is not null and ts >= 1718 and ts <= 1719) and not (user_id = 1 and user_id is not null and ts >= 1720 and ts <= 1721) and not (user_id = 1 and user_id is not null and ts >= 1722 and ts <= 1723) and not (user_id = 1 and user_id is not null and ts >= 1724 and ts <= 1725) and not (user_id = 1 and user_id is not null and ts >= 1726 and ts <= 1727) and not (user_id = 1 and user_id is not null and ts >= 1728 and ts <= 1729) and not (user_id = 1 and user_id is not null and ts >= 1730 and ts <= 1731) and not (user_id = 1 and user_id is not null and ts >= 1732 and ts <= 1733) and not (user_id = 1 and user_id is not null and ts >= 1734 and ts <= 1735) and not (user_id = 1 and user_id is not null and ts >= 1736 and ts <= 1737) and not (user_id = 1 and user_id is not null and ts >= 1738 and ts <= 1739) and not (user_id = 1 and user_id is not null and ts >= 1740 and ts <= 1741) and not (user_id = 1 and user_id is not null and ts >= 1742 and ts <= 1743) and not (user_id = 1 and user_id is not null and ts >= 1744 and ts <= 1745) and not (user_id = 1 and user_id is not null and ts >= 1746 and ts <= 1747) and not (user_id = 1 and user_id is not null and ts >= 1748 and ts <= 1749) and not (user_id = 1 and user_id is not null and ts >= 1750 and ts <= 1751) and not (user_id = 1 and user_id is not null and ts >= 1752 and ts <= 1753) and not (user_id = 1 and user_id is not null and ts >= 1754 and ts <= 1755) and not (user_id = 1 and user_id is not null and ts >= 1756 and ts <= 1757) and not (user_id = 1 and user_id is not null and ts >= 1758 and ts <= 1759) and not (user_id = 1 and user_id is not null and ts >= 1760 and ts <= 1761) and not (user_id = 1 and user_id is not null and ts >= 1762 and ts <= 1763) and not (user_id = 1 and user_id is not null and ts >= 1764 and ts <= 1765) and not (user_id = 1 and user_id is not null and ts >= 1766 and ts <= 1767) and not (user_id = 1 and user_id is not null and ts >= 1768 and ts <= 1769) and not (user_id = 1 and user_id is not null and ts >= 1770 and ts <= 1771) and not (user_id = 1 and user_id is not null and ts >= 1772 and ts <= 1773) and not (user_id = 1 and user_id is not null and ts >= 1774 and ts <= 1775) and not (user_id = 1 and user_id is not null and ts >= 1776 and ts <= 1777) and not (user_id = 1 and user_id is not null and ts >= 1778 and ts <= 1779) and not (user_id = 1 and user_id is not null and ts >= 1780 and ts <= 1781) and not (user_id = 1 and user_id is not null and ts >= 1782 and ts <= 1783) and not (user_id = 1 and user_id is not null and ts >= 1784 and ts <= 1785) and not (user_id = 1 and user_id is not null and ts >= 1786 and ts <= 1787) and not (user_id = 1 and user_id is not null and ts >= 1788 and ts <= 1789) and not (user_id = 1 and user_id is not null and ts >= 1790 and ts <= 1791) and not (user_id = 1 and user_id is not null and ts >= 1792 and ts <= 1793) and not (user_id = 1 and user_id is not null and ts >= 1794 and ts <= 1795) and not (user_id = 1 and user_id is not null and ts >= 1796 and ts <= 1797) and not (user_id = 1 and user_id is not null and ts >= 1798 and ts <= 1799) and not (user_id = 1 and user_id is not null and ts >= 1800 and ts <= 1801) and not (user_id = 1 and user_id is not null and ts >= 1802 and ts <= 1803) and not (user_id = 1 and user_id is not null and ts >= 1804 and ts <= 1805) and not (user_id = 1 and user_id is not null and ts >= 1806 and ts <= 1807) and not (user_id = 1 and user_id is not null and ts >= 1808 and ts <= 1809) and not (user_id = 1 and user_id is not null and ts >= 1810 and ts <= 1811) and not (user_id = 1 and user_id is not null and ts >= 1812 and ts <= 1813) and not (user_id = 1 and user_id is not null and ts >= 1814 and ts <= 1815) and not (user_id = 1 and user_id is not null and ts >= 1816 and ts <= 1817) and not (user_id = 1 and user_id is not null and ts >= 1818 and ts <= 1819) and not (user_id = 1 and user_id is not null and ts >= 1820 and ts <= 1821) and not (user_id = 1 and user_id is not null and ts >= 1822 and ts <= 1823) and not (user_id = 1 and user_id is not null and ts >= 1824 and ts <= 1825) and not (user_id = 1 and user_id is not null and ts >= 1826 and ts <= 1827) and not (user_id = 1 and user_id is not null and ts >= 1828 and ts <= 1829) and not (user_id = 1 and user_id is not null and ts >= 1830 and ts <= 1831) and not (user_id = 1 and user_id is not null and ts >= 1832 and ts <= 1833) and not (user_id = 1 and user_id is not null and ts >= 1834 and ts <= 1835) and not (user_id = 1 and user_id is not null and ts >= 1836 and ts <= 1837) and not (user_id = 1 and user_id is not null and ts >= 1838 and ts <= 1839) and not (user_id = 1 and user_id is not null and ts >= 1840 and ts <= 1841) and not (user_id = 1 and user_id is not null and ts >= 1842 and ts <= 1843) and not (user_id = 1 and user_id is not null and ts >= 1844 and ts <= 1845) and not (user_id = 1 and user_id is not null and ts >= 1846 and ts <= 1847) and not (user_id = 1 and user_id is not null and ts >= 1848 and ts <= 1849) and not (user_id = 1 and user_id is not null and ts >= 1850 and ts <= 1851) and not (user_id = 1 and user_id is not null and ts >= 1852 and ts <= 1853) and not (user_id = 1 and user_id is not null and ts >= 1854 and ts <= 1855) and not (user_id = 1 and user_id is not null and ts >= 1856 and ts <= 1857) and not (user_id = 1 and user_id is not null and ts >= 1858 and ts <= 1859) and not (user_id = 1 and user_id is not null and ts >= 1860 and ts <= 1861) and not (user_id = 1 and user_id is not null and ts >= 1862 and ts <= 1863) and not (user_id = 1 and user_id is not null and ts >= 1864 and ts <= 1865) and not (user_id = 1 and user_id is not null and ts >= 1866 and ts <= 1867) and not (user_id = 1 and user_id is not null and ts >= 1868 and ts <= 1869) and not (user_id = 1 and user_id is not null and ts >= 1870 and ts <= 1871) and not (user_id = 1 and user_id is not null and ts >= 1872 and ts <= 1873) and not (user_id = 1 and user_id is not null and ts >= 1874 and ts <= 1875) and not (user_id = 1 and user_id is not null and ts >= 1876 and ts <= 1877) and not (user_id = 1 and user_id is not null and ts >= 1878 and ts <= 1879) and not (user_id = 1 and user_id is not null and ts >= 1880 and ts <= 1881) and not (user_id = 1 and user_id is not null and ts >= 1882 and ts <= 1883) and not (user_id = 1 and user_id is not null and ts >= 1884 and ts <= 1885) and not (user_id = 1 and user_id is not null and ts >= 1886 and ts <= 1887) and not (user_id = 1 and user_id is not null and ts >= 1888 and ts <= 1889) and not (user_id = 1 and user_id is not null and ts >= 1890 and ts <= 1891) and not (user_id = 1 and user_id is not null and ts >= 1892 and ts <= 1893) and not (user_id = 1 and user_id is not null and ts >= 1894 and ts <= 1895) and not (user_id = 1 and user_id is not null and ts >= 1896 and ts <= 1897) and not (user_id = 1 and user_id is not null and ts >= 1898 and ts <= 1899) and not (user_id = 1 and user_id is not null and ts >= 1900 and ts <= 1901) and not (user_id = 1 and user_id is not null and ts >= 1902 and ts <= 1903) and not (user_id = 1 and user_id is not null and ts >= 1904 and ts <= 1905) and not (user_id = 1 and user_id is not null and ts >= 1906 and ts <= 1907) and not (user_id = 1 and user_id is not null and ts >= 1908 and ts <= 1909) and not (user_id = 1 and user_id is not null and ts >= 1910 and ts <= 1911) and not (user_id = 1 and user_id is not null and ts >= 1912 and ts <= 1913) and not (user_id = 1 and user_id is not null and ts >= 1914 and ts <= 1915) and not (user_id = 1 and user_id is not null and ts >= 1916 and ts <= 1917) and not (user_id = 1 and user_id is not null and ts >= 1918 and ts <= 1919) and not (user_id = 1 and user_id is not null and ts >= 1920 and ts <= 1921) and not (user_id = 1 and user_id is not null and ts >= 1922 and ts <= 1923) and not (user_id = 1 and user_id is not null and ts >= 1924 and ts <= 1925) and not (user_id = 1 and user_id is not null and ts >= 1926 and ts <= 1927) and not (user_id = 1 and user_id is not null and ts >= 1928 and ts <= 1929) and not (user_id = 1 and user_id is not null and ts >= 1930 and ts <= 1931) and not (user_id = 1 and user_id is not null and ts >= 1932 and ts <= 1933) and not (user_id = 1 and user_id is not null and ts >= 1934 and ts <= 1935) and not (user_id = 1 and user_id is not null and ts >= 1936 and ts <= 1937) and not (user_id = 1 and user_id is not null and ts >= 1938 and ts <= 1939) and not (user_id = 1 and user_id is not null and ts >= 1940 and ts <= 1941) and not (user_id = 1 and user_id is not null and ts >= 1942 and ts <= 1943) and not (user_id = 1 and user_id is not null and ts >= 1944 and ts <= 1945) and not (user_id = 1 and user_id is not null and ts >= 1946 and ts <= 1947) and not (user_id = 1 and user_id is not null and ts >= 1948 and ts <= 1949) and not (user_id = 1 and user_id is not null and ts >= 1950 and ts <= 1951) and not (user_id = 1 and user_id is not null and ts >= 1952 and ts <= 1953) and not (user_id = 1 and user_id is not null and ts >= 1954 and ts <= 1955) and not (user_id = 1 and user_id is not null and ts >= 1956 and ts <= 1957) and not (user_id = 1 and user_id is not null and ts >= 1958 and ts <= 1959) and not (user_id = 1 and user_id is not null and ts >= 1960 and ts <= 1961) and not (user_id = 1 and user_id is not null and ts >= 1962 and ts <= 1963) and not (user_id = 1 and user_id is not null and ts >= 1964 and ts <= 1965) and not (user_id = 1 and user_id is not null and ts >= 1966 and ts <= 1967) and not (user_id = 1 and user_id is not null and ts >= 1968 and ts <= 1969) and not (user_id = 1 and user_id is not null and ts >= 1970 and ts <= 1971) and not (user_id = 1 and user_id is not null and ts >= 1972 and ts <= 1973) and not (user_id = 1 and user_id is not null and ts >= 1974 and ts <= 1975) and not (user_id = 1 and user_id is not null and ts >= 1976 and ts <= 1977) and not (user_id = 1 and user_id is not null and ts >= 1978 and ts <= 1979) and not (user_id = 1 and user_id is not null and ts >= 1980 and ts <= 1981) and not (user_id = 1 and user_id is not null and ts >= 1982 and ts <= 1983) and not (user_id = 1 and user_id is not null and ts >= 1984 and ts <= 1985) and not (user_id = 1 and user_id is not null and ts >= 1986 and ts <= 1987) and not (user_id = 1 and user_id is not null and ts >= 1988 and ts <= 1989) and not (user_id = 1 and user_id is not null and ts >= 1990 and ts <= 1991) and not (user_id = 1 and user_id is not null and ts >= 1992 and ts <= 1993) and not (user_id = 1 and user_id is not null and ts >= 1994 and ts <= 1995) and not (user_id = 1 and user_id is not null and ts >= 1996 and ts <= 1997) and not (user_id = 1 and user_id is not null and ts >= 1998 and ts <= 1999) and not (user_id = 1 and user_id is not null and ts >= 11000 and ts <= 11001) and not (user_id = 1 and user_id is not null and ts >= 11002 and ts <= 11003) and not (user_id = 1 and user_id is not null and ts >= 11004 and ts <= 11005) and not (user_id = 1 and user_id is not null and ts >= 11006 and ts <= 11007) and not (user_id = 1 and user_id is not null and ts >= 11008 and ts <= 11009) and not (user_id = 1 and user_id is not null and ts >= 11010 and ts <= 11011) and not (user_id = 1 and user_id is not null and ts >= 11012 and ts <= 11013) and not (user_id = 1 and user_id is not null and ts >= 11014 and ts <= 11015) and not (user_id = 1 and user_id is not null and ts >= 11016 and ts <= 11017) and not (user_id = 1 and user_id is not null and ts >= 11018 and ts <= 11019) and not (user_id = 1 and user_id is not null and ts >= 11020 and ts <= 11021) and not (user_id = 1 and user_id is not null and ts >= 11022 and ts <= 11023) and not (user_id = 1 and user_id is not null and ts >= 11024 and ts <= 11025) and not (user_id = 1 and user_id is not null and ts >= 11026 and ts <= 11027) and not (user_id = 1 and user_id is not null and ts >= 11028 and ts <= 11029) and not (user_id = 1 and user_id is not null and ts >= 11030 and ts <= 11031) and not (user_id = 1 and user_id is not null and ts >= 11032 and ts <= 11033) and not (user_id = 1 and user_id is not null and ts >= 11034 and ts <= 11035) and not (user_id = 1 and user_id is not null and ts >= 11036 and ts <= 11037) and not (user_id = 1 and user_id is not null and ts >= 11038 and ts <= 11039) and not (user_id = 1 and user_id is not null and ts >= 11040 and ts <= 11041) and not (user_id = 1 and user_id is not null and ts >= 11042 and ts <= 11043) and not (user_id = 1 and user_id is not null and ts >= 11044 and ts <= 11045) and not (user_id = 1 and user_id is not null and ts >= 11046 and ts <= 11047) and not (user_id = 1 and user_id is not null and ts >= 11048 and ts <= 11049) and not (user_id = 1 and user_id is not null and ts >= 11050 and ts <= 11051) and not (user_id = 1 and user_id is not null and ts >= 11052 and ts <= 11053) and not (user_id = 1 and user_id is not null and ts >= 11054 and ts <= 11055) and not (user_id = 1 and user_id is not null and ts >= 11056 and ts <= 11057) and not (user_id = 1 and user_id is not null and ts >= 11058 and ts <= 11059) and not (user_id = 1 and user_id is not null and ts >= 11060 and ts <= 11061) and not (user_id = 1 and user_id is not null and ts >= 11062 and ts <= 11063) and not (user_id = 1 and user_id is not null and ts >= 11064 and ts <= 11065) and not (user_id = 1 and user_id is not null and ts >= 11066 and ts <= 11067) and not (user_id = 1 and user_id is not null and ts >= 11068 and ts <= 11069) and not (user_id = 1 and user_id is not null and ts >= 11070 and ts <= 11071) and not (user_id = 1 and user_id is not null and ts >= 11072 and ts <= 11073) and not (user_id = 1 and user_id is not null and ts >= 11074 and ts <= 11075) and not (user_id = 1 and user_id is not null and ts >= 11076 and ts <= 11077) and not (user_id = 1 and user_id is not null and ts >= 11078 and ts <= 11079) and not (user_id = 1 and user_id is not null and ts >= 11080 and ts <= 11081) and not (user_id = 1 and user_id is not null and ts >= 11082 and ts <= 11083) and not (user_id = 1 and user_id is not null and ts >= 11084 and ts <= 11085) and not (user_id = 1 and user_id is not null and ts >= 11086 and ts <= 11087) and not (user_id = 1 and user_id is not null and ts >= 11088 and ts <= 11089) and not (user_id = 1 and user_id is not null and ts >= 11090 and ts <= 11091) and not (user_id = 1 and user_id is not null and ts >= 11092 and ts <= 11093) and not (user_id = 1 and user_id is not null and ts >= 11094 and ts <= 11095) and not (user_id = 1 and user_id is not null and ts >= 11096 and ts <= 11097) and not (user_id = 1 and user_id is not null and ts >= 11098 and ts <= 11099) and not (user_id = 1 and user_id is not null and ts >= 11100 and ts <= 11101) and not (user_id = 1 and user_id is not null and ts >= 11102 and ts <= 11103) and not (user_id = 1 and user_id is not null and ts >= 11104 and ts <= 11105) and not (user_id = 1 and user_id is not null and ts >= 11106 and ts <= 11107) and not (user_id = 1 and user_id is not null and ts >= 11108 and ts <= 11109) and not (user_id = 1 and user_id is not null and ts >= 11110 and ts <= 11111) and not (user_id = 1 and user_id is not null and ts >= 11112 and ts <= 11113) and not (user_id = 1 and user_id is not null and ts >= 11114 and ts <= 11115) and not (user_id = 1 and user_id is not null and ts >= 11116 and ts <= 11117) and not (user_id = 1 and user_id is not null and ts >= 11118 and ts <= 11119) and not (user_id = 1 and user_id is not null and ts >= 11120 and ts <= 11121) and not (user_id = 1 and user_id is not null and ts >= 11122 and ts <= 11123) and not (user_id = 1 and user_id is not null and ts >= 11124 and ts <= 11125) and not (user_id = 1 and user_id is not null and ts >= 11126 and ts <= 11127) and not (user_id = 1 and user_id is not null and ts >= 11128 and ts <= 11129) and not (user_id = 1 and user_id is not null and ts >= 11130 and ts <= 11131) and not (user_id = 1 and user_id is not null and ts >= 11132 and ts <= 11133) and not (user_id = 1 and user_id is not null and ts >= 11134 and ts <= 11135) and not (user_id = 1 and user_id is not null and ts >= 11136 and ts <= 11137) and not (user_id = 1 and user_id is not null and ts >= 11138 and ts <= 11139) and not (user_id = 1 and user_id is not null and ts >= 11140 and ts <= 11141) and not (user_id = 1 and user_id is not null and ts >= 11142 and ts <= 11143) and not (user_id = 1 and user_id is not null and ts >= 11144 and ts <= 11145) and not (user_id = 1 and user_id is not null and ts >= 11146 and ts <= 11147) and not (user_id = 1 and user_id is not null and ts >= 11148 and ts <= 11149) and not (user_id = 1 and user_id is not null and ts >= 11150 and ts <= 11151) and not (user_id = 1 and user_id is not null and ts >= 11152 and ts <= 11153) and not (user_id = 1 and user_id is not null and ts >= 11154 and ts <= 11155) and not (user_id = 1 and user_id is not null and ts >= 11156 and ts <= 11157) and not (user_id = 1 and user_id is not null and ts >= 11158 and ts <= 11159) and not (user_id = 1 and user_id is not null and ts >= 11160 and ts <= 11161) and not (user_id = 1 and user_id is not null and ts >= 11162 and ts <= 11163) and not (user_id = 1 and user_id is not null and ts >= 11164 and ts <= 11165) and not (user_id = 1 and user_id is not null and ts >= 11166 and ts <= 11167) and not (user_id = 1 and user_id is not null and ts >= 11168 and ts <= 11169) and not (user_id = 1 and user_id is not null and ts >= 11170 and ts <= 11171) and not (user_id = 1 and user_id is not null and ts >= 11172 and ts <= 11173) and not (user_id = 1 and user_id is not null and ts >= 11174 and ts <= 11175) and not (user_id = 1 and user_id is not null and ts >= 11176 and ts <= 11177) and not (user_id = 1 and user_id is not null and ts >= 11178 and ts <= 11179) and not (user_id = 1 and user_id is not null and ts >= 11180 and ts <= 11181) and not (user_id = 1 and user_id is not null and ts >= 11182 and ts <= 11183) and not (user_id = 1 and user_id is not null and ts >= 11184 and ts <= 11185) and not (user_id = 1 and user_id is not null and ts >= 11186 and ts <= 11187) and not (user_id = 1 and user_id is not null and ts >= 11188 and ts <= 11189) and not (user_id = 1 and user_id is not null and ts >= 11190 and ts <= 11191) and not (user_id = 1 and user_id is not null and ts >= 11192 and ts <= 11193) and not (user_id = 1 and user_id is not null and ts >= 11194 and ts <= 11195) and not (user_id = 1 and user_id is not null and ts >= 11196 and ts <= 11197) and not (user_id = 1 and user_id is not null and ts >= 11198 and ts <= 11199) and not (user_id = 1 and user_id is not null and ts >= 11200 and ts <= 11201) and not (user_id = 1 and user_id is not null and ts >= 11202 and ts <= 11203) and not (user_id = 1 and user_id is not null and ts >= 11204 and ts <= 11205) and not (user_id = 1 and user_id is not null and ts >= 11206 and ts <= 11207) and not (user_id = 1 and user_id is not null and ts >= 11208 and ts <= 11209) and not (user_id = 1 and user_id is not null and ts >= 11210 and ts <= 11211) and not (user_id = 1 and user_id is not null and ts >= 11212 and ts <= 11213) and not (user_id = 1 and user_id is not null and ts >= 11214 and ts <= 11215) and not (user_id = 1 and user_id is not null and ts >= 11216 and ts <= 11217) and not (user_id = 1 and user_id is not null and ts >= 11218 and ts <= 11219) and not (user_id = 1 and user_id is not null and ts >= 11220 and ts <= 11221) and not (user_id = 1 and user_id is not null and ts >= 11222 and ts <= 11223) and not (user_id = 1 and user_id is not null and ts >= 11224 and ts <= 11225) and not (user_id = 1 and user_id is not null and ts >= 11226 and ts <= 11227) and not (user_id = 1 and user_id is not null and ts >= 11228 and ts <= 11229) and not (user_id = 1 and user_id is not null and ts >= 11230 and ts <= 11231) and not (user_id = 1 and user_id is not null and ts >= 11232 and ts <= 11233) and not (user_id = 1 and user_id is not null and ts >= 11234 and ts <= 11235) and not (user_id = 1 and user_id is not null and ts >= 11236 and ts <= 11237) and not (user_id = 1 and user_id is not null and ts >= 11238 and ts <= 11239) and not (user_id = 1 and user_id is not null and ts >= 11240 and ts <= 11241) and not (user_id = 1 and user_id is not null and ts >= 11242 and ts <= 11243) and not (user_id = 1 and user_id is not null and ts >= 11244 and ts <= 11245) and not (user_id = 1 and user_id is not null and ts >= 11246 and ts <= 11247) and not (user_id = 1 and user_id is not null and ts >= 11248 and ts <= 11249) and not (user_id = 1 and user_id is not null and ts >= 11250 and ts <= 11251) and not (user_id = 1 and user_id is not null and ts >= 11252 and ts <= 11253) and not (user_id = 1 and user_id is not null and ts >= 11254 and ts <= 11255) and not (user_id = 1 and user_id is not null and ts >= 11256 and ts <= 11257) and not (user_id = 1 and user_id is not null and ts >= 11258 and ts <= 11259) and not (user_id = 1 and user_id is not null and ts >= 11260 and ts <= 11261) and not (user_id = 1 and user_id is not null and ts >= 11262 and ts <= 11263) and not (user_id = 1 and user_id is not null and ts >= 11264 and ts <= 11265) and not (user_id = 1 and user_id is not null and ts >= 11266 and ts <= 11267) and not (user_id = 1 and user_id is not null and ts >= 11268 and ts <= 11269) and not (user_id = 1 and user_id is not null and ts >= 11270 and ts <= 11271) and not (user_id = 1 and user_id is not null and ts >= 11272 and ts <= 11273) and not (user_id = 1 and user_id is not null and ts >= 11274 and ts <= 11275) and not (user_id = 1 and user_id is not null and ts >= 11276 and ts <= 11277) and not (user_id = 1 and user_id is not null and ts >= 11278 and ts <= 11279) and not (user_id = 1 and user_id is not null and ts >= 11280 and ts <= 11281) and not (user_id = 1 and user_id is not null and ts >= 11282 and ts <= 11283) and not (user_id = 1 and user_id is not null and ts >= 11284 and ts <= 11285) and not (user_id = 1 and user_id is not null and ts >= 11286 and ts <= 11287) and not (user_id = 1 and user_id is not null and ts >= 11288 and ts <= 11289) and not (user_id = 1 and user_id is not null and ts >= 11290 and ts <= 11291) and not (user_id = 1 and user_id is not null and ts >= 11292 and ts <= 11293) and not (user_id = 1 and user_id is not null and ts >= 11294 and ts <= 11295) and not (user_id = 1 and user_id is not null and ts >= 11296 and ts <= 11297) and not (user_id = 1 and user_id is not null and ts >= 11298 and ts <= 11299) and not (user_id = 1 and user_id is not null and ts >= 11300 and ts <= 11301) and not (user_id = 1 and user_id is not null and ts >= 11302 and ts <= 11303) and not (user_id = 1 and user_id is not null and ts >= 11304 and ts <= 11305) and not (user_id = 1 and user_id is not null and ts >= 11306 and ts <= 11307) and not (user_id = 1 and user_id is not null and ts >= 11308 and ts <= 11309) and not (user_id = 1 and user_id is not null and ts >= 11310 and ts <= 11311) and not (user_id = 1 and user_id is not null and ts >= 11312 and ts <= 11313) and not (user_id = 1 and user_id is not null and ts >= 11314 and ts <= 11315) and not (user_id = 1 and user_id is not null and ts >= 11316 and ts <= 11317) and not (user_id = 1 and user_id is not null and ts >= 11318 and ts <= 11319) and not (user_id = 1 and user_id is not null and ts >= 11320 and ts <= 11321) and not (user_id = 1 and user_id is not null and ts >= 11322 and ts <= 11323) and not (user_id = 1 and user_id is not null and ts >= 11324 and ts <= 11325) and not (user_id = 1 and user_id is not null and ts >= 11326 and ts <= 11327) and not (user_id = 1 and user_id is not null and ts >= 11328 and ts <= 11329) and not (user_id = 1 and user_id is not null and ts >= 11330 and ts <= 11331) and not (user_id = 1 and user_id is not null and ts >= 11332 and ts <= 11333) and not (user_id = 1 and user_id is not null and ts >= 11334 and ts <= 11335) and not (user_id = 1 and user_id is not null and ts >= 11336 and ts <= 11337) and not (user_id = 1 and user_id is not null and ts >= 11338 and ts <= 11339) and not (user_id = 1 and user_id is not null and ts >= 11340 and ts <= 11341) and not (user_id = 1 and user_id is not null and ts >= 11342 and ts <= 11343) and not (user_id = 1 and user_id is not null and ts >= 11344 and ts <= 11345) and not (user_id = 1 and user_id is not null and ts >= 11346 and ts <= 11347) and not (user_id = 1 and user_id is not null and ts >= 11348 and ts <= 11349) and not (user_id = 1 and user_id is not null and ts >= 11350 and ts <= 11351) and not (user_id = 1 and user_id is not null and ts >= 11352 and ts <= 11353) and not (user_id = 1 and user_id is not null and ts >= 11354 and ts <= 11355) and not (user_id = 1 and user_id is not null and ts >= 11356 and ts <= 11357) and not (user_id = 1 and user_id is not null and ts >= 11358 and ts <= 11359) and not (user_id = 1 and user_id is not null and ts >= 11360 and ts <= 11361) and not (user_id = 1 and user_id is not null and ts >= 11362 and ts <= 11363) and not (user_id = 1 and user_id is not null and ts >= 11364 and ts <= 11365) and not (user_id = 1 and user_id is not null and ts >= 11366 and ts <= 11367) and not (user_id = 1 and user_id is not null and ts >= 11368 and ts <= 11369) and not (user_id = 1 and user_id is not null and ts >= 11370 and ts <= 11371) and not (user_id = 1 and user_id is not null and ts >= 11372 and ts <= 11373) and not (user_id = 1 and user_id is not null and ts >= 11374 and ts <= 11375) and not (user_id = 1 and user_id is not null and ts >= 11376 and ts <= 11377) and not (user_id = 1 and user_id is not null and ts >= 11378 and ts <= 11379) and not (user_id = 1 and user_id is not null and ts >= 11380 and ts <= 11381) and not (user_id = 1 and user_id is not null and ts >= 11382 and ts <= 11383) and not (user_id = 1 and user_id is not null and ts >= 11384 and ts <= 11385) and not (user_id = 1 and user_id is not null and ts >= 11386 and ts <= 11387) and not (user_id = 1 and user_id is not null and ts >= 11388 and ts <= 11389) and not (user_id = 1 and user_id is not null and ts >= 11390 and ts <= 11391) and not (user_id = 1 and user_id is not null and ts >= 11392 and ts <= 11393) and not (user_id = 1 and user_id is not null and ts >= 11394 and ts <= 11395) and not (user_id = 1 and user_id is not null and ts >= 11396 and ts <= 11397) and not (user_id = 1 and user_id is not null and ts >= 11398 and ts <= 11399) and not (user_id = 1 and user_id is not null and ts >= 11400 and ts <= 11401) and not (user_id = 1 and user_id is not null and ts >= 11402 and ts <= 11403) and not (user_id = 1 and user_id is not null and ts >= 11404 and ts <= 11405) and not (user_id = 1 and user_id is not null and ts >= 11406 and ts <= 11407) and not (user_id = 1 and user_id is not null and ts >= 11408 and ts <= 11409) and not (user_id = 1 and user_id is not null and ts >= 11410 and ts <= 11411) and not (user_id = 1 and user_id is not null and ts >= 11412 and ts <= 11413) and not (user_id = 1 and user_id is not null and ts >= 11414 and ts <= 11415) and not (user_id = 1 and user_id is not null and ts >= 11416 and ts <= 11417) and not (user_id = 1 and user_id is not null and ts >= 11418 and ts <= 11419) and not (user_id = 1 and user_id is not null and ts >= 11420 and ts <= 11421) and not (user_id = 1 and user_id is not null and ts >= 11422 and ts <= 11423) and not (user_id = 1 and user_id is not null and ts >= 11424 and ts <= 11425) and not (user_id = 1 and user_id is not null and ts >= 11426 and ts <= 11427) and not (user_id = 1 and user_id is not null and ts >= 11428 and ts <= 11429) and not (user_id = 1 and user_id is not null and ts >= 11430 and ts <= 11431) and not (user_id = 1 and user_id is not null and ts >= 11432 and ts <= 11433) and not (user_id = 1 and user_id is not null and ts >= 11434 and ts <= 11435) and not (user_id = 1 and user_id is not null and ts >= 11436 and ts <= 11437) and not (user_id = 1 and user_id is not null and ts >= 11438 and ts <= 11439) and not (user_id = 1 and user_id is not null and ts >= 11440 and ts <= 11441) and not (user_id = 1 and user_id is not null and ts >= 11442 and ts <= 11443) and not (user_id = 1 and user_id is not null and ts >= 11444 and ts <= 11445) and not (user_id = 1 and user_id is not null and ts >= 11446 and ts <= 11447) and not (user_id = 1 and user_id is not null and ts >= 11448 and ts <= 11449) and not (user_id = 1 and user_id is not null and ts >= 11450 and ts <= 11451) and not (user_id = 1 and user_id is not null and ts >= 11452 and ts <= 11453) and not (user_id = 1 and user_id is not null and ts >= 11454 and ts <= 11455) and not (user_id = 1 and user_id is not null and ts >= 11456 and ts <= 11457) and not (user_id = 1 and user_id is not null and ts >= 11458 and ts <= 11459) and not (user_id = 1 and user_id is not null and ts >= 11460 and ts <= 11461) and not (user_id = 1 and user_id is not null and ts >= 11462 and ts <= 11463) and not (user_id = 1 and user_id is not null and ts >= 11464 and ts <= 11465) and not (user_id = 1 and user_id is not null and ts >= 11466 and ts <= 11467) and not (user_id = 1 and user_id is not null and ts >= 11468 and ts <= 11469) and not (user_id = 1 and user_id is not null and ts >= 11470 and ts <= 11471) and not (user_id = 1 and user_id is not null and ts >= 11472 and ts <= 11473) and not (user_id = 1 and user_id is not null and ts >= 11474 and ts <= 11475) and not (user_id = 1 and user_id is not null and ts >= 11476 and ts <= 11477) and not (user_id = 1 and user_id is not null and ts >= 11478 and ts <= 11479) and not (user_id = 1 and user_id is not null and ts >= 11480 and ts <= 11481) and not (user_id = 1 and user_id is not null and ts >= 11482 and ts <= 11483) and not (user_id = 1 and user_id is not null and ts >= 11484 and ts <= 11485) and not (user_id = 1 and user_id is not null and ts >= 11486 and ts <= 11487) and not (user_id = 1 and user_id is not null and ts >= 11488 and ts <= 11489) and not (user_id = 1 and user_id is not null and ts >= 11490 and ts <= 11491) and not (user_id = 1 and user_id is not null and ts >= 11492 and ts <= 11493) and not (user_id = 1 and user_id is not null and ts >= 11494 and ts <= 11495) and not (user_id = 1 and user_id is not null and ts >= 11496 and ts <= 11497) and not (user_id = 1 and user_id is not null and ts >= 11498 and ts <= 11499) and not (user_id = 1 and user_id is not null and ts >= 11500 and ts <= 11501) and not (user_id = 1 and user_id is not null and ts >= 11502 and ts <= 11503) and not (user_id = 1 and user_id is not null and ts >= 11504 and ts <= 11505) and not (user_id = 1 and user_id is not null and ts >= 11506 and ts <= 11507) and not (user_id = 1 and user_id is not null and ts >= 11508 and ts <= 11509) and not (user_id = 1 and user_id is not null and ts >= 11510 and ts <= 11511) and not (user_id = 1 and user_id is not null and ts >= 11512 and ts <= 11513) and not (user_id = 1 and user_id is not null and ts >= 11514 and ts <= 11515) and not (user_id = 1 and user_id is not null and ts >= 11516 and ts <= 11517) and not (user_id = 1 and user_id is not null and ts >= 11518 and ts <= 11519) and not (user_id = 1 and user_id is not null and ts >= 11520 and ts <= 11521) and not (user_id = 1 and user_id is not null and ts >= 11522 and ts <= 11523) and not (user_id = 1 and user_id is not null and ts >= 11524 and ts <= 11525) and not (user_id = 1 and user_id is not null and ts >= 11526 and ts <= 11527) and not (user_id = 1 and user_id is not null and ts >= 11528 and ts <= 11529) and not (user_id = 1 and user_id is not null and ts >= 11530 and ts <= 11531) and not (user_id = 1 and user_id is not null and ts >= 11532 and ts <= 11533) and not (user_id = 1 and user_id is not null and ts >= 11534 and ts <= 11535) and not (user_id = 1 and user_id is not null and ts >= 11536 and ts <= 11537) and not (user_id = 1 and user_id is not null and ts >= 11538 and ts <= 11539) and not (user_id = 1 and user_id is not null and ts >= 11540 and ts <= 11541) and not (user_id = 1 and user_id is not null and ts >= 11542 and ts <= 11543) and not (user_id = 1 and user_id is not null and ts >= 11544 and ts <= 11545) and not (user_id = 1 and user_id is not null and ts >= 11546 and ts <= 11547) and not (user_id = 1 and user_id is not null and ts >= 11548 and ts <= 11549) and not (user_id = 1 and user_id is not null and ts >= 11550 and ts <= 11551) and not (user_id = 1 and user_id is not null and ts >= 11552 and ts <= 11553) and not (user_id = 1 and user_id is not null and ts >= 11554 and ts <= 11555) and not (user_id = 1 and user_id is not null and ts >= 11556 and ts <= 11557) and not (user_id = 1 and user_id is not null and ts >= 11558 and ts <= 11559) and not (user_id = 1 and user_id is not null and ts >= 11560 and ts <= 11561) and not (user_id = 1 and user_id is not null and ts >= 11562 and ts <= 11563) and not (user_id = 1 and user_id is not null and ts >= 11564 and ts <= 11565) and not (user_id = 1 and user_id is not null and ts >= 11566 and ts <= 11567) and not (user_id = 1 and user_id is not null and ts >= 11568 and ts <= 11569) and not (user_id = 1 and user_id is not null and ts >= 11570 and ts <= 11571) and not (user_id = 1 and user_id is not null and ts >= 11572 and ts <= 11573) and not (user_id = 1 and user_id is not null and ts >= 11574 and ts <= 11575) and not (user_id = 1 and user_id is not null and ts >= 11576 and ts <= 11577) and not (user_id = 1 and user_id is not null and ts >= 11578 and ts <= 11579) and not (user_id = 1 and user_id is not null and ts >= 11580 and ts <= 11581) and not (user_id = 1 and user_id is not null and ts >= 11582 and ts <= 11583) and not (user_id = 1 and user_id is not null and ts >= 11584 and ts <= 11585) and not (user_id = 1 and user_id is not null and ts >= 11586 and ts <= 11587) and not (user_id = 1 and user_id is not null and ts >= 11588 and ts <= 11589) and not (user_id = 1 and user_id is not null and ts >= 11590 and ts <= 11591) and not (user_id = 1 and user_id is not null and ts >= 11592 and ts <= 11593) and not (user_id = 1 and user_id is not null and ts >= 11594 and ts <= 11595) and not (user_id = 1 and user_id is not null and ts >= 11596 and ts <= 11597) and not (user_id = 1 and user_id is not null and ts >= 11598 and ts <= 11599) and not (user_id = 1 and user_id is not null and ts >= 11600 and ts <= 11601) and not (user_id = 1 and user_id is not null and ts >= 11602 and ts <= 11603) and not (user_id = 1 and user_id is not null and ts >= 11604 and ts <= 11605) and not (user_id = 1 and user_id is not null and ts >= 11606 and ts <= 11607) and not (user_id = 1 and user_id is not null and ts >= 11608 and ts <= 11609) and not (user_id = 1 and user_id is not null and ts >= 11610 and ts <= 11611) and not (user_id = 1 and user_id is not null and ts >= 11612 and ts <= 11613) and not (user_id = 1 and user_id is not null and ts >= 11614 and ts <= 11615) and not (user_id = 1 and user_id is not null and ts >= 11616 and ts <= 11617) and not (user_id = 1 and user_id is not null and ts >= 11618 and ts <= 11619) and not (user_id = 1 and user_id is not null and ts >= 11620 and ts <= 11621) and not (user_id = 1 and user_id is not null and ts >= 11622 and ts <= 11623) and not (user_id = 1 and user_id is not null and ts >= 11624 and ts <= 11625) and not (user_id = 1 and user_id is not null and ts >= 11626 and ts <= 11627) and not (user_id = 1 and user_id is not null and ts >= 11628 and ts <= 11629) and not (user_id = 1 and user_id is not null and ts >= 11630 and ts <= 11631) and not (user_id = 1 and user_id is not null and ts >= 11632 and ts <= 11633) and not (user_id = 1 and user_id is not null and ts >= 11634 and ts <= 11635) and not (user_id = 1 and user_id is not null and ts >= 11636 and ts <= 11637) and not (user_id = 1 and user_id is not null and ts >= 11638 and ts <= 11639) and not (user_id = 1 and user_id is not null and ts >= 11640 and ts <= 11641) and not (user_id = 1 and user_id is not null and ts >= 11642 and ts <= 11643) and not (user_id = 1 and user_id is not null and ts >= 11644 and ts <= 11645) and not (user_id = 1 and user_id is not null and ts >= 11646 and ts <= 11647) and not (user_id = 1 and user_id is not null and ts >= 11648 and ts <= 11649) and not (user_id = 1 and user_id is not null and ts >= 11650 and ts <= 11651) and not (user_id = 1 and user_id is not null and ts >= 11652 and ts <= 11653) and not (user_id = 1 and user_id is not null and ts >= 11654 and ts <= 11655) and not (user_id = 1 and user_id is not null and ts >= 11656 and ts <= 11657) and not (user_id = 1 and user_id is not null and ts >= 11658 and ts <= 11659) and not (user_id = 1 and user_id is not null and ts >= 11660 and ts <= 11661) and not (user_id = 1 and user_id is not null and ts >= 11662 and ts <= 11663) and not (user_id = 1 and user_id is not null and ts >= 11664 and ts <= 11665) and not (user_id = 1 and user_id is not null and ts >= 11666 and ts <= 11667) and not (user_id = 1 and user_id is not null and ts >= 11668 and ts <= 11669) and not (user_id = 1 and user_id is not null and ts >= 11670 and ts <= 11671) and not (user_id = 1 and user_id is not null and ts >= 11672 and ts <= 11673) and not (user_id = 1 and user_id is not null and ts >= 11674 and ts <= 11675) and not (user_id = 1 and user_id is not null and ts >= 11676 and ts <= 11677) and not (user_id = 1 and user_id is not null and ts >= 11678 and ts <= 11679) and not (user_id = 1 and user_id is not null and ts >= 11680 and ts <= 11681) and not (user_id = 1 and user_id is not null and ts >= 11682 and ts <= 11683) and not (user_id = 1 and user_id is not null and ts >= 11684 and ts <= 11685) and not (user_id = 1 and user_id is not null and ts >= 11686 and ts <= 11687) and not (user_id = 1 and user_id is not null and ts >= 11688 and ts <= 11689) and not (user_id = 1 and user_id is not null and ts >= 11690 and ts <= 11691) and not (user_id = 1 and user_id is not null and ts >= 11692 and ts <= 11693) and not (user_id = 1 and user_id is not null and ts >= 11694 and ts <= 11695) and not (user_id = 1 and user_id is not null and ts >= 11696 and ts <= 11697) and not (user_id = 1 and user_id is not null and ts >= 11698 and ts <= 11699) and not (user_id = 1 and user_id is not null and ts >= 11700 and ts <= 11701) and not (user_id = 1 and user_id is not null and ts >= 11702 and ts <= 11703) and not (user_id = 1 and user_id is not null and ts >= 11704 and ts <= 11705) and not (user_id = 1 and user_id is not null and ts >= 11706 and ts <= 11707) and not (user_id = 1 and user_id is not null and ts >= 11708 and ts <= 11709) and not (user_id = 1 and user_id is not null and ts >= 11710 and ts <= 11711) and not (user_id = 1 and user_id is not null and ts >= 11712 and ts <= 11713) and not (user_id = 1 and user_id is not null and ts >= 11714 and ts <= 11715) and not (user_id = 1 and user_id is not null and ts >= 11716 and ts <= 11717) and not (user_id = 1 and user_id is not null and ts >= 11718 and ts <= 11719) and not (user_id = 1 and user_id is not null and ts >= 11720 and ts <= 11721) and not (user_id = 1 and user_id is not null and ts >= 11722 and ts <= 11723) and not (user_id = 1 and user_id is not null and ts >= 11724 and ts <= 11725) and not (user_id = 1 and user_id is not null and ts >= 11726 and ts <= 11727) and not (user_id = 1 and user_id is not null and ts >= 11728 and ts <= 11729) and not (user_id = 1 and user_id is not null and ts >= 11730 and ts <= 11731) and not (user_id = 1 and user_id is not null and ts >= 11732 and ts <= 11733) and not (user_id = 1 and user_id is not null and ts >= 11734 and ts <= 11735) and not (user_id = 1 and user_id is not null and ts >= 11736 and ts <= 11737) and not (user_id = 1 and user_id is not null and ts >= 11738 and ts <= 11739) and not (user_id = 1 and user_id is not null and ts >= 11740 and ts <= 11741) and not (user_id = 1 and user_id is not null and ts >= 11742 and ts <= 11743) and not (user_id = 1 and user_id is not null and ts >= 11744 and ts <= 11745) and not (user_id = 1 and user_id is not null and ts >= 11746 and ts <= 11747) and not (user_id = 1 and user_id is not null and ts >= 11748 and ts <= 11749) and not (user_id = 1 and user_id is not null and ts >= 11750 and ts <= 11751) and not (user_id = 1 and user_id is not null and ts >= 11752 and ts <= 11753) and not (user_id = 1 and user_id is not null and ts >= 11754 and ts <= 11755) and not (user_id = 1 and user_id is not null and ts >= 11756 and ts <= 11757) and not (user_id = 1 and user_id is not null and ts >= 11758 and ts <= 11759) and not (user_id = 1 and user_id is not null and ts >= 11760 and ts <= 11761) and not (user_id = 1 and user_id is not null and ts >= 11762 and ts <= 11763) and not (user_id = 1 and user_id is not null and ts >= 11764 and ts <= 11765) and not (user_id = 1 and user_id is not null and ts >= 11766 and ts <= 11767) and not (user_id = 1 and user_id is not null and ts >= 11768 and ts <= 11769) and not (user_id = 1 and user_id is not null and ts >= 11770 and ts <= 11771) and not (user_id = 1 and user_id is not null and ts >= 11772 and ts <= 11773) and not (user_id = 1 and user_id is not null and ts >= 11774 and ts <= 11775) and not (user_id = 1 and user_id is not null and ts >= 11776 and ts <= 11777) and not (user_id = 1 and user_id is not null and ts >= 11778 and ts <= 11779) and not (user_id = 1 and user_id is not null and ts >= 11780 and ts <= 11781) and not (user_id = 1 and user_id is not null and ts >= 11782 and ts <= 11783) and not (user_id = 1 and user_id is not null and ts >= 11784 and ts <= 11785) and not (user_id = 1 and user_id is not null and ts >= 11786 and ts <= 11787) and not (user_id = 1 and user_id is not null and ts >= 11788 and ts <= 11789) and not (user_id = 1 and user_id is not null and ts >= 11790 and ts <= 11791) and not (user_id = 1 and user_id is not null and ts >= 11792 and ts <= 11793) and not (user_id = 1 and user_id is not null and ts >= 11794 and ts <= 11795) and not (user_id = 1 and user_id is not null and ts >= 11796 and ts <= 11797) and not (user_id = 1 and user_id is not null and ts >= 11798 and ts <= 11799) and not (user_id = 1 and user_id is not null and ts >= 11800 and ts <= 11801) and not (user_id = 1 and user_id is not null and ts >= 11802 and ts <= 11803) and not (user_id = 1 and user_id is not null and ts >= 11804 and ts <= 11805) and not (user_id = 1 and user_id is not null and ts >= 11806 and ts <= 11807) and not (user_id = 1 and user_id is not null and ts >= 11808 and ts <= 11809) and not (user_id = 1 and user_id is not null and ts >= 11810 and ts <= 11811) and not (user_id = 1 and user_id is not null and ts >= 11812 and ts <= 11813) and not (user_id = 1 and user_id is not null and ts >= 11814 and ts <= 11815) and not (user_id = 1 and user_id is not null and ts >= 11816 and ts <= 11817) and not (user_id = 1 and user_id is not null and ts >= 11818 and ts <= 11819) and not (user_id = 1 and user_id is not null and ts >= 11820 and ts <= 11821) and not (user_id = 1 and user_id is not null and ts >= 11822 and ts <= 11823) and not (user_id = 1 and user_id is not null and ts >= 11824 and ts <= 11825) and not (user_id = 1 and user_id is not null and ts >= 11826 and ts <= 11827) and not (user_id = 1 and user_id is not null and ts >= 11828 and ts <= 11829) and not (user_id = 1 and user_id is not null and ts >= 11830 and ts <= 11831) and not (user_id = 1 and user_id is not null and ts >= 11832 and ts <= 11833) and not (user_id = 1 and user_id is not null and ts >= 11834 and ts <= 11835) and not (user_id = 1 and user_id is not null and ts >= 11836 and ts <= 11837) and not (user_id = 1 and user_id is not null and ts >= 11838 and ts <= 11839) and not (user_id = 1 and user_id is not null and ts >= 11840 and ts <= 11841) and not (user_id = 1 and user_id is not null and ts >= 11842 and ts <= 11843) and not (user_id = 1 and user_id is not null and ts >= 11844 and ts <= 11845) and not (user_id = 1 and user_id is not null and ts >= 11846 and ts <= 11847) and not (user_id = 1 and user_id is not null and ts >= 11848 and ts <= 11849) and not (user_id = 1 and user_id is not null and ts >= 11850 and ts <= 11851) and not (user_id = 1 and user_id is not null and ts >= 11852 and ts <= 11853) and not (user_id = 1 and user_id is not null and ts >= 11854 and ts <= 11855) and not (user_id = 1 and user_id is not null and ts >= 11856 and ts <= 11857) and not (user_id = 1 and user_id is not null and ts >= 11858 and ts <= 11859) and not (user_id = 1 and user_id is not null and ts >= 11860 and ts <= 11861) and not (user_id = 1 and user_id is not null and ts >= 11862 and ts <= 11863) and not (user_id = 1 and user_id is not null and ts >= 11864 and ts <= 11865) and not (user_id = 1 and user_id is not null and ts >= 11866 and ts <= 11867) and not (user_id = 1 and user_id is not null and ts >= 11868 and ts <= 11869) and not (user_id = 1 and user_id is not null and ts >= 11870 and ts <= 11871) and not (user_id = 1 and user_id is not null and ts >= 11872 and ts <= 11873) and not (user_id = 1 and user_id is not null and ts >= 11874 and ts <= 11875) and not (user_id = 1 and user_id is not null and ts >= 11876 and ts <= 11877) and not (user_id = 1 and user_id is not null and ts >= 11878 and ts <= 11879) and not (user_id = 1 and user_id is not null and ts >= 11880 and ts <= 11881) and not (user_id = 1 and user_id is not null and ts >= 11882 and ts <= 11883) and not (user_id = 1 and user_id is not null and ts >= 11884 and ts <= 11885) and not (user_id = 1 and user_id is not null and ts >= 11886 and ts <= 11887) and not (user_id = 1 and user_id is not null and ts >= 11888 and ts <= 11889) and not (user_id = 1 and user_id is not null and ts >= 11890 and ts <= 11891) and not (user_id = 1 and user_id is not null and ts >= 11892 and ts <= 11893) and not (user_id = 1 and user_id is not null and ts >= 11894 and ts <= 11895) and not (user_id = 1 and user_id is not null and ts >= 11896 and ts <= 11897) and not (user_id = 1 and user_id is not null and ts >= 11898 and ts <= 11899) and not (user_id = 1 and user_id is not null and ts >= 11900 and ts <= 11901) and not (user_id = 1 and user_id is not null and ts >= 11902 and ts <= 11903) and not (user_id = 1 and user_id is not null and ts >= 11904 and ts <= 11905) and not (user_id = 1 and user_id is not null and ts >= 11906 and ts <= 11907) and not (user_id = 1 and user_id is not null and ts >= 11908 and ts <= 11909) and not (user_id = 1 and user_id is not null and ts >= 11910 and ts <= 11911) and not (user_id = 1 and user_id is not null and ts >= 11912 and ts <= 11913) and not (user_id = 1 and user_id is not null and ts >= 11914 and ts <= 11915) and not (user_id = 1 and user_id is not null and ts >= 11916 and ts <= 11917) and not (user_id = 1 and user_id is not null and ts >= 11918 and ts <= 11919) and not (user_id = 1 and user_id is not null and ts >= 11920 and ts <= 11921) and not (user_id = 1 and user_id is not null and ts >= 11922 and ts <= 11923) and not (user_id = 1 and user_id is not null and ts >= 11924 and ts <= 11925) and not (user_id = 1 and user_id is not null and ts >= 11926 and ts <= 11927) and not (user_id = 1 and user_id is not null and ts >= 11928 and ts <= 11929) and not (user_id = 1 and user_id is not null and ts >= 11930 and ts <= 11931) and not (user_id = 1 and user_id is not null and ts >= 11932 and ts <= 11933) and not (user_id = 1 and user_id is not null and ts >= 11934 and ts <= 11935) and not (user_id = 1 and user_id is not null and ts >= 11936 and ts <= 11937) and not (user_id = 1 and user_id is not null and ts >= 11938 and ts <= 11939) and not (user_id = 1 and user_id is not null and ts >= 11940 and ts <= 11941) and not (user_id = 1 and user_id is not null and ts >= 11942 and ts <= 11943) and not (user_id = 1 and user_id is not null and ts >= 11944 and ts <= 11945) and not (user_id = 1 and user_id is not null and ts >= 11946 and ts <= 11947) and not (user_id = 1 and user_id is not null and ts >= 11948 and ts <= 11949) and not (user_id = 1 and user_id is not null and ts >= 11950 and ts <= 11951) and not (user_id = 1 and user_id is not null and ts >= 11952 and ts <= 11953) and not (user_id = 1 and user_id is not null and ts >= 11954 and ts <= 11955) and not (user_id = 1 and user_id is not null and ts >= 11956 and ts <= 11957) and not (user_id = 1 and user_id is not null and ts >= 11958 and ts <= 11959) and not (user_id = 1 and user_id is not null and ts >= 11960 and ts <= 11961) and not (user_id = 1 and user_id is not null and ts >= 11962 and ts <= 11963) and not (user_id = 1 and user_id is not null and ts >= 11964 and ts <= 11965) and not (user_id = 1 and user_id is not null and ts >= 11966 and ts <= 11967) and not (user_id = 1 and user_id is not null and ts >= 11968 and ts <= 11969) and not (user_id = 1 and user_id is not null and ts >= 11970 and ts <= 11971) and not (user_id = 1 and user_id is not null and ts >= 11972 and ts <= 11973) and not (user_id = 1 and user_id is not null and ts >= 11974 and ts <= 11975) and not (user_id = 1 and user_id is not null and ts >= 11976 and ts <= 11977) and not (user_id = 1 and user_id is not null and ts >= 11978 and ts <= 11979) and not (user_id = 1 and user_id is not null and ts >= 11980 and ts <= 11981) and not (user_id = 1 and user_id is not null and ts >= 11982 and ts <= 11983) and not (user_id = 1 and user_id is not null and ts >= 11984 and ts <= 11985) and not (user_id = 1 and user_id is not null and ts >= 11986 and ts <= 11987) and not (user_id = 1 and user_id is not null and ts >= 11988 and ts <= 11989) and not (user_id = 1 and user_id is not null and ts >= 11990 and ts <= 11991) and not (user_id = 1 and user_id is not null and ts >= 11992 and ts <= 11993) and ts >= 113898 and parent_id = 1 order by ts asc limit 100", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from user where shard_key = 1 and is_removed = 1 and cmd in ('A','B','C') and not (user_id = 1 and user_id is not null and ts >= 1 and ts <= 2) and not (user_id = 1 and user_id is not null and ts >= 12 and ts <= 13) and not (user_id = 1 and user_id is not null and ts >= 14 and ts <= 15) and not (user_id = 1 and user_id is not null and ts >= 16 and ts <= 17) and not (user_id = 1 and user_id is not null and ts >= 18 and ts <= 19) and not (user_id = 1 and user_id is not null and ts >= 110 and ts <= 111) and not (user_id = 1 and user_id is not null and ts >= 112 and ts <= 113) and not (user_id = 1 and user_id is not null and ts >= 114 and ts <= 115) and not (user_id = 1 and user_id is not null and ts >= 116 and ts <= 117) and not (user_id = 1 and user_id is not null and ts >= 118 and ts <= 119) and not (user_id = 1 and user_id is not null and ts >= 120 and ts <= 121) and not (user_id = 1 and user_id is not null and ts >= 122 and ts <= 123) and not (user_id = 1 and user_id is not null and ts >= 124 and ts <= 125) and not (user_id = 1 and user_id is not null and ts >= 126 and ts <= 127) and not (user_id = 1 and user_id is not null and ts >= 128 and ts <= 129) and not (user_id = 1 and user_id is not null and ts >= 130 and ts <= 131) and not (user_id = 1 and user_id is not null and ts >= 132 and ts <= 133) and not (user_id = 1 and user_id is not null and ts >= 134 and ts <= 135) and not (user_id = 1 and user_id is not null and ts >= 136 and ts <= 137) and not (user_id = 1 and user_id is not null and ts >= 138 and ts <= 139) and not (user_id = 1 and user_id is not null and ts >= 140 and ts <= 141) and not (user_id = 1 and user_id is not null and ts >= 142 and ts <= 143) and not (user_id = 1 and user_id is not null and ts >= 144 and ts <= 145) and not (user_id = 1 and user_id is not null and ts >= 146 and ts <= 147) and not (user_id = 1 and user_id is not null and ts >= 148 and ts <= 149) and not (user_id = 1 and user_id is not null and ts >= 150 and ts <= 151) and not (user_id = 1 and user_id is not null and ts >= 152 and ts <= 153) and not (user_id = 1 and user_id is not null and ts >= 154 and ts <= 155) and not (user_id = 1 and user_id is not null and ts >= 156 and ts <= 157) and not (user_id = 1 and user_id is not null and ts >= 158 and ts <= 159) and not (user_id = 1 and user_id is not null and ts >= 160 and ts <= 161) and not (user_id = 1 and user_id is not null and ts >= 162 and ts <= 163) and not (user_id = 1 and user_id is not null and ts >= 164 and ts <= 165) and not (user_id = 1 and user_id is not null and ts >= 166 and ts <= 167) and not (user_id = 1 and user_id is not null and ts >= 168 and ts <= 169) and not (user_id = 1 and user_id is not null and ts >= 170 and ts <= 171) and not (user_id = 1 and user_id is not null and ts >= 172 and ts <= 173) and not (user_id = 1 and user_id is not null and ts >= 174 and ts <= 175) and not (user_id = 1 and user_id is not null and ts >= 176 and ts <= 177) and not (user_id = 1 and user_id is not null and ts >= 178 and ts <= 179) and not (user_id = 1 and user_id is not null and ts >= 180 and ts <= 181) and not (user_id = 1 and user_id is not null and ts >= 182 and ts <= 183) and not (user_id = 1 and user_id is not null and ts >= 184 and ts <= 185) and not (user_id = 1 and user_id is not null and ts >= 186 and ts <= 187) and not (user_id = 1 and user_id is not null and ts >= 188 and ts <= 189) and not (user_id = 1 and user_id is not null and ts >= 190 and ts <= 191) and not (user_id = 1 and user_id is not null and ts >= 192 and ts <= 193) and not (user_id = 1 and user_id is not null and ts >= 194 and ts <= 195) and not (user_id = 1 and user_id is not null and ts >= 196 and ts <= 197) and not (user_id = 1 and user_id is not null and ts >= 198 and ts <= 199) and not (user_id = 1 and user_id is not null and ts >= 1100 and ts <= 1101) and not (user_id = 1 and user_id is not null and ts >= 1102 and ts <= 1103) and not (user_id = 1 and user_id is not null and ts >= 1104 and ts <= 1105) and not (user_id = 1 and user_id is not null and ts >= 1106 and ts <= 1107) and not (user_id = 1 and user_id is not null and ts >= 1108 and ts <= 1109) and not (user_id = 1 and user_id is not null and ts >= 1110 and ts <= 1111) and not (user_id = 1 and user_id is not null and ts >= 1112 and ts <= 1113) and not (user_id = 1 and user_id is not null and ts >= 1114 and ts <= 1115) and not (user_id = 1 and user_id is not null and ts >= 1116 and ts <= 1117) and not (user_id = 1 and user_id is not null and ts >= 1118 and ts <= 1119) and not (user_id = 1 and user_id is not null and ts >= 1120 and ts <= 1121) and not (user_id = 1 and user_id is not null and ts >= 1122 and ts <= 1123) and not (user_id = 1 and user_id is not null and ts >= 1124 and ts <= 1125) and not (user_id = 1 and user_id is not null and ts >= 1126 and ts <= 1127) and not (user_id = 1 and user_id is not null and ts >= 1128 and ts <= 1129) and not (user_id = 1 and user_id is not null and ts >= 1130 and ts <= 1131) and not (user_id = 1 and user_id is not null and ts >= 1132 and ts <= 1133) and not (user_id = 1 and user_id is not null and ts >= 1134 and ts <= 1135) and not (user_id = 1 and user_id is not null and ts >= 1136 and ts <= 1137) and not (user_id = 1 and user_id is not null and ts >= 1138 and ts <= 1139) and not (user_id = 1 and user_id is not null and ts >= 1140 and ts <= 1141) and not (user_id = 1 and user_id is not null and ts >= 1142 and ts <= 1143) and not (user_id = 1 and user_id is not null and ts >= 1144 and ts <= 1145) and not (user_id = 1 and user_id is not null and ts >= 1146 and ts <= 1147) and not (user_id = 1 and user_id is not null and ts >= 1148 and ts <= 1149) and not (user_id = 1 and user_id is not null and ts >= 1150 and ts <= 1151) and not (user_id = 1 and user_id is not null and ts >= 1152 and ts <= 1153) and not (user_id = 1 and user_id is not null and ts >= 1154 and ts <= 1155) and not (user_id = 1 and user_id is not null and ts >= 1156 and ts <= 1157) and not (user_id = 1 and user_id is not null and ts >= 1158 and ts <= 1159) and not (user_id = 1 and user_id is not null and ts >= 1160 and ts <= 1161) and not (user_id = 1 and user_id is not null and ts >= 1162 and ts <= 1163) and not (user_id = 1 and user_id is not null and ts >= 1164 and ts <= 1165) and not (user_id = 1 and user_id is not null and ts >= 1166 and ts <= 1167) and not (user_id = 1 and user_id is not null and ts >= 1168 and ts <= 1169) and not (user_id = 1 and user_id is not null and ts >= 1170 and ts <= 1171) and not (user_id = 1 and user_id is not null and ts >= 1172 and ts <= 1173) and not (user_id = 1 and user_id is not null and ts >= 1174 and ts <= 1175) and not (user_id = 1 and user_id is not null and ts >= 1176 and ts <= 1177) and not (user_id = 1 and user_id is not null and ts >= 1178 and ts <= 1179) and not (user_id = 1 and user_id is not null and ts >= 1180 and ts <= 1181) and not (user_id = 1 and user_id is not null and ts >= 1182 and ts <= 1183) and not (user_id = 1 and user_id is not null and ts >= 1184 and ts <= 1185) and not (user_id = 1 and user_id is not null and ts >= 1186 and ts <= 1187) and not (user_id = 1 and user_id is not null and ts >= 1188 and ts <= 1189) and not (user_id = 1 and user_id is not null and ts >= 1190 and ts <= 1191) and not (user_id = 1 and user_id is not null and ts >= 1192 and ts <= 1193) and not (user_id = 1 and user_id is not null and ts >= 1194 and ts <= 1195) and not (user_id = 1 and user_id is not null and ts >= 1196 and ts <= 1197) and not (user_id = 1 and user_id is not null and ts >= 1198 and ts <= 1199) and not (user_id = 1 and user_id is not null and ts >= 1200 and ts <= 1201) and not (user_id = 1 and user_id is not null and ts >= 1202 and ts <= 1203) and not (user_id = 1 and user_id is not null and ts >= 1204 and ts <= 1205) and not (user_id = 1 and user_id is not null and ts >= 1206 and ts <= 1207) and not (user_id = 1 and user_id is not null and ts >= 1208 and ts <= 1209) and not (user_id = 1 and user_id is not null and ts >= 1210 and ts <= 1211) and not (user_id = 1 and user_id is not null and ts >= 1212 and ts <= 1213) and not (user_id = 1 and user_id is not null and ts >= 1214 and ts <= 1215) and not (user_id = 1 and user_id is not null and ts >= 1216 and ts <= 1217) and not (user_id = 1 and user_id is not null and ts >= 1218 and ts <= 1219) and not (user_id = 1 and user_id is not null and ts >= 1220 and ts <= 1221) and not (user_id = 1 and user_id is not null and ts >= 1222 and ts <= 1223) and not (user_id = 1 and user_id is not null and ts >= 1224 and ts <= 1225) and not (user_id = 1 and user_id is not null and ts >= 1226 and ts <= 1227) and not (user_id = 1 and user_id is not null and ts >= 1228 and ts <= 1229) and not (user_id = 1 and user_id is not null and ts >= 1230 and ts <= 1231) and not (user_id = 1 and user_id is not null and ts >= 1232 and ts <= 1233) and not (user_id = 1 and user_id is not null and ts >= 1234 and ts <= 1235) and not (user_id = 1 and user_id is not null and ts >= 1236 and ts <= 1237) and not (user_id = 1 and user_id is not null and ts >= 1238 and ts <= 1239) and not (user_id = 1 and user_id is not null and ts >= 1240 and ts <= 1241) and not (user_id = 1 and user_id is not null and ts >= 1242 and ts <= 1243) and not (user_id = 1 and user_id is not null and ts >= 1244 and ts <= 1245) and not (user_id = 1 and user_id is not null and ts >= 1246 and ts <= 1247) and not (user_id = 1 and user_id is not null and ts >= 1248 and ts <= 1249) and not (user_id = 1 and user_id is not null and ts >= 1250 and ts <= 1251) and not (user_id = 1 and user_id is not null and ts >= 1252 and ts <= 1253) and not (user_id = 1 and user_id is not null and ts >= 1254 and ts <= 1255) and not (user_id = 1 and user_id is not null and ts >= 1256 and ts <= 1257) and not (user_id = 1 and user_id is not null and ts >= 1258 and ts <= 1259) and not (user_id = 1 and user_id is not null and ts >= 1260 and ts <= 1261) and not (user_id = 1 and user_id is not null and ts >= 1262 and ts <= 1263) and not (user_id = 1 and user_id is not null and ts >= 1264 and ts <= 1265) and not (user_id = 1 and user_id is not null and ts >= 1266 and ts <= 1267) and not (user_id = 1 and user_id is not null and ts >= 1268 and ts <= 1269) and not (user_id = 1 and user_id is not null and ts >= 1270 and ts <= 1271) and not (user_id = 1 and user_id is not null and ts >= 1272 and ts <= 1273) and not (user_id = 1 and user_id is not null and ts >= 1274 and ts <= 1275) and not (user_id = 1 and user_id is not null and ts >= 1276 and ts <= 1277) and not (user_id = 1 and user_id is not null and ts >= 1278 and ts <= 1279) and not (user_id = 1 and user_id is not null and ts >= 1280 and ts <= 1281) and not (user_id = 1 and user_id is not null and ts >= 1282 and ts <= 1283) and not (user_id = 1 and user_id is not null and ts >= 1284 and ts <= 1285) and not (user_id = 1 and user_id is not null and ts >= 1286 and ts <= 1287) and not (user_id = 1 and user_id is not null and ts >= 1288 and ts <= 1289) and not (user_id = 1 and user_id is not null and ts >= 1290 and ts <= 1291) and not (user_id = 1 and user_id is not null and ts >= 1292 and ts <= 1293) and not (user_id = 1 and user_id is not null and ts >= 1294 and ts <= 1295) and not (user_id = 1 and user_id is not null and ts >= 1296 and ts <= 1297) and not (user_id = 1 and user_id is not null and ts >= 1298 and ts <= 1299) and not (user_id = 1 and user_id is not null and ts >= 1300 and ts <= 1301) and not (user_id = 1 and user_id is not null and ts >= 1302 and ts <= 1303) and not (user_id = 1 and user_id is not null and ts >= 1304 and ts <= 1305) and not (user_id = 1 and user_id is not null and ts >= 1306 and ts <= 1307) and not (user_id = 1 and user_id is not null and ts >= 1308 and ts <= 1309) and not (user_id = 1 and user_id is not null and ts >= 1310 and ts <= 1311) and not (user_id = 1 and user_id is not null and ts >= 1312 and ts <= 1313) and not (user_id = 1 and user_id is not null and ts >= 1314 and ts <= 1315) and not (user_id = 1 and user_id is not null and ts >= 1316 and ts <= 1317) and not (user_id = 1 and user_id is not null and ts >= 1318 and ts <= 1319) and not (user_id = 1 and user_id is not null and ts >= 1320 and ts <= 1321) and not (user_id = 1 and user_id is not null and ts >= 1322 and ts <= 1323) and not (user_id = 1 and user_id is not null and ts >= 1324 and ts <= 1325) and not (user_id = 1 and user_id is not null and ts >= 1326 and ts <= 1327) and not (user_id = 1 and user_id is not null and ts >= 1328 and ts <= 1329) and not (user_id = 1 and user_id is not null and ts >= 1330 and ts <= 1331) and not (user_id = 1 and user_id is not null and ts >= 1332 and ts <= 1333) and not (user_id = 1 and user_id is not null and ts >= 1334 and ts <= 1335) and not (user_id = 1 and user_id is not null and ts >= 1336 and ts <= 1337) and not (user_id = 1 and user_id is not null and ts >= 1338 and ts <= 1339) and not (user_id = 1 and user_id is not null and ts >= 1340 and ts <= 1341) and not (user_id = 1 and user_id is not null and ts >= 1342 and ts <= 1343) and not (user_id = 1 and user_id is not null and ts >= 1344 and ts <= 1345) and not (user_id = 1 and user_id is not null and ts >= 1346 and ts <= 1347) and not (user_id = 1 and user_id is not null and ts >= 1348 and ts <= 1349) and not (user_id = 1 and user_id is not null and ts >= 1350 and ts <= 1351) and not (user_id = 1 and user_id is not null and ts >= 1352 and ts <= 1353) and not (user_id = 1 and user_id is not null and ts >= 1354 and ts <= 1355) and not (user_id = 1 and user_id is not null and ts >= 1356 and ts <= 1357) and not (user_id = 1 and user_id is not null and ts >= 1358 and ts <= 1359) and not (user_id = 1 and user_id is not null and ts >= 1360 and ts <= 1361) and not (user_id = 1 and user_id is not null and ts >= 1362 and ts <= 1363) and not (user_id = 1 and user_id is not null and ts >= 1364 and ts <= 1365) and not (user_id = 1 and user_id is not null and ts >= 1366 and ts <= 1367) and not (user_id = 1 and user_id is not null and ts >= 1368 and ts <= 1369) and not (user_id = 1 and user_id is not null and ts >= 1370 and ts <= 1371) and not (user_id = 1 and user_id is not null and ts >= 1372 and ts <= 1373) and not (user_id = 1 and user_id is not null and ts >= 1374 and ts <= 1375) and not (user_id = 1 and user_id is not null and ts >= 1376 and ts <= 1377) and not (user_id = 1 and user_id is not null and ts >= 1378 and ts <= 1379) and not (user_id = 1 and user_id is not null and ts >= 1380 and ts <= 1381) and not (user_id = 1 and user_id is not null and ts >= 1382 and ts <= 1383) and not (user_id = 1 and user_id is not null and ts >= 1384 and ts <= 1385) and not (user_id = 1 and user_id is not null and ts >= 1386 and ts <= 1387) and not (user_id = 1 and user_id is not null and ts >= 1388 and ts <= 1389) and not (user_id = 1 and user_id is not null and ts >= 1390 and ts <= 1391) and not (user_id = 1 and user_id is not null and ts >= 1392 and ts <= 1393) and not (user_id = 1 and user_id is not null and ts >= 1394 and ts <= 1395) and not (user_id = 1 and user_id is not null and ts >= 1396 and ts <= 1397) and not (user_id = 1 and user_id is not null and ts >= 1398 and ts <= 1399) and not (user_id = 1 and user_id is not null and ts >= 1400 and ts <= 1401) and not (user_id = 1 and user_id is not null and ts >= 1402 and ts <= 1403) and not (user_id = 1 and user_id is not null and ts >= 1404 and ts <= 1405) and not (user_id = 1 and user_id is not null and ts >= 1406 and ts <= 1407) and not (user_id = 1 and user_id is not null and ts >= 1408 and ts <= 1409) and not (user_id = 1 and user_id is not null and ts >= 1410 and ts <= 1411) and not (user_id = 1 and user_id is not null and ts >= 1412 and ts <= 1413) and not (user_id = 1 and user_id is not null and ts >= 1414 and ts <= 1415) and not (user_id = 1 and user_id is not null and ts >= 1416 and ts <= 1417) and not (user_id = 1 and user_id is not null and ts >= 1418 and ts <= 1419) and not (user_id = 1 and user_id is not null and ts >= 1420 and ts <= 1421) and not (user_id = 1 and user_id is not null and ts >= 1422 and ts <= 1423) and not (user_id = 1 and user_id is not null and ts >= 1424 and ts <= 1425) and not (user_id = 1 and user_id is not null and ts >= 1426 and ts <= 1427) and not (user_id = 1 and user_id is not null and ts >= 1428 and ts <= 1429) and not (user_id = 1 and user_id is not null and ts >= 1430 and ts <= 1431) and not (user_id = 1 and user_id is not null and ts >= 1432 and ts <= 1433) and not (user_id = 1 and user_id is not null and ts >= 1434 and ts <= 1435) and not (user_id = 1 and user_id is not null and ts >= 1436 and ts <= 1437) and not (user_id = 1 and user_id is not null and ts >= 1438 and ts <= 1439) and not (user_id = 1 and user_id is not null and ts >= 1440 and ts <= 1441) and not (user_id = 1 and user_id is not null and ts >= 1442 and ts <= 1443) and not (user_id = 1 and user_id is not null and ts >= 1444 and ts <= 1445) and not (user_id = 1 and user_id is not null and ts >= 1446 and ts <= 1447) and not (user_id = 1 and user_id is not null and ts >= 1448 and ts <= 1449) and not (user_id = 1 and user_id is not null and ts >= 1450 and ts <= 1451) and not (user_id = 1 and user_id is not null and ts >= 1452 and ts <= 1453) and not (user_id = 1 and user_id is not null and ts >= 1454 and ts <= 1455) and not (user_id = 1 and user_id is not null and ts >= 1456 and ts <= 1457) and not (user_id = 1 and user_id is not null and ts >= 1458 and ts <= 1459) and not (user_id = 1 and user_id is not null and ts >= 1460 and ts <= 1461) and not (user_id = 1 and user_id is not null and ts >= 1462 and ts <= 1463) and not (user_id = 1 and user_id is not null and ts >= 1464 and ts <= 1465) and not (user_id = 1 and user_id is not null and ts >= 1466 and ts <= 1467) and not (user_id = 1 and user_id is not null and ts >= 1468 and ts <= 1469) and not (user_id = 1 and user_id is not null and ts >= 1470 and ts <= 1471) and not (user_id = 1 and user_id is not null and ts >= 1472 and ts <= 1473) and not (user_id = 1 and user_id is not null and ts >= 1474 and ts <= 1475) and not (user_id = 1 and user_id is not null and ts >= 1476 and ts <= 1477) and not (user_id = 1 and user_id is not null and ts >= 1478 and ts <= 1479) and not (user_id = 1 and user_id is not null and ts >= 1480 and ts <= 1481) and not (user_id = 1 and user_id is not null and ts >= 1482 and ts <= 1483) and not (user_id = 1 and user_id is not null and ts >= 1484 and ts <= 1485) and not (user_id = 1 and user_id is not null and ts >= 1486 and ts <= 1487) and not (user_id = 1 and user_id is not null and ts >= 1488 and ts <= 1489) and not (user_id = 1 and user_id is not null and ts >= 1490 and ts <= 1491) and not (user_id = 1 and user_id is not null and ts >= 1492 and ts <= 1493) and not (user_id = 1 and user_id is not null and ts >= 1494 and ts <= 1495) and not (user_id = 1 and user_id is not null and ts >= 1496 and ts <= 1497) and not (user_id = 1 and user_id is not null and ts >= 1498 and ts <= 1499) and not (user_id = 1 and user_id is not null and ts >= 1500 and ts <= 1501) and not (user_id = 1 and user_id is not null and ts >= 1502 and ts <= 1503) and not (user_id = 1 and user_id is not null and ts >= 1504 and ts <= 1505) and not (user_id = 1 and user_id is not null and ts >= 1506 and ts <= 1507) and not (user_id = 1 and user_id is not null and ts >= 1508 and ts <= 1509) and not (user_id = 1 and user_id is not null and ts >= 1510 and ts <= 1511) and not (user_id = 1 and user_id is not null and ts >= 1512 and ts <= 1513) and not (user_id = 1 and user_id is not null and ts >= 1514 and ts <= 1515) and not (user_id = 1 and user_id is not null and ts >= 1516 and ts <= 1517) and not (user_id = 1 and user_id is not null and ts >= 1518 and ts <= 1519) and not (user_id = 1 and user_id is not null and ts >= 1520 and ts <= 1521) and not (user_id = 1 and user_id is not null and ts >= 1522 and ts <= 1523) and not (user_id = 1 and user_id is not null and ts >= 1524 and ts <= 1525) and not (user_id = 1 and user_id is not null and ts >= 1526 and ts <= 1527) and not (user_id = 1 and user_id is not null and ts >= 1528 and ts <= 1529) and not (user_id = 1 and user_id is not null and ts >= 1530 and ts <= 1531) and not (user_id = 1 and user_id is not null and ts >= 1532 and ts <= 1533) and not (user_id = 1 and user_id is not null and ts >= 1534 and ts <= 1535) and not (user_id = 1 and user_id is not null and ts >= 1536 and ts <= 1537) and not (user_id = 1 and user_id is not null and ts >= 1538 and ts <= 1539) and not (user_id = 1 and user_id is not null and ts >= 1540 and ts <= 1541) and not (user_id = 1 and user_id is not null and ts >= 1542 and ts <= 1543) and not (user_id = 1 and user_id is not null and ts >= 1544 and ts <= 1545) and not (user_id = 1 and user_id is not null and ts >= 1546 and ts <= 1547) and not (user_id = 1 and user_id is not null and ts >= 1548 and ts <= 1549) and not (user_id = 1 and user_id is not null and ts >= 1550 and ts <= 1551) and not (user_id = 1 and user_id is not null and ts >= 1552 and ts <= 1553) and not (user_id = 1 and user_id is not null and ts >= 1554 and ts <= 1555) and not (user_id = 1 and user_id is not null and ts >= 1556 and ts <= 1557) and not (user_id = 1 and user_id is not null and ts >= 1558 and ts <= 1559) and not (user_id = 1 and user_id is not null and ts >= 1560 and ts <= 1561) and not (user_id = 1 and user_id is not null and ts >= 1562 and ts <= 1563) and not (user_id = 1 and user_id is not null and ts >= 1564 and ts <= 1565) and not (user_id = 1 and user_id is not null and ts >= 1566 and ts <= 1567) and not (user_id = 1 and user_id is not null and ts >= 1568 and ts <= 1569) and not (user_id = 1 and user_id is not null and ts >= 1570 and ts <= 1571) and not (user_id = 1 and user_id is not null and ts >= 1572 and ts <= 1573) and not (user_id = 1 and user_id is not null and ts >= 1574 and ts <= 1575) and not (user_id = 1 and user_id is not null and ts >= 1576 and ts <= 1577) and not (user_id = 1 and user_id is not null and ts >= 1578 and ts <= 1579) and not (user_id = 1 and user_id is not null and ts >= 1580 and ts <= 1581) and not (user_id = 1 and user_id is not null and ts >= 1582 and ts <= 1583) and not (user_id = 1 and user_id is not null and ts >= 1584 and ts <= 1585) and not (user_id = 1 and user_id is not null and ts >= 1586 and ts <= 1587) and not (user_id = 1 and user_id is not null and ts >= 1588 and ts <= 1589) and not (user_id = 1 and user_id is not null and ts >= 1590 and ts <= 1591) and not (user_id = 1 and user_id is not null and ts >= 1592 and ts <= 1593) and not (user_id = 1 and user_id is not null and ts >= 1594 and ts <= 1595) and not (user_id = 1 and user_id is not null and ts >= 1596 and ts <= 1597) and not (user_id = 1 and user_id is not null and ts >= 1598 and ts <= 1599) and not (user_id = 1 and user_id is not null and ts >= 1600 and ts <= 1601) and not (user_id = 1 and user_id is not null and ts >= 1602 and ts <= 1603) and not (user_id = 1 and user_id is not null and ts >= 1604 and ts <= 1605) and not (user_id = 1 and user_id is not null and ts >= 1606 and ts <= 1607) and not (user_id = 1 and user_id is not null and ts >= 1608 and ts <= 1609) and not (user_id = 1 and user_id is not null and ts >= 1610 and ts <= 1611) and not (user_id = 1 and user_id is not null and ts >= 1612 and ts <= 1613) and not (user_id = 1 and user_id is not null and ts >= 1614 and ts <= 1615) and not (user_id = 1 and user_id is not null and ts >= 1616 and ts <= 1617) and not (user_id = 1 and user_id is not null and ts >= 1618 and ts <= 1619) and not (user_id = 1 and user_id is not null and ts >= 1620 and ts <= 1621) and not (user_id = 1 and user_id is not null and ts >= 1622 and ts <= 1623) and not (user_id = 1 and user_id is not null and ts >= 1624 and ts <= 1625) and not (user_id = 1 and user_id is not null and ts >= 1626 and ts <= 1627) and not (user_id = 1 and user_id is not null and ts >= 1628 and ts <= 1629) and not (user_id = 1 and user_id is not null and ts >= 1630 and ts <= 1631) and not (user_id = 1 and user_id is not null and ts >= 1632 and ts <= 1633) and not (user_id = 1 and user_id is not null and ts >= 1634 and ts <= 1635) and not (user_id = 1 and user_id is not null and ts >= 1636 and ts <= 1637) and not (user_id = 1 and user_id is not null and ts >= 1638 and ts <= 1639) and not (user_id = 1 and user_id is not null and ts >= 1640 and ts <= 1641) and not (user_id = 1 and user_id is not null and ts >= 1642 and ts <= 1643) and not (user_id = 1 and user_id is not null and ts >= 1644 and ts <= 1645) and not (user_id = 1 and user_id is not null and ts >= 1646 and ts <= 1647) and not (user_id = 1 and user_id is not null and ts >= 1648 and ts <= 1649) and not (user_id = 1 and user_id is not null and ts >= 1650 and ts <= 1651) and not (user_id = 1 and user_id is not null and ts >= 1652 and ts <= 1653) and not (user_id = 1 and user_id is not null and ts >= 1654 and ts <= 1655) and not (user_id = 1 and user_id is not null and ts >= 1656 and ts <= 1657) and not (user_id = 1 and user_id is not null and ts >= 1658 and ts <= 1659) and not (user_id = 1 and user_id is not null and ts >= 1660 and ts <= 1661) and not (user_id = 1 and user_id is not null and ts >= 1662 and ts <= 1663) and not (user_id = 1 and user_id is not null and ts >= 1664 and ts <= 1665) and not (user_id = 1 and user_id is not null and ts >= 1666 and ts <= 1667) and not (user_id = 1 and user_id is not null and ts >= 1668 and ts <= 1669) and not (user_id = 1 and user_id is not null and ts >= 1670 and ts <= 1671) and not (user_id = 1 and user_id is not null and ts >= 1672 and ts <= 1673) and not (user_id = 1 and user_id is not null and ts >= 1674 and ts <= 1675) and not (user_id = 1 and user_id is not null and ts >= 1676 and ts <= 1677) and not (user_id = 1 and user_id is not null and ts >= 1678 and ts <= 1679) and not (user_id = 1 and user_id is not null and ts >= 1680 and ts <= 1681) and not (user_id = 1 and user_id is not null and ts >= 1682 and ts <= 1683) and not (user_id = 1 and user_id is not null and ts >= 1684 and ts <= 1685) and not (user_id = 1 and user_id is not null and ts >= 1686 and ts <= 1687) and not (user_id = 1 and user_id is not null and ts >= 1688 and ts <= 1689) and not (user_id = 1 and user_id is not null and ts >= 1690 and ts <= 1691) and not (user_id = 1 and user_id is not null and ts >= 1692 and ts <= 1693) and not (user_id = 1 and user_id is not null and ts >= 1694 and ts <= 1695) and not (user_id = 1 and user_id is not null and ts >= 1696 and ts <= 1697) and not (user_id = 1 and user_id is not null and ts >= 1698 and ts <= 1699) and not (user_id = 1 and user_id is not null and ts >= 1700 and ts <= 1701) and not (user_id = 1 and user_id is not null and ts >= 1702 and ts <= 1703) and not (user_id = 1 and user_id is not null and ts >= 1704 and ts <= 1705) and not (user_id = 1 and user_id is not null and ts >= 1706 and ts <= 1707) and not (user_id = 1 and user_id is not null and ts >= 1708 and ts <= 1709) and not (user_id = 1 and user_id is not null and ts >= 1710 and ts <= 1711) and not (user_id = 1 and user_id is not null and ts >= 1712 and ts <= 1713) and not (user_id = 1 and user_id is not null and ts >= 1714 and ts <= 1715) and not (user_id = 1 and user_id is not null and ts >= 1716 and ts <= 1717) and not (user_id = 1 and user_id is not null and ts >= 1718 and ts <= 1719) and not (user_id = 1 and user_id is not null and ts >= 1720 and ts <= 1721) and not (user_id = 1 and user_id is not null and ts >= 1722 and ts <= 1723) and not (user_id = 1 and user_id is not null and ts >= 1724 and ts <= 1725) and not (user_id = 1 and user_id is not null and ts >= 1726 and ts <= 1727) and not (user_id = 1 and user_id is not null and ts >= 1728 and ts <= 1729) and not (user_id = 1 and user_id is not null and ts >= 1730 and ts <= 1731) and not (user_id = 1 and user_id is not null and ts >= 1732 and ts <= 1733) and not (user_id = 1 and user_id is not null and ts >= 1734 and ts <= 1735) and not (user_id = 1 and user_id is not null and ts >= 1736 and ts <= 1737) and not (user_id = 1 and user_id is not null and ts >= 1738 and ts <= 1739) and not (user_id = 1 and user_id is not null and ts >= 1740 and ts <= 1741) and not (user_id = 1 and user_id is not null and ts >= 1742 and ts <= 1743) and not (user_id = 1 and user_id is not null and ts >= 1744 and ts <= 1745) and not (user_id = 1 and user_id is not null and ts >= 1746 and ts <= 1747) and not (user_id = 1 and user_id is not null and ts >= 1748 and ts <= 1749) and not (user_id = 1 and user_id is not null and ts >= 1750 and ts <= 1751) and not (user_id = 1 and user_id is not null and ts >= 1752 and ts <= 1753) and not (user_id = 1 and user_id is not null and ts >= 1754 and ts <= 1755) and not (user_id = 1 and user_id is not null and ts >= 1756 and ts <= 1757) and not (user_id = 1 and user_id is not null and ts >= 1758 and ts <= 1759) and not (user_id = 1 and user_id is not null and ts >= 1760 and ts <= 1761) and not (user_id = 1 and user_id is not null and ts >= 1762 and ts <= 1763) and not (user_id = 1 and user_id is not null and ts >= 1764 and ts <= 1765) and not (user_id = 1 and user_id is not null and ts >= 1766 and ts <= 1767) and not (user_id = 1 and user_id is not null and ts >= 1768 and ts <= 1769) and not (user_id = 1 and user_id is not null and ts >= 1770 and ts <= 1771) and not (user_id = 1 and user_id is not null and ts >= 1772 and ts <= 1773) and not (user_id = 1 and user_id is not null and ts >= 1774 and ts <= 1775) and not (user_id = 1 and user_id is not null and ts >= 1776 and ts <= 1777) and not (user_id = 1 and user_id is not null and ts >= 1778 and ts <= 1779) and not (user_id = 1 and user_id is not null and ts >= 1780 and ts <= 1781) and not (user_id = 1 and user_id is not null and ts >= 1782 and ts <= 1783) and not (user_id = 1 and user_id is not null and ts >= 1784 and ts <= 1785) and not (user_id = 1 and user_id is not null and ts >= 1786 and ts <= 1787) and not (user_id = 1 and user_id is not null and ts >= 1788 and ts <= 1789) and not (user_id = 1 and user_id is not null and ts >= 1790 and ts <= 1791) and not (user_id = 1 and user_id is not null and ts >= 1792 and ts <= 1793) and not (user_id = 1 and user_id is not null and ts >= 1794 and ts <= 1795) and not (user_id = 1 and user_id is not null and ts >= 1796 and ts <= 1797) and not (user_id = 1 and user_id is not null and ts >= 1798 and ts <= 1799) and not (user_id = 1 and user_id is not null and ts >= 1800 and ts <= 1801) and not (user_id = 1 and user_id is not null and ts >= 1802 and ts <= 1803) and not (user_id = 1 and user_id is not null and ts >= 1804 and ts <= 1805) and not (user_id = 1 and user_id is not null and ts >= 1806 and ts <= 1807) and not (user_id = 1 and user_id is not null and ts >= 1808 and ts <= 1809) and not (user_id = 1 and user_id is not null and ts >= 1810 and ts <= 1811) and not (user_id = 1 and user_id is not null and ts >= 1812 and ts <= 1813) and not (user_id = 1 and user_id is not null and ts >= 1814 and ts <= 1815) and not (user_id = 1 and user_id is not null and ts >= 1816 and ts <= 1817) and not (user_id = 1 and user_id is not null and ts >= 1818 and ts <= 1819) and not (user_id = 1 and user_id is not null and ts >= 1820 and ts <= 1821) and not (user_id = 1 and user_id is not null and ts >= 1822 and ts <= 1823) and not (user_id = 1 and user_id is not null and ts >= 1824 and ts <= 1825) and not (user_id = 1 and user_id is not null and ts >= 1826 and ts <= 1827) and not (user_id = 1 and user_id is not null and ts >= 1828 and ts <= 1829) and not (user_id = 1 and user_id is not null and ts >= 1830 and ts <= 1831) and not (user_id = 1 and user_id is not null and ts >= 1832 and ts <= 1833) and not (user_id = 1 and user_id is not null and ts >= 1834 and ts <= 1835) and not (user_id = 1 and user_id is not null and ts >= 1836 and ts <= 1837) and not (user_id = 1 and user_id is not null and ts >= 1838 and ts <= 1839) and not (user_id = 1 and user_id is not null and ts >= 1840 and ts <= 1841) and not (user_id = 1 and user_id is not null and ts >= 1842 and ts <= 1843) and not (user_id = 1 and user_id is not null and ts >= 1844 and ts <= 1845) and not (user_id = 1 and user_id is not null and ts >= 1846 and ts <= 1847) and not (user_id = 1 and user_id is not null and ts >= 1848 and ts <= 1849) and not (user_id = 1 and user_id is not null and ts >= 1850 and ts <= 1851) and not (user_id = 1 and user_id is not null and ts >= 1852 and ts <= 1853) and not (user_id = 1 and user_id is not null and ts >= 1854 and ts <= 1855) and not (user_id = 1 and user_id is not null and ts >= 1856 and ts <= 1857) and not (user_id = 1 and user_id is not null and ts >= 1858 and ts <= 1859) and not (user_id = 1 and user_id is not null and ts >= 1860 and ts <= 1861) and not (user_id = 1 and user_id is not null and ts >= 1862 and ts <= 1863) and not (user_id = 1 and user_id is not null and ts >= 1864 and ts <= 1865) and not (user_id = 1 and user_id is not null and ts >= 1866 and ts <= 1867) and not (user_id = 1 and user_id is not null and ts >= 1868 and ts <= 1869) and not (user_id = 1 and user_id is not null and ts >= 1870 and ts <= 1871) and not (user_id = 1 and user_id is not null and ts >= 1872 and ts <= 1873) and not (user_id = 1 and user_id is not null and ts >= 1874 and ts <= 1875) and not (user_id = 1 and user_id is not null and ts >= 1876 and ts <= 1877) and not (user_id = 1 and user_id is not null and ts >= 1878 and ts <= 1879) and not (user_id = 1 and user_id is not null and ts >= 1880 and ts <= 1881) and not (user_id = 1 and user_id is not null and ts >= 1882 and ts <= 1883) and not (user_id = 1 and user_id is not null and ts >= 1884 and ts <= 1885) and not (user_id = 1 and user_id is not null and ts >= 1886 and ts <= 1887) and not (user_id = 1 and user_id is not null and ts >= 1888 and ts <= 1889) and not (user_id = 1 and user_id is not null and ts >= 1890 and ts <= 1891) and not (user_id = 1 and user_id is not null and ts >= 1892 and ts <= 1893) and not (user_id = 1 and user_id is not null and ts >= 1894 and ts <= 1895) and not (user_id = 1 and user_id is not null and ts >= 1896 and ts <= 1897) and not (user_id = 1 and user_id is not null and ts >= 1898 and ts <= 1899) and not (user_id = 1 and user_id is not null and ts >= 1900 and ts <= 1901) and not (user_id = 1 and user_id is not null and ts >= 1902 and ts <= 1903) and not (user_id = 1 and user_id is not null and ts >= 1904 and ts <= 1905) and not (user_id = 1 and user_id is not null and ts >= 1906 and ts <= 1907) and not (user_id = 1 and user_id is not null and ts >= 1908 and ts <= 1909) and not (user_id = 1 and user_id is not null and ts >= 1910 and ts <= 1911) and not (user_id = 1 and user_id is not null and ts >= 1912 and ts <= 1913) and not (user_id = 1 and user_id is not null and ts >= 1914 and ts <= 1915) and not (user_id = 1 and user_id is not null and ts >= 1916 and ts <= 1917) and not (user_id = 1 and user_id is not null and ts >= 1918 and ts <= 1919) and not (user_id = 1 and user_id is not null and ts >= 1920 and ts <= 1921) and not (user_id = 1 and user_id is not null and ts >= 1922 and ts <= 1923) and not (user_id = 1 and user_id is not null and ts >= 1924 and ts <= 1925) and not (user_id = 1 and user_id is not null and ts >= 1926 and ts <= 1927) and not (user_id = 1 and user_id is not null and ts >= 1928 and ts <= 1929) and not (user_id = 1 and user_id is not null and ts >= 1930 and ts <= 1931) and not (user_id = 1 and user_id is not null and ts >= 1932 and ts <= 1933) and not (user_id = 1 and user_id is not null and ts >= 1934 and ts <= 1935) and not (user_id = 1 and user_id is not null and ts >= 1936 and ts <= 1937) and not (user_id = 1 and user_id is not null and ts >= 1938 and ts <= 1939) and not (user_id = 1 and user_id is not null and ts >= 1940 and ts <= 1941) and not (user_id = 1 and user_id is not null and ts >= 1942 and ts <= 1943) and not (user_id = 1 and user_id is not null and ts >= 1944 and ts <= 1945) and not (user_id = 1 and user_id is not null and ts >= 1946 and ts <= 1947) and not (user_id = 1 and user_id is not null and ts >= 1948 and ts <= 1949) and not (user_id = 1 and user_id is not null and ts >= 1950 and ts <= 1951) and not (user_id = 1 and user_id is not null and ts >= 1952 and ts <= 1953) and not (user_id = 1 and user_id is not null and ts >= 1954 and ts <= 1955) and not (user_id = 1 and user_id is not null and ts >= 1956 and ts <= 1957) and not (user_id = 1 and user_id is not null and ts >= 1958 and ts <= 1959) and not (user_id = 1 and user_id is not null and ts >= 1960 and ts <= 1961) and not (user_id = 1 and user_id is not null and ts >= 1962 and ts <= 1963) and not (user_id = 1 and user_id is not null and ts >= 1964 and ts <= 1965) and not (user_id = 1 and user_id is not null and ts >= 1966 and ts <= 1967) and not (user_id = 1 and user_id is not null and ts >= 1968 and ts <= 1969) and not (user_id = 1 and user_id is not null and ts >= 1970 and ts <= 1971) and not (user_id = 1 and user_id is not null and ts >= 1972 and ts <= 1973) and not (user_id = 1 and user_id is not null and ts >= 1974 and ts <= 1975) and not (user_id = 1 and user_id is not null and ts >= 1976 and ts <= 1977) and not (user_id = 1 and user_id is not null and ts >= 1978 and ts <= 1979) and not (user_id = 1 and user_id is not null and ts >= 1980 and ts <= 1981) and not (user_id = 1 and user_id is not null and ts >= 1982 and ts <= 1983) and not (user_id = 1 and user_id is not null and ts >= 1984 and ts <= 1985) and not (user_id = 1 and user_id is not null and ts >= 1986 and ts <= 1987) and not (user_id = 1 and user_id is not null and ts >= 1988 and ts <= 1989) and not (user_id = 1 and user_id is not null and ts >= 1990 and ts <= 1991) and not (user_id = 1 and user_id is not null and ts >= 1992 and ts <= 1993) and not (user_id = 1 and user_id is not null and ts >= 1994 and ts <= 1995) and not (user_id = 1 and user_id is not null and ts >= 1996 and ts <= 1997) and not (user_id = 1 and user_id is not null and ts >= 1998 and ts <= 1999) and not (user_id = 1 and user_id is not null and ts >= 11000 and ts <= 11001) and not (user_id = 1 and user_id is not null and ts >= 11002 and ts <= 11003) and not (user_id = 1 and user_id is not null and ts >= 11004 and ts <= 11005) and not (user_id = 1 and user_id is not null and ts >= 11006 and ts <= 11007) and not (user_id = 1 and user_id is not null and ts >= 11008 and ts <= 11009) and not (user_id = 1 and user_id is not null and ts >= 11010 and ts <= 11011) and not (user_id = 1 and user_id is not null and ts >= 11012 and ts <= 11013) and not (user_id = 1 and user_id is not null and ts >= 11014 and ts <= 11015) and not (user_id = 1 and user_id is not null and ts >= 11016 and ts <= 11017) and not (user_id = 1 and user_id is not null and ts >= 11018 and ts <= 11019) and not (user_id = 1 and user_id is not null and ts >= 11020 and ts <= 11021) and not (user_id = 1 and user_id is not null and ts >= 11022 and ts <= 11023) and not (user_id = 1 and user_id is not null and ts >= 11024 and ts <= 11025) and not (user_id = 1 and user_id is not null and ts >= 11026 and ts <= 11027) and not (user_id = 1 and user_id is not null and ts >= 11028 and ts <= 11029) and not (user_id = 1 and user_id is not null and ts >= 11030 and ts <= 11031) and not (user_id = 1 and user_id is not null and ts >= 11032 and ts <= 11033) and not (user_id = 1 and user_id is not null and ts >= 11034 and ts <= 11035) and not (user_id = 1 and user_id is not null and ts >= 11036 and ts <= 11037) and not (user_id = 1 and user_id is not null and ts >= 11038 and ts <= 11039) and not (user_id = 1 and user_id is not null and ts >= 11040 and ts <= 11041) and not (user_id = 1 and user_id is not null and ts >= 11042 and ts <= 11043) and not (user_id = 1 and user_id is not null and ts >= 11044 and ts <= 11045) and not (user_id = 1 and user_id is not null and ts >= 11046 and ts <= 11047) and not (user_id = 1 and user_id is not null and ts >= 11048 and ts <= 11049) and not (user_id = 1 and user_id is not null and ts >= 11050 and ts <= 11051) and not (user_id = 1 and user_id is not null and ts >= 11052 and ts <= 11053) and not (user_id = 1 and user_id is not null and ts >= 11054 and ts <= 11055) and not (user_id = 1 and user_id is not null and ts >= 11056 and ts <= 11057) and not (user_id = 1 and user_id is not null and ts >= 11058 and ts <= 11059) and not (user_id = 1 and user_id is not null and ts >= 11060 and ts <= 11061) and not (user_id = 1 and user_id is not null and ts >= 11062 and ts <= 11063) and not (user_id = 1 and user_id is not null and ts >= 11064 and ts <= 11065) and not (user_id = 1 and user_id is not null and ts >= 11066 and ts <= 11067) and not (user_id = 1 and user_id is not null and ts >= 11068 and ts <= 11069) and not (user_id = 1 and user_id is not null and ts >= 11070 and ts <= 11071) and not (user_id = 1 and user_id is not null and ts >= 11072 and ts <= 11073) and not (user_id = 1 and user_id is not null and ts >= 11074 and ts <= 11075) and not (user_id = 1 and user_id is not null and ts >= 11076 and ts <= 11077) and not (user_id = 1 and user_id is not null and ts >= 11078 and ts <= 11079) and not (user_id = 1 and user_id is not null and ts >= 11080 and ts <= 11081) and not (user_id = 1 and user_id is not null and ts >= 11082 and ts <= 11083) and not (user_id = 1 and user_id is not null and ts >= 11084 and ts <= 11085) and not (user_id = 1 and user_id is not null and ts >= 11086 and ts <= 11087) and not (user_id = 1 and user_id is not null and ts >= 11088 and ts <= 11089) and not (user_id = 1 and user_id is not null and ts >= 11090 and ts <= 11091) and not (user_id = 1 and user_id is not null and ts >= 11092 and ts <= 11093) and not (user_id = 1 and user_id is not null and ts >= 11094 and ts <= 11095) and not (user_id = 1 and user_id is not null and ts >= 11096 and ts <= 11097) and not (user_id = 1 and user_id is not null and ts >= 11098 and ts <= 11099) and not (user_id = 1 and user_id is not null and ts >= 11100 and ts <= 11101) and not (user_id = 1 and user_id is not null and ts >= 11102 and ts <= 11103) and not (user_id = 1 and user_id is not null and ts >= 11104 and ts <= 11105) and not (user_id = 1 and user_id is not null and ts >= 11106 and ts <= 11107) and not (user_id = 1 and user_id is not null and ts >= 11108 and ts <= 11109) and not (user_id = 1 and user_id is not null and ts >= 11110 and ts <= 11111) and not (user_id = 1 and user_id is not null and ts >= 11112 and ts <= 11113) and not (user_id = 1 and user_id is not null and ts >= 11114 and ts <= 11115) and not (user_id = 1 and user_id is not null and ts >= 11116 and ts <= 11117) and not (user_id = 1 and user_id is not null and ts >= 11118 and ts <= 11119) and not (user_id = 1 and user_id is not null and ts >= 11120 and ts <= 11121) and not (user_id = 1 and user_id is not null and ts >= 11122 and ts <= 11123) and not (user_id = 1 and user_id is not null and ts >= 11124 and ts <= 11125) and not (user_id = 1 and user_id is not null and ts >= 11126 and ts <= 11127) and not (user_id = 1 and user_id is not null and ts >= 11128 and ts <= 11129) and not (user_id = 1 and user_id is not null and ts >= 11130 and ts <= 11131) and not (user_id = 1 and user_id is not null and ts >= 11132 and ts <= 11133) and not (user_id = 1 and user_id is not null and ts >= 11134 and ts <= 11135) and not (user_id = 1 and user_id is not null and ts >= 11136 and ts <= 11137) and not (user_id = 1 and user_id is not null and ts >= 11138 and ts <= 11139) and not (user_id = 1 and user_id is not null and ts >= 11140 and ts <= 11141) and not (user_id = 1 and user_id is not null and ts >= 11142 and ts <= 11143) and not (user_id = 1 and user_id is not null and ts >= 11144 and ts <= 11145) and not (user_id = 1 and user_id is not null and ts >= 11146 and ts <= 11147) and not (user_id = 1 and user_id is not null and ts >= 11148 and ts <= 11149) and not (user_id = 1 and user_id is not null and ts >= 11150 and ts <= 11151) and not (user_id = 1 and user_id is not null and ts >= 11152 and ts <= 11153) and not (user_id = 1 and user_id is not null and ts >= 11154 and ts <= 11155) and not (user_id = 1 and user_id is not null and ts >= 11156 and ts <= 11157) and not (user_id = 1 and user_id is not null and ts >= 11158 and ts <= 11159) and not (user_id = 1 and user_id is not null and ts >= 11160 and ts <= 11161) and not (user_id = 1 and user_id is not null and ts >= 11162 and ts <= 11163) and not (user_id = 1 and user_id is not null and ts >= 11164 and ts <= 11165) and not (user_id = 1 and user_id is not null and ts >= 11166 and ts <= 11167) and not (user_id = 1 and user_id is not null and ts >= 11168 and ts <= 11169) and not (user_id = 1 and user_id is not null and ts >= 11170 and ts <= 11171) and not (user_id = 1 and user_id is not null and ts >= 11172 and ts <= 11173) and not (user_id = 1 and user_id is not null and ts >= 11174 and ts <= 11175) and not (user_id = 1 and user_id is not null and ts >= 11176 and ts <= 11177) and not (user_id = 1 and user_id is not null and ts >= 11178 and ts <= 11179) and not (user_id = 1 and user_id is not null and ts >= 11180 and ts <= 11181) and not (user_id = 1 and user_id is not null and ts >= 11182 and ts <= 11183) and not (user_id = 1 and user_id is not null and ts >= 11184 and ts <= 11185) and not (user_id = 1 and user_id is not null and ts >= 11186 and ts <= 11187) and not (user_id = 1 and user_id is not null and ts >= 11188 and ts <= 11189) and not (user_id = 1 and user_id is not null and ts >= 11190 and ts <= 11191) and not (user_id = 1 and user_id is not null and ts >= 11192 and ts <= 11193) and not (user_id = 1 and user_id is not null and ts >= 11194 and ts <= 11195) and not (user_id = 1 and user_id is not null and ts >= 11196 and ts <= 11197) and not (user_id = 1 and user_id is not null and ts >= 11198 and ts <= 11199) and not (user_id = 1 and user_id is not null and ts >= 11200 and ts <= 11201) and not (user_id = 1 and user_id is not null and ts >= 11202 and ts <= 11203) and not (user_id = 1 and user_id is not null and ts >= 11204 and ts <= 11205) and not (user_id = 1 and user_id is not null and ts >= 11206 and ts <= 11207) and not (user_id = 1 and user_id is not null and ts >= 11208 and ts <= 11209) and not (user_id = 1 and user_id is not null and ts >= 11210 and ts <= 11211) and not (user_id = 1 and user_id is not null and ts >= 11212 and ts <= 11213) and not (user_id = 1 and user_id is not null and ts >= 11214 and ts <= 11215) and not (user_id = 1 and user_id is not null and ts >= 11216 and ts <= 11217) and not (user_id = 1 and user_id is not null and ts >= 11218 and ts <= 11219) and not (user_id = 1 and user_id is not null and ts >= 11220 and ts <= 11221) and not (user_id = 1 and user_id is not null and ts >= 11222 and ts <= 11223) and not (user_id = 1 and user_id is not null and ts >= 11224 and ts <= 11225) and not (user_id = 1 and user_id is not null and ts >= 11226 and ts <= 11227) and not (user_id = 1 and user_id is not null and ts >= 11228 and ts <= 11229) and not (user_id = 1 and user_id is not null and ts >= 11230 and ts <= 11231) and not (user_id = 1 and user_id is not null and ts >= 11232 and ts <= 11233) and not (user_id = 1 and user_id is not null and ts >= 11234 and ts <= 11235) and not (user_id = 1 and user_id is not null and ts >= 11236 and ts <= 11237) and not (user_id = 1 and user_id is not null and ts >= 11238 and ts <= 11239) and not (user_id = 1 and user_id is not null and ts >= 11240 and ts <= 11241) and not (user_id = 1 and user_id is not null and ts >= 11242 and ts <= 11243) and not (user_id = 1 and user_id is not null and ts >= 11244 and ts <= 11245) and not (user_id = 1 and user_id is not null and ts >= 11246 and ts <= 11247) and not (user_id = 1 and user_id is not null and ts >= 11248 and ts <= 11249) and not (user_id = 1 and user_id is not null and ts >= 11250 and ts <= 11251) and not (user_id = 1 and user_id is not null and ts >= 11252 and ts <= 11253) and not (user_id = 1 and user_id is not null and ts >= 11254 and ts <= 11255) and not (user_id = 1 and user_id is not null and ts >= 11256 and ts <= 11257) and not (user_id = 1 and user_id is not null and ts >= 11258 and ts <= 11259) and not (user_id = 1 and user_id is not null and ts >= 11260 and ts <= 11261) and not (user_id = 1 and user_id is not null and ts >= 11262 and ts <= 11263) and not (user_id = 1 and user_id is not null and ts >= 11264 and ts <= 11265) and not (user_id = 1 and user_id is not null and ts >= 11266 and ts <= 11267) and not (user_id = 1 and user_id is not null and ts >= 11268 and ts <= 11269) and not (user_id = 1 and user_id is not null and ts >= 11270 and ts <= 11271) and not (user_id = 1 and user_id is not null and ts >= 11272 and ts <= 11273) and not (user_id = 1 and user_id is not null and ts >= 11274 and ts <= 11275) and not (user_id = 1 and user_id is not null and ts >= 11276 and ts <= 11277) and not (user_id = 1 and user_id is not null and ts >= 11278 and ts <= 11279) and not (user_id = 1 and user_id is not null and ts >= 11280 and ts <= 11281) and not (user_id = 1 and user_id is not null and ts >= 11282 and ts <= 11283) and not (user_id = 1 and user_id is not null and ts >= 11284 and ts <= 11285) and not (user_id = 1 and user_id is not null and ts >= 11286 and ts <= 11287) and not (user_id = 1 and user_id is not null and ts >= 11288 and ts <= 11289) and not (user_id = 1 and user_id is not null and ts >= 11290 and ts <= 11291) and not (user_id = 1 and user_id is not null and ts >= 11292 and ts <= 11293) and not (user_id = 1 and user_id is not null and ts >= 11294 and ts <= 11295) and not (user_id = 1 and user_id is not null and ts >= 11296 and ts <= 11297) and not (user_id = 1 and user_id is not null and ts >= 11298 and ts <= 11299) and not (user_id = 1 and user_id is not null and ts >= 11300 and ts <= 11301) and not (user_id = 1 and user_id is not null and ts >= 11302 and ts <= 11303) and not (user_id = 1 and user_id is not null and ts >= 11304 and ts <= 11305) and not (user_id = 1 and user_id is not null and ts >= 11306 and ts <= 11307) and not (user_id = 1 and user_id is not null and ts >= 11308 and ts <= 11309) and not (user_id = 1 and user_id is not null and ts >= 11310 and ts <= 11311) and not (user_id = 1 and user_id is not null and ts >= 11312 and ts <= 11313) and not (user_id = 1 and user_id is not null and ts >= 11314 and ts <= 11315) and not (user_id = 1 and user_id is not null and ts >= 11316 and ts <= 11317) and not (user_id = 1 and user_id is not null and ts >= 11318 and ts <= 11319) and not (user_id = 1 and user_id is not null and ts >= 11320 and ts <= 11321) and not (user_id = 1 and user_id is not null and ts >= 11322 and ts <= 11323) and not (user_id = 1 and user_id is not null and ts >= 11324 and ts <= 11325) and not (user_id = 1 and user_id is not null and ts >= 11326 and ts <= 11327) and not (user_id = 1 and user_id is not null and ts >= 11328 and ts <= 11329) and not (user_id = 1 and user_id is not null and ts >= 11330 and ts <= 11331) and not (user_id = 1 and user_id is not null and ts >= 11332 and ts <= 11333) and not (user_id = 1 and user_id is not null and ts >= 11334 and ts <= 11335) and not (user_id = 1 and user_id is not null and ts >= 11336 and ts <= 11337) and not (user_id = 1 and user_id is not null and ts >= 11338 and ts <= 11339) and not (user_id = 1 and user_id is not null and ts >= 11340 and ts <= 11341) and not (user_id = 1 and user_id is not null and ts >= 11342 and ts <= 11343) and not (user_id = 1 and user_id is not null and ts >= 11344 and ts <= 11345) and not (user_id = 1 and user_id is not null and ts >= 11346 and ts <= 11347) and not (user_id = 1 and user_id is not null and ts >= 11348 and ts <= 11349) and not (user_id = 1 and user_id is not null and ts >= 11350 and ts <= 11351) and not (user_id = 1 and user_id is not null and ts >= 11352 and ts <= 11353) and not (user_id = 1 and user_id is not null and ts >= 11354 and ts <= 11355) and not (user_id = 1 and user_id is not null and ts >= 11356 and ts <= 11357) and not (user_id = 1 and user_id is not null and ts >= 11358 and ts <= 11359) and not (user_id = 1 and user_id is not null and ts >= 11360 and ts <= 11361) and not (user_id = 1 and user_id is not null and ts >= 11362 and ts <= 11363) and not (user_id = 1 and user_id is not null and ts >= 11364 and ts <= 11365) and not (user_id = 1 and user_id is not null and ts >= 11366 and ts <= 11367) and not (user_id = 1 and user_id is not null and ts >= 11368 and ts <= 11369) and not (user_id = 1 and user_id is not null and ts >= 11370 and ts <= 11371) and not (user_id = 1 and user_id is not null and ts >= 11372 and ts <= 11373) and not (user_id = 1 and user_id is not null and ts >= 11374 and ts <= 11375) and not (user_id = 1 and user_id is not null and ts >= 11376 and ts <= 11377) and not (user_id = 1 and user_id is not null and ts >= 11378 and ts <= 11379) and not (user_id = 1 and user_id is not null and ts >= 11380 and ts <= 11381) and not (user_id = 1 and user_id is not null and ts >= 11382 and ts <= 11383) and not (user_id = 1 and user_id is not null and ts >= 11384 and ts <= 11385) and not (user_id = 1 and user_id is not null and ts >= 11386 and ts <= 11387) and not (user_id = 1 and user_id is not null and ts >= 11388 and ts <= 11389) and not (user_id = 1 and user_id is not null and ts >= 11390 and ts <= 11391) and not (user_id = 1 and user_id is not null and ts >= 11392 and ts <= 11393) and not (user_id = 1 and user_id is not null and ts >= 11394 and ts <= 11395) and not (user_id = 1 and user_id is not null and ts >= 11396 and ts <= 11397) and not (user_id = 1 and user_id is not null and ts >= 11398 and ts <= 11399) and not (user_id = 1 and user_id is not null and ts >= 11400 and ts <= 11401) and not (user_id = 1 and user_id is not null and ts >= 11402 and ts <= 11403) and not (user_id = 1 and user_id is not null and ts >= 11404 and ts <= 11405) and not (user_id = 1 and user_id is not null and ts >= 11406 and ts <= 11407) and not (user_id = 1 and user_id is not null and ts >= 11408 and ts <= 11409) and not (user_id = 1 and user_id is not null and ts >= 11410 and ts <= 11411) and not (user_id = 1 and user_id is not null and ts >= 11412 and ts <= 11413) and not (user_id = 1 and user_id is not null and ts >= 11414 and ts <= 11415) and not (user_id = 1 and user_id is not null and ts >= 11416 and ts <= 11417) and not (user_id = 1 and user_id is not null and ts >= 11418 and ts <= 11419) and not (user_id = 1 and user_id is not null and ts >= 11420 and ts <= 11421) and not (user_id = 1 and user_id is not null and ts >= 11422 and ts <= 11423) and not (user_id = 1 and user_id is not null and ts >= 11424 and ts <= 11425) and not (user_id = 1 and user_id is not null and ts >= 11426 and ts <= 11427) and not (user_id = 1 and user_id is not null and ts >= 11428 and ts <= 11429) and not (user_id = 1 and user_id is not null and ts >= 11430 and ts <= 11431) and not (user_id = 1 and user_id is not null and ts >= 11432 and ts <= 11433) and not (user_id = 1 and user_id is not null and ts >= 11434 and ts <= 11435) and not (user_id = 1 and user_id is not null and ts >= 11436 and ts <= 11437) and not (user_id = 1 and user_id is not null and ts >= 11438 and ts <= 11439) and not (user_id = 1 and user_id is not null and ts >= 11440 and ts <= 11441) and not (user_id = 1 and user_id is not null and ts >= 11442 and ts <= 11443) and not (user_id = 1 and user_id is not null and ts >= 11444 and ts <= 11445) and not (user_id = 1 and user_id is not null and ts >= 11446 and ts <= 11447) and not (user_id = 1 and user_id is not null and ts >= 11448 and ts <= 11449) and not (user_id = 1 and user_id is not null and ts >= 11450 and ts <= 11451) and not (user_id = 1 and user_id is not null and ts >= 11452 and ts <= 11453) and not (user_id = 1 and user_id is not null and ts >= 11454 and ts <= 11455) and not (user_id = 1 and user_id is not null and ts >= 11456 and ts <= 11457) and not (user_id = 1 and user_id is not null and ts >= 11458 and ts <= 11459) and not (user_id = 1 and user_id is not null and ts >= 11460 and ts <= 11461) and not (user_id = 1 and user_id is not null and ts >= 11462 and ts <= 11463) and not (user_id = 1 and user_id is not null and ts >= 11464 and ts <= 11465) and not (user_id = 1 and user_id is not null and ts >= 11466 and ts <= 11467) and not (user_id = 1 and user_id is not null and ts >= 11468 and ts <= 11469) and not (user_id = 1 and user_id is not null and ts >= 11470 and ts <= 11471) and not (user_id = 1 and user_id is not null and ts >= 11472 and ts <= 11473) and not (user_id = 1 and user_id is not null and ts >= 11474 and ts <= 11475) and not (user_id = 1 and user_id is not null and ts >= 11476 and ts <= 11477) and not (user_id = 1 and user_id is not null and ts >= 11478 and ts <= 11479) and not (user_id = 1 and user_id is not null and ts >= 11480 and ts <= 11481) and not (user_id = 1 and user_id is not null and ts >= 11482 and ts <= 11483) and not (user_id = 1 and user_id is not null and ts >= 11484 and ts <= 11485) and not (user_id = 1 and user_id is not null and ts >= 11486 and ts <= 11487) and not (user_id = 1 and user_id is not null and ts >= 11488 and ts <= 11489) and not (user_id = 1 and user_id is not null and ts >= 11490 and ts <= 11491) and not (user_id = 1 and user_id is not null and ts >= 11492 and ts <= 11493) and not (user_id = 1 and user_id is not null and ts >= 11494 and ts <= 11495) and not (user_id = 1 and user_id is not null and ts >= 11496 and ts <= 11497) and not (user_id = 1 and user_id is not null and ts >= 11498 and ts <= 11499) and not (user_id = 1 and user_id is not null and ts >= 11500 and ts <= 11501) and not (user_id = 1 and user_id is not null and ts >= 11502 and ts <= 11503) and not (user_id = 1 and user_id is not null and ts >= 11504 and ts <= 11505) and not (user_id = 1 and user_id is not null and ts >= 11506 and ts <= 11507) and not (user_id = 1 and user_id is not null and ts >= 11508 and ts <= 11509) and not (user_id = 1 and user_id is not null and ts >= 11510 and ts <= 11511) and not (user_id = 1 and user_id is not null and ts >= 11512 and ts <= 11513) and not (user_id = 1 and user_id is not null and ts >= 11514 and ts <= 11515) and not (user_id = 1 and user_id is not null and ts >= 11516 and ts <= 11517) and not (user_id = 1 and user_id is not null and ts >= 11518 and ts <= 11519) and not (user_id = 1 and user_id is not null and ts >= 11520 and ts <= 11521) and not (user_id = 1 and user_id is not null and ts >= 11522 and ts <= 11523) and not (user_id = 1 and user_id is not null and ts >= 11524 and ts <= 11525) and not (user_id = 1 and user_id is not null and ts >= 11526 and ts <= 11527) and not (user_id = 1 and user_id is not null and ts >= 11528 and ts <= 11529) and not (user_id = 1 and user_id is not null and ts >= 11530 and ts <= 11531) and not (user_id = 1 and user_id is not null and ts >= 11532 and ts <= 11533) and not (user_id = 1 and user_id is not null and ts >= 11534 and ts <= 11535) and not (user_id = 1 and user_id is not null and ts >= 11536 and ts <= 11537) and not (user_id = 1 and user_id is not null and ts >= 11538 and ts <= 11539) and not (user_id = 1 and user_id is not null and ts >= 11540 and ts <= 11541) and not (user_id = 1 and user_id is not null and ts >= 11542 and ts <= 11543) and not (user_id = 1 and user_id is not null and ts >= 11544 and ts <= 11545) and not (user_id = 1 and user_id is not null and ts >= 11546 and ts <= 11547) and not (user_id = 1 and user_id is not null and ts >= 11548 and ts <= 11549) and not (user_id = 1 and user_id is not null and ts >= 11550 and ts <= 11551) and not (user_id = 1 and user_id is not null and ts >= 11552 and ts <= 11553) and not (user_id = 1 and user_id is not null and ts >= 11554 and ts <= 11555) and not (user_id = 1 and user_id is not null and ts >= 11556 and ts <= 11557) and not (user_id = 1 and user_id is not null and ts >= 11558 and ts <= 11559) and not (user_id = 1 and user_id is not null and ts >= 11560 and ts <= 11561) and not (user_id = 1 and user_id is not null and ts >= 11562 and ts <= 11563) and not (user_id = 1 and user_id is not null and ts >= 11564 and ts <= 11565) and not (user_id = 1 and user_id is not null and ts >= 11566 and ts <= 11567) and not (user_id = 1 and user_id is not null and ts >= 11568 and ts <= 11569) and not (user_id = 1 and user_id is not null and ts >= 11570 and ts <= 11571) and not (user_id = 1 and user_id is not null and ts >= 11572 and ts <= 11573) and not (user_id = 1 and user_id is not null and ts >= 11574 and ts <= 11575) and not (user_id = 1 and user_id is not null and ts >= 11576 and ts <= 11577) and not (user_id = 1 and user_id is not null and ts >= 11578 and ts <= 11579) and not (user_id = 1 and user_id is not null and ts >= 11580 and ts <= 11581) and not (user_id = 1 and user_id is not null and ts >= 11582 and ts <= 11583) and not (user_id = 1 and user_id is not null and ts >= 11584 and ts <= 11585) and not (user_id = 1 and user_id is not null and ts >= 11586 and ts <= 11587) and not (user_id = 1 and user_id is not null and ts >= 11588 and ts <= 11589) and not (user_id = 1 and user_id is not null and ts >= 11590 and ts <= 11591) and not (user_id = 1 and user_id is not null and ts >= 11592 and ts <= 11593) and not (user_id = 1 and user_id is not null and ts >= 11594 and ts <= 11595) and not (user_id = 1 and user_id is not null and ts >= 11596 and ts <= 11597) and not (user_id = 1 and user_id is not null and ts >= 11598 and ts <= 11599) and not (user_id = 1 and user_id is not null and ts >= 11600 and ts <= 11601) and not (user_id = 1 and user_id is not null and ts >= 11602 and ts <= 11603) and not (user_id = 1 and user_id is not null and ts >= 11604 and ts <= 11605) and not (user_id = 1 and user_id is not null and ts >= 11606 and ts <= 11607) and not (user_id = 1 and user_id is not null and ts >= 11608 and ts <= 11609) and not (user_id = 1 and user_id is not null and ts >= 11610 and ts <= 11611) and not (user_id = 1 and user_id is not null and ts >= 11612 and ts <= 11613) and not (user_id = 1 and user_id is not null and ts >= 11614 and ts <= 11615) and not (user_id = 1 and user_id is not null and ts >= 11616 and ts <= 11617) and not (user_id = 1 and user_id is not null and ts >= 11618 and ts <= 11619) and not (user_id = 1 and user_id is not null and ts >= 11620 and ts <= 11621) and not (user_id = 1 and user_id is not null and ts >= 11622 and ts <= 11623) and not (user_id = 1 and user_id is not null and ts >= 11624 and ts <= 11625) and not (user_id = 1 and user_id is not null and ts >= 11626 and ts <= 11627) and not (user_id = 1 and user_id is not null and ts >= 11628 and ts <= 11629) and not (user_id = 1 and user_id is not null and ts >= 11630 and ts <= 11631) and not (user_id = 1 and user_id is not null and ts >= 11632 and ts <= 11633) and not (user_id = 1 and user_id is not null and ts >= 11634 and ts <= 11635) and not (user_id = 1 and user_id is not null and ts >= 11636 and ts <= 11637) and not (user_id = 1 and user_id is not null and ts >= 11638 and ts <= 11639) and not (user_id = 1 and user_id is not null and ts >= 11640 and ts <= 11641) and not (user_id = 1 and user_id is not null and ts >= 11642 and ts <= 11643) and not (user_id = 1 and user_id is not null and ts >= 11644 and ts <= 11645) and not (user_id = 1 and user_id is not null and ts >= 11646 and ts <= 11647) and not (user_id = 1 and user_id is not null and ts >= 11648 and ts <= 11649) and not (user_id = 1 and user_id is not null and ts >= 11650 and ts <= 11651) and not (user_id = 1 and user_id is not null and ts >= 11652 and ts <= 11653) and not (user_id = 1 and user_id is not null and ts >= 11654 and ts <= 11655) and not (user_id = 1 and user_id is not null and ts >= 11656 and ts <= 11657) and not (user_id = 1 and user_id is not null and ts >= 11658 and ts <= 11659) and not (user_id = 1 and user_id is not null and ts >= 11660 and ts <= 11661) and not (user_id = 1 and user_id is not null and ts >= 11662 and ts <= 11663) and not (user_id = 1 and user_id is not null and ts >= 11664 and ts <= 11665) and not (user_id = 1 and user_id is not null and ts >= 11666 and ts <= 11667) and not (user_id = 1 and user_id is not null and ts >= 11668 and ts <= 11669) and not (user_id = 1 and user_id is not null and ts >= 11670 and ts <= 11671) and not (user_id = 1 and user_id is not null and ts >= 11672 and ts <= 11673) and not (user_id = 1 and user_id is not null and ts >= 11674 and ts <= 11675) and not (user_id = 1 and user_id is not null and ts >= 11676 and ts <= 11677) and not (user_id = 1 and user_id is not null and ts >= 11678 and ts <= 11679) and not (user_id = 1 and user_id is not null and ts >= 11680 and ts <= 11681) and not (user_id = 1 and user_id is not null and ts >= 11682 and ts <= 11683) and not (user_id = 1 and user_id is not null and ts >= 11684 and ts <= 11685) and not (user_id = 1 and user_id is not null and ts >= 11686 and ts <= 11687) and not (user_id = 1 and user_id is not null and ts >= 11688 and ts <= 11689) and not (user_id = 1 and user_id is not null and ts >= 11690 and ts <= 11691) and not (user_id = 1 and user_id is not null and ts >= 11692 and ts <= 11693) and not (user_id = 1 and user_id is not null and ts >= 11694 and ts <= 11695) and not (user_id = 1 and user_id is not null and ts >= 11696 and ts <= 11697) and not (user_id = 1 and user_id is not null and ts >= 11698 and ts <= 11699) and not (user_id = 1 and user_id is not null and ts >= 11700 and ts <= 11701) and not (user_id = 1 and user_id is not null and ts >= 11702 and ts <= 11703) and not (user_id = 1 and user_id is not null and ts >= 11704 and ts <= 11705) and not (user_id = 1 and user_id is not null and ts >= 11706 and ts <= 11707) and not (user_id = 1 and user_id is not null and ts >= 11708 and ts <= 11709) and not (user_id = 1 and user_id is not null and ts >= 11710 and ts <= 11711) and not (user_id = 1 and user_id is not null and ts >= 11712 and ts <= 11713) and not (user_id = 1 and user_id is not null and ts >= 11714 and ts <= 11715) and not (user_id = 1 and user_id is not null and ts >= 11716 and ts <= 11717) and not (user_id = 1 and user_id is not null and ts >= 11718 and ts <= 11719) and not (user_id = 1 and user_id is not null and ts >= 11720 and ts <= 11721) and not (user_id = 1 and user_id is not null and ts >= 11722 and ts <= 11723) and not (user_id = 1 and user_id is not null and ts >= 11724 and ts <= 11725) and not (user_id = 1 and user_id is not null and ts >= 11726 and ts <= 11727) and not (user_id = 1 and user_id is not null and ts >= 11728 and ts <= 11729) and not (user_id = 1 and user_id is not null and ts >= 11730 and ts <= 11731) and not (user_id = 1 and user_id is not null and ts >= 11732 and ts <= 11733) and not (user_id = 1 and user_id is not null and ts >= 11734 and ts <= 11735) and not (user_id = 1 and user_id is not null and ts >= 11736 and ts <= 11737) and not (user_id = 1 and user_id is not null and ts >= 11738 and ts <= 11739) and not (user_id = 1 and user_id is not null and ts >= 11740 and ts <= 11741) and not (user_id = 1 and user_id is not null and ts >= 11742 and ts <= 11743) and not (user_id = 1 and user_id is not null and ts >= 11744 and ts <= 11745) and not (user_id = 1 and user_id is not null and ts >= 11746 and ts <= 11747) and not (user_id = 1 and user_id is not null and ts >= 11748 and ts <= 11749) and not (user_id = 1 and user_id is not null and ts >= 11750 and ts <= 11751) and not (user_id = 1 and user_id is not null and ts >= 11752 and ts <= 11753) and not (user_id = 1 and user_id is not null and ts >= 11754 and ts <= 11755) and not (user_id = 1 and user_id is not null and ts >= 11756 and ts <= 11757) and not (user_id = 1 and user_id is not null and ts >= 11758 and ts <= 11759) and not (user_id = 1 and user_id is not null and ts >= 11760 and ts <= 11761) and not (user_id = 1 and user_id is not null and ts >= 11762 and ts <= 11763) and not (user_id = 1 and user_id is not null and ts >= 11764 and ts <= 11765) and not (user_id = 1 and user_id is not null and ts >= 11766 and ts <= 11767) and not (user_id = 1 and user_id is not null and ts >= 11768 and ts <= 11769) and not (user_id = 1 and user_id is not null and ts >= 11770 and ts <= 11771) and not (user_id = 1 and user_id is not null and ts >= 11772 and ts <= 11773) and not (user_id = 1 and user_id is not null and ts >= 11774 and ts <= 11775) and not (user_id = 1 and user_id is not null and ts >= 11776 and ts <= 11777) and not (user_id = 1 and user_id is not null and ts >= 11778 and ts <= 11779) and not (user_id = 1 and user_id is not null and ts >= 11780 and ts <= 11781) and not (user_id = 1 and user_id is not null and ts >= 11782 and ts <= 11783) and not (user_id = 1 and user_id is not null and ts >= 11784 and ts <= 11785) and not (user_id = 1 and user_id is not null and ts >= 11786 and ts <= 11787) and not (user_id = 1 and user_id is not null and ts >= 11788 and ts <= 11789) and not (user_id = 1 and user_id is not null and ts >= 11790 and ts <= 11791) and not (user_id = 1 and user_id is not null and ts >= 11792 and ts <= 11793) and not (user_id = 1 and user_id is not null and ts >= 11794 and ts <= 11795) and not (user_id = 1 and user_id is not null and ts >= 11796 and ts <= 11797) and not (user_id = 1 and user_id is not null and ts >= 11798 and ts <= 11799) and not (user_id = 1 and user_id is not null and ts >= 11800 and ts <= 11801) and not (user_id = 1 and user_id is not null and ts >= 11802 and ts <= 11803) and not (user_id = 1 and user_id is not null and ts >= 11804 and ts <= 11805) and not (user_id = 1 and user_id is not null and ts >= 11806 and ts <= 11807) and not (user_id = 1 and user_id is not null and ts >= 11808 and ts <= 11809) and not (user_id = 1 and user_id is not null and ts >= 11810 and ts <= 11811) and not (user_id = 1 and user_id is not null and ts >= 11812 and ts <= 11813) and not (user_id = 1 and user_id is not null and ts >= 11814 and ts <= 11815) and not (user_id = 1 and user_id is not null and ts >= 11816 and ts <= 11817) and not (user_id = 1 and user_id is not null and ts >= 11818 and ts <= 11819) and not (user_id = 1 and user_id is not null and ts >= 11820 and ts <= 11821) and not (user_id = 1 and user_id is not null and ts >= 11822 and ts <= 11823) and not (user_id = 1 and user_id is not null and ts >= 11824 and ts <= 11825) and not (user_id = 1 and user_id is not null and ts >= 11826 and ts <= 11827) and not (user_id = 1 and user_id is not null and ts >= 11828 and ts <= 11829) and not (user_id = 1 and user_id is not null and ts >= 11830 and ts <= 11831) and not (user_id = 1 and user_id is not null and ts >= 11832 and ts <= 11833) and not (user_id = 1 and user_id is not null and ts >= 11834 and ts <= 11835) and not (user_id = 1 and user_id is not null and ts >= 11836 and ts <= 11837) and not (user_id = 1 and user_id is not null and ts >= 11838 and ts <= 11839) and not (user_id = 1 and user_id is not null and ts >= 11840 and ts <= 11841) and not (user_id = 1 and user_id is not null and ts >= 11842 and ts <= 11843) and not (user_id = 1 and user_id is not null and ts >= 11844 and ts <= 11845) and not (user_id = 1 and user_id is not null and ts >= 11846 and ts <= 11847) and not (user_id = 1 and user_id is not null and ts >= 11848 and ts <= 11849) and not (user_id = 1 and user_id is not null and ts >= 11850 and ts <= 11851) and not (user_id = 1 and user_id is not null and ts >= 11852 and ts <= 11853) and not (user_id = 1 and user_id is not null and ts >= 11854 and ts <= 11855) and not (user_id = 1 and user_id is not null and ts >= 11856 and ts <= 11857) and not (user_id = 1 and user_id is not null and ts >= 11858 and ts <= 11859) and not (user_id = 1 and user_id is not null and ts >= 11860 and ts <= 11861) and not (user_id = 1 and user_id is not null and ts >= 11862 and ts <= 11863) and not (user_id = 1 and user_id is not null and ts >= 11864 and ts <= 11865) and not (user_id = 1 and user_id is not null and ts >= 11866 and ts <= 11867) and not (user_id = 1 and user_id is not null and ts >= 11868 and ts <= 11869) and not (user_id = 1 and user_id is not null and ts >= 11870 and ts <= 11871) and not (user_id = 1 and user_id is not null and ts >= 11872 and ts <= 11873) and not (user_id = 1 and user_id is not null and ts >= 11874 and ts <= 11875) and not (user_id = 1 and user_id is not null and ts >= 11876 and ts <= 11877) and not (user_id = 1 and user_id is not null and ts >= 11878 and ts <= 11879) and not (user_id = 1 and user_id is not null and ts >= 11880 and ts <= 11881) and not (user_id = 1 and user_id is not null and ts >= 11882 and ts <= 11883) and not (user_id = 1 and user_id is not null and ts >= 11884 and ts <= 11885) and not (user_id = 1 and user_id is not null and ts >= 11886 and ts <= 11887) and not (user_id = 1 and user_id is not null and ts >= 11888 and ts <= 11889) and not (user_id = 1 and user_id is not null and ts >= 11890 and ts <= 11891) and not (user_id = 1 and user_id is not null and ts >= 11892 and ts <= 11893) and not (user_id = 1 and user_id is not null and ts >= 11894 and ts <= 11895) and not (user_id = 1 and user_id is not null and ts >= 11896 and ts <= 11897) and not (user_id = 1 and user_id is not null and ts >= 11898 and ts <= 11899) and not (user_id = 1 and user_id is not null and ts >= 11900 and ts <= 11901) and not (user_id = 1 and user_id is not null and ts >= 11902 and ts <= 11903) and not (user_id = 1 and user_id is not null and ts >= 11904 and ts <= 11905) and not (user_id = 1 and user_id is not null and ts >= 11906 and ts <= 11907) and not (user_id = 1 and user_id is not null and ts >= 11908 and ts <= 11909) and not (user_id = 1 and user_id is not null and ts >= 11910 and ts <= 11911) and not (user_id = 1 and user_id is not null and ts >= 11912 and ts <= 11913) and not (user_id = 1 and user_id is not null and ts >= 11914 and ts <= 11915) and not (user_id = 1 and user_id is not null and ts >= 11916 and ts <= 11917) and not (user_id = 1 and user_id is not null and ts >= 11918 and ts <= 11919) and not (user_id = 1 and user_id is not null and ts >= 11920 and ts <= 11921) and not (user_id = 1 and user_id is not null and ts >= 11922 and ts <= 11923) and not (user_id = 1 and user_id is not null and ts >= 11924 and ts <= 11925) and not (user_id = 1 and user_id is not null and ts >= 11926 and ts <= 11927) and not (user_id = 1 and user_id is not null and ts >= 11928 and ts <= 11929) and not (user_id = 1 and user_id is not null and ts >= 11930 and ts <= 11931) and not (user_id = 1 and user_id is not null and ts >= 11932 and ts <= 11933) and not (user_id = 1 and user_id is not null and ts >= 11934 and ts <= 11935) and not (user_id = 1 and user_id is not null and ts >= 11936 and ts <= 11937) and not (user_id = 1 and user_id is not null and ts >= 11938 and ts <= 11939) and not (user_id = 1 and user_id is not null and ts >= 11940 and ts <= 11941) and not (user_id = 1 and user_id is not null and ts >= 11942 and ts <= 11943) and not (user_id = 1 and user_id is not null and ts >= 11944 and ts <= 11945) and not (user_id = 1 and user_id is not null and ts >= 11946 and ts <= 11947) and not (user_id = 1 and user_id is not null and ts >= 11948 and ts <= 11949) and not (user_id = 1 and user_id is not null and ts >= 11950 and ts <= 11951) and not (user_id = 1 and user_id is not null and ts >= 11952 and ts <= 11953) and not (user_id = 1 and user_id is not null and ts >= 11954 and ts <= 11955) and not (user_id = 1 and user_id is not null and ts >= 11956 and ts <= 11957) and not (user_id = 1 and user_id is not null and ts >= 11958 and ts <= 11959) and not (user_id = 1 and user_id is not null and ts >= 11960 and ts <= 11961) and not (user_id = 1 and user_id is not null and ts >= 11962 and ts <= 11963) and not (user_id = 1 and user_id is not null and ts >= 11964 and ts <= 11965) and not (user_id = 1 and user_id is not null and ts >= 11966 and ts <= 11967) and not (user_id = 1 and user_id is not null and ts >= 11968 and ts <= 11969) and not (user_id = 1 and user_id is not null and ts >= 11970 and ts <= 11971) and not (user_id = 1 and user_id is not null and ts >= 11972 and ts <= 11973) and not (user_id = 1 and user_id is not null and ts >= 11974 and ts <= 11975) and not (user_id = 1 and user_id is not null and ts >= 11976 and ts <= 11977) and not (user_id = 1 and user_id is not null and ts >= 11978 and ts <= 11979) and not (user_id = 1 and user_id is not null and ts >= 11980 and ts <= 11981) and not (user_id = 1 and user_id is not null and ts >= 11982 and ts <= 11983) and not (user_id = 1 and user_id is not null and ts >= 11984 and ts <= 11985) and not (user_id = 1 and user_id is not null and ts >= 11986 and ts <= 11987) and not (user_id = 1 and user_id is not null and ts >= 11988 and ts <= 11989) and not (user_id = 1 and user_id is not null and ts >= 11990 and ts <= 11991) and not (user_id = 1 and user_id is not null and ts >= 11992 and ts <= 11993) and ts >= 113898 and parent_id = 1 order by ts asc limit 100", "Instructions": { @@ -4669,12 +4802,13 @@ "user.user" ] }, - "skip_e2e":true + "skip_e2e": true }, { "comment": "union inside subquery. all routes can be merged by literal value", "query": "select 1 from user where id = 12 and exists(select 1 from music where user_id = 12 union select 1 from user_extra where user_id = 12)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select 1 from user where id = 12 and exists(select 1 from music where user_id = 12 union select 1 from user_extra where user_id = 12)", "Instructions": { @@ -4703,6 +4837,7 @@ "comment": "list args: single column vindex", "query": "select 1 from user where (id, col) in ::vals", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select 1 from user where (id, col) in ::vals", "Instructions": { @@ -4730,6 +4865,7 @@ "comment": "list args: single column vindex on non-zero offset", "query": "select 1 from user where (col, id) in ::vals", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select 1 from user where (col, id) in ::vals", "Instructions": { @@ -4757,6 +4893,7 @@ "comment": "list args: multi column vindex", "query": "select 1 from multicol_tbl where (cola, colb) in ::vals", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select 1 from multicol_tbl where (cola, colb) in ::vals", "Instructions": { @@ -4785,6 +4922,7 @@ "comment": "list args: multi column vindex - subshard", "query": "select 1 from multicol_tbl where (cola) in ::vals", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select 1 from multicol_tbl where (cola) in ::vals", "Instructions": { @@ -4812,6 +4950,7 @@ "comment": "list args: multi column vindex - more columns", "query": "select 1 from multicol_tbl where (cola, colx, colb) in ::vals", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select 1 from multicol_tbl where (cola, colx, colb) in ::vals", "Instructions": { @@ -4840,6 +4979,7 @@ "comment": "list args: multi column vindex - columns rearranged", "query": "select 1 from multicol_tbl where (colb, colx, cola) in ::vals", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select 1 from multicol_tbl where (colb, colx, cola) in ::vals", "Instructions": { @@ -4868,6 +5008,7 @@ "comment": "order by with filter removing the keyspace from order by", "query": "select col from user.user where id = 1 order by user.user.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from user.user where id = 1 order by user.user.user_id", "Instructions": { @@ -4894,6 +5035,7 @@ "comment": "group by with filter removing the keyspace from order by", "query": "select col from user.user where id = 1 group by user.user.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from user.user where id = 1 group by user.user.user_id", "Instructions": { @@ -4920,6 +5062,7 @@ "comment": "order with authoritative table - removing keyspace from group by", "query": "select * from user.authoritative where user_id = 5 order by user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user.authoritative where user_id = 5 order by user_id", "Instructions": { @@ -4946,6 +5089,7 @@ "comment": "group by and having with authoritative table - removing keyspace from having", "query": "select * from user.authoritative where user_id = 5 group by user_id having count(user_id) = 6 order by user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user.authoritative where user_id = 5 group by user_id having count(user_id) = 6 order by user_id", "Instructions": { @@ -4972,6 +5116,7 @@ "comment": "Between clause on primary indexed id column (binary vindex on id)", "query": "select id from unq_binary_idx where id between 1 and 5", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select id from unq_binary_idx where id between 1 and 5", "Instructions": { @@ -4994,10 +5139,11 @@ ] } }, -{ + { "comment": "Between clause on customer.id column (xxhash vindex on id)", "query": "select id from customer where id between 1 and 5", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from customer where id between 1 and 5", "Instructions": { @@ -5016,10 +5162,11 @@ ] } }, -{ + { "comment": "Between clause on col1 column (there is no vindex on this column)", "query": "select id, col1 from unq_binary_idx where col1 between 10 and 50", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, col1 from unq_binary_idx where col1 between 10 and 50", "Instructions": { @@ -5037,78 +5184,80 @@ "user.unq_binary_idx" ] } -}, -{ - "comment": "Between clause on multicolumn vindex (cola,colb)", - "query": "select cola,colb,colc from multicol_tbl where cola between 1 and 5", - "plan": { - "QueryType": "SELECT", - "Original": "select cola,colb,colc from multicol_tbl where cola between 1 and 5", - "Instructions": { - "OperatorType": "Route", - "Variant": "Scatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "FieldQuery": "select cola, colb, colc from multicol_tbl where 1 != 1", - "Query": "select cola, colb, colc from multicol_tbl where cola between 1 and 5", - "Table": "multicol_tbl" - }, - "TablesUsed": [ - "user.multicol_tbl" - ] - } -}, -{ - "comment": "Between clause on a binary vindex field with values from a different table", - "query": "select s.oid,s.col1, se.colb from sales s join sales_extra se on s.col1 = se.cola where s.oid between se.start and se.end", - "plan": { - "QueryType": "SELECT", - "Original": "select s.oid,s.col1, se.colb from sales s join sales_extra se on s.col1 = se.cola where s.oid between se.start and se.end", - "Instructions": { - "OperatorType": "Join", - "Variant": "Join", - "JoinColumnIndexes": "R:0,R:1,L:0", - "JoinVars": { - "se_cola": 1, - "se_end": 3, - "se_start": 2 - }, - "TableName": "sales_extra_sales", - "Inputs": [ - { - "OperatorType": "Route", - "Variant": "Scatter", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "FieldQuery": "select se.colb, se.cola, se.`start`, se.`end` from sales_extra as se where 1 != 1", - "Query": "select se.colb, se.cola, se.`start`, se.`end` from sales_extra as se", - "Table": "sales_extra" - }, - { - "OperatorType": "Route", - "Variant": "Between", - "Keyspace": { - "Name": "user", - "Sharded": true + }, + { + "comment": "Between clause on multicolumn vindex (cola,colb)", + "query": "select cola,colb,colc from multicol_tbl where cola between 1 and 5", + "plan": { + "Type": "Scatter", + "QueryType": "SELECT", + "Original": "select cola,colb,colc from multicol_tbl where cola between 1 and 5", + "Instructions": { + "OperatorType": "Route", + "Variant": "Scatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select cola, colb, colc from multicol_tbl where 1 != 1", + "Query": "select cola, colb, colc from multicol_tbl where cola between 1 and 5", + "Table": "multicol_tbl" + }, + "TablesUsed": [ + "user.multicol_tbl" + ] + } + }, + { + "comment": "Between clause on a binary vindex field with values from a different table", + "query": "select s.oid,s.col1, se.colb from sales s join sales_extra se on s.col1 = se.cola where s.oid between se.start and se.end", + "plan": { + "Type": "Unknown", + "QueryType": "SELECT", + "Original": "select s.oid,s.col1, se.colb from sales s join sales_extra se on s.col1 = se.cola where s.oid between se.start and se.end", + "Instructions": { + "OperatorType": "Join", + "Variant": "Join", + "JoinColumnIndexes": "R:0,R:1,L:0", + "JoinVars": { + "se_cola": 1, + "se_end": 3, + "se_start": 2 + }, + "TableName": "sales_extra_sales", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "Scatter", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select se.colb, se.cola, se.`start`, se.`end` from sales_extra as se where 1 != 1", + "Query": "select se.colb, se.cola, se.`start`, se.`end` from sales_extra as se", + "Table": "sales_extra" }, - "FieldQuery": "select s.oid, s.col1 from sales as s where 1 != 1", - "Query": "select s.oid, s.col1 from sales as s where s.oid between :se_start /* INT16 */ and :se_end /* INT16 */ and s.col1 = :se_cola /* VARCHAR */", - "Table": "sales", - "Values": [ - "(:se_start, :se_end)" - ], - "Vindex": "binary" - } + { + "OperatorType": "Route", + "Variant": "Between", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select s.oid, s.col1 from sales as s where 1 != 1", + "Query": "select s.oid, s.col1 from sales as s where s.oid between :se_start /* INT16 */ and :se_end /* INT16 */ and s.col1 = :se_cola /* VARCHAR */", + "Table": "sales", + "Values": [ + "(:se_start, :se_end)" + ], + "Vindex": "binary" + } + ] + }, + "TablesUsed": [ + "user.sales", + "user.sales_extra" ] - }, - "TablesUsed": [ - "user.sales", - "user.sales_extra" - ] + } } -} ] diff --git a/go/vt/vtgate/planbuilder/testdata/flush_cases.json b/go/vt/vtgate/planbuilder/testdata/flush_cases.json index 26a1f218c8d..403db244ef3 100644 --- a/go/vt/vtgate/planbuilder/testdata/flush_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/flush_cases.json @@ -3,6 +3,7 @@ "comment": "Flush statement", "query": "flush tables unsharded, music", "plan": { + "Type": "Unknown", "QueryType": "FLUSH", "Original": "flush tables unsharded, music", "Instructions": { @@ -24,6 +25,7 @@ "comment": "Flush statement with no tables", "query": "flush local tables with read lock", "plan": { + "Type": "Unknown", "QueryType": "FLUSH", "Original": "flush local tables with read lock", "Instructions": { @@ -42,6 +44,7 @@ "comment": "Flush statement with flush options", "query": "flush no_write_to_binlog hosts, logs", "plan": { + "Type": "Unknown", "QueryType": "FLUSH", "Original": "flush no_write_to_binlog hosts, logs", "Instructions": { @@ -59,6 +62,7 @@ "comment": "Flush statement with multiple tables in different keyspace with read lock", "query": "flush tables user.music, main.unsharded with read lock", "plan": { + "Type": "Complex", "QueryType": "FLUSH", "Original": "flush tables user.music, main.unsharded with read lock", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/flush_cases_no_default_keyspace.json b/go/vt/vtgate/planbuilder/testdata/flush_cases_no_default_keyspace.json index 7afd090ba21..4419bbe50a6 100644 --- a/go/vt/vtgate/planbuilder/testdata/flush_cases_no_default_keyspace.json +++ b/go/vt/vtgate/planbuilder/testdata/flush_cases_no_default_keyspace.json @@ -3,6 +3,7 @@ "comment": "Flush statement", "query": "flush local tables user, unsharded_a, user_extra with read lock", "plan": { + "Type": "Complex", "QueryType": "FLUSH", "Original": "flush local tables user, unsharded_a, user_extra with read lock", "Instructions": { @@ -41,6 +42,7 @@ "comment": "Flush statement with flush options", "query": "flush no_write_to_binlog hosts, logs", "plan": { + "Type": "Unknown", "QueryType": "FLUSH", "Original": "flush no_write_to_binlog hosts, logs", "Instructions": { @@ -58,6 +60,7 @@ "comment": "Flush statement with routing rules", "query": "flush local tables route1, route2", "plan": { + "Type": "Complex", "QueryType": "FLUSH", "Original": "flush local tables route1, route2", "Instructions": { @@ -98,6 +101,7 @@ "comment": "Unknown tables in unsharded keyspaces are allowed", "query": "flush tables main.a with read lock", "plan": { + "Type": "Unknown", "QueryType": "FLUSH", "Original": "flush tables main.a with read lock", "Instructions": { @@ -119,6 +123,7 @@ "comment": "Flush statement with 3 keyspaces", "query": "flush local tables user, unsharded_a, user_extra, unsharded_tab with read lock", "plan": { + "Type": "Complex", "QueryType": "FLUSH", "Original": "flush local tables user, unsharded_a, user_extra, unsharded_tab with read lock", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/foreignkey_cases.json b/go/vt/vtgate/planbuilder/testdata/foreignkey_cases.json index 799c9bd4420..efa02f76f38 100644 --- a/go/vt/vtgate/planbuilder/testdata/foreignkey_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/foreignkey_cases.json @@ -8,6 +8,7 @@ "comment": "Insertion in a table with shard-scoped foreign keys is allowed", "query": "insert into tbl2 (col2, coly) values (1, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into tbl2 (col2, coly) values (1, 3)", "Instructions": { @@ -33,6 +34,7 @@ "comment": "Insertion in a table with shard-scoped multiple column foreign key is allowed", "query": "insert into multicol_tbl2 (cola, colb, colc) values (1, 2, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into multicol_tbl2 (cola, colb, colc) values (1, 2, 3)", "Instructions": { @@ -68,6 +70,7 @@ "comment": "Delete in a table with shard-scoped multiple column foreign key with cascade", "query": "delete from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "Instructions": { @@ -147,6 +150,7 @@ "comment": "Delete in a table with shard-scoped foreign keys with cascade", "query": "delete from tbl5", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from tbl5", "Instructions": { @@ -229,6 +233,7 @@ "comment": "Delete in a table with unsharded foreign key with SET NULL", "query": "delete from u_tbl9 where col9 = 5", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from u_tbl9 where col9 = 5", "Instructions": { @@ -286,6 +291,7 @@ "comment": "update in unsharded table with restrict", "query": "update u_tbl5 set col5 = 'foo' where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update u_tbl5 set col5 = 'foo' where id = 1", "Instructions": { @@ -308,6 +314,7 @@ "comment": "update in unsharded table with cascade", "query": "update u_tbl2 set col2 = 'bar' where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set col2 = 'bar' where id = 1", "Instructions": { @@ -365,6 +372,7 @@ "comment": "update in unsharded table with cascade - on non-referenced column", "query": "update u_tbl2 set col_no_ref = 'baz' where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update u_tbl2 set col_no_ref = 'baz' where id = 1", "Instructions": { @@ -392,6 +400,7 @@ "comment": "Update in a table with cross-shard foreign keys, column not in update expression - allowed", "query": "update tbl1 set not_ref_col = 'foo' where id = 1", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update tbl1 set not_ref_col = 'foo' where id = 1", "Instructions": { @@ -419,6 +428,7 @@ "comment": "Update in a table with shard-scoped foreign keys with cascade", "query": "update tbl5 set t5col5 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl5 set t5col5 = 'foo'", "Instructions": { @@ -481,6 +491,7 @@ "comment": "Update a table with parent and child foreign keys - shard scoped", "query": "update tbl2 set col = 'foo'", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update tbl2 set col = 'foo'", "Instructions": { @@ -503,6 +514,7 @@ "comment": "update table with column's parent foreign key cross shard", "query": "update tbl10 set col = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl10 set col = 'foo'", "Instructions": { @@ -588,6 +600,7 @@ "comment": "Delete table with cross-shard foreign key with set null - should be eventually allowed", "query": "delete from tbl9 where col9 = 34", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from tbl9 where col9 = 34", "Instructions": { @@ -653,6 +666,7 @@ "comment": "update table with same column having reference to different tables, one with on update cascade other with on update set null - child table have further reference", "query": "update u_tbl1 set col1 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 set col1 = 'foo'", "Instructions": { @@ -797,6 +811,7 @@ "comment": "update in a table with non-literal value - set null", "query": "update u_tbl2 set m = 2, col2 = col1 + 'bar' where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set m = 2, col2 = col1 + 'bar' where id = 1", "Instructions": { @@ -880,6 +895,7 @@ "comment": "update in a table with non-literal value - with cascade", "query": "update u_tbl1 set m = 2, col1 = x + 'bar' where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 set m = 2, col1 = x + 'bar' where id = 1", "Instructions": { @@ -1038,6 +1054,7 @@ "comment": "update in a table with set null, non-literal value on non-foreign key column", "query": "update u_tbl2 set m = col1 + 'bar', col2 = 2 where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set m = col1 + 'bar', col2 = 2 where id = 1", "Instructions": { @@ -1095,6 +1112,7 @@ "comment": "update in a table with cascade, non-literal value on non-foreign key column", "query": "update u_tbl1 set m = x + 'bar', col1 = 2 where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 set m = x + 'bar', col1 = 2 where id = 1", "Instructions": { @@ -1244,6 +1262,7 @@ "comment": "delete in a table with limit", "query": "delete from u_tbl2 limit 2", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from u_tbl2 limit 2", "Instructions": { @@ -1321,6 +1340,7 @@ "comment": "update with fk on cross-shard with a update condition on non-literal value", "query": "update tbl3 set coly = colx + 10 where coly = 10", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl3 set coly = colx + 10 where coly = 10", "Instructions": { @@ -1404,6 +1424,7 @@ "comment": "update with fk on cross-shard with a where condition", "query": "update tbl3 set coly = 20 where coly = 10", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl3 set coly = 20 where coly = 10", "Instructions": { @@ -1484,6 +1505,7 @@ "comment": "Update in a table with shard-scoped foreign keys with cascade that requires a validation of a different parent foreign key", "query": "update u_tbl6 set col6 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl6 set col6 = 'foo'", "Instructions": { @@ -1560,6 +1582,7 @@ "comment": "Update that cascades and requires parent fk and restrict child fk verification", "query": "update u_tbl7 set col7 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl7 set col7 = 'foo'", "Instructions": { @@ -1649,6 +1672,7 @@ "comment": "Update that cascades and requires parent fk and restrict child fk verification - bindVariable", "query": "update u_tbl7 set col7 = :v1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl7 set col7 = :v1", "Instructions": { @@ -1738,6 +1762,7 @@ "comment": "Insert with on duplicate key update - foreign key with new value", "query": "insert into u_tbl1 (id, col1) values (1, 3) on duplicate key update col1 = 5", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into u_tbl1 (id, col1) values (1, 3) on duplicate key update col1 = 5", "Instructions": { @@ -1902,6 +1927,7 @@ "comment": "Insert with on duplicate key update - foreign keys not on update column - allowed", "query": "insert into u_tbl1 (id, col1, foo) values (1, 3, 'bar') on duplicate key update foo = 'baz'", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into u_tbl1 (id, col1, foo) values (1, 3, 'bar') on duplicate key update foo = 'baz'", "Instructions": { @@ -1929,6 +1955,7 @@ "comment": "replace into with table having primary key", "query": "replace into u_tbl1 (id, col1) values (1, 2)", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "replace into u_tbl1 (id, col1) values (1, 2)", "Instructions": { @@ -2038,6 +2065,7 @@ "comment": "update on a multicol foreign key that set nulls and then cascades", "query": "update u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "Instructions": { @@ -2132,6 +2160,7 @@ "comment": "update on a multicol foreign key that set nulls and then cascades - bindVariables", "query": "update u_multicol_tbl1 set cola = :v1, colb = :v2 where id = :v3", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_multicol_tbl1 set cola = :v1, colb = :v2 where id = :v3", "Instructions": { @@ -2226,6 +2255,7 @@ "comment": "Cascaded delete run from prepared statement", "query": "execute prep_delete using @foo", "plan": { + "Type": "Complex", "QueryType": "EXECUTE", "Original": "execute prep_delete using @foo", "Instructions": { @@ -2316,6 +2346,7 @@ "comment": "foreign key column updated by using a column which is also getting updated - self reference column is allowed", "query": "update u_tbl7 set foo = 100, col7 = baz + 1 + col7 where bar = 42", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl7 set foo = 100, col7 = baz + 1 + col7 where bar = 42", "Instructions": { @@ -2412,6 +2443,7 @@ "comment": "Single column updated in a multi-col table", "query": "update u_multicol_tbl1 set cola = cola + 3 where id = 3", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_multicol_tbl1 set cola = cola + 3 where id = 3", "Instructions": { @@ -2518,6 +2550,7 @@ "comment": "multicol foreign key updates with one literal and one non-literal update", "query": "update u_multicol_tbl2 set cola = 2, colb = colc - (2) where id = 7", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_multicol_tbl2 set cola = 2, colb = colc - (2) where id = 7", "Instructions": { @@ -2607,6 +2640,7 @@ "comment": "replace into with table having unique key and primary key", "query": "replace into u_tbl9(id, col9) values (1, 10),(2, 20),(3, 30)", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "replace into u_tbl9(id, col9) values (1, 10),(2, 20),(3, 30)", "Instructions": { @@ -2681,6 +2715,7 @@ "comment": "Delete with foreign key checks off", "query": "delete /*+ SET_VAR(foreign_key_checks=off) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete /*+ SET_VAR(foreign_key_checks=off) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "Instructions": { @@ -2709,6 +2744,7 @@ "comment": "Update with foreign key checks off", "query": "update /*+ SET_VAR(foreign_key_checks=0) */ u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update /*+ SET_VAR(foreign_key_checks=0) */ u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "Instructions": { @@ -2731,6 +2767,7 @@ "comment": "Insert with cross shard foreign keys and foreign key checks off", "query": "insert /*+ SET_VAR(foreign_key_checks=0) */ into tbl3 (col3, coly) values (1, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert /*+ SET_VAR(foreign_key_checks=0) */ into tbl3 (col3, coly) values (1, 3)", "Instructions": { @@ -2756,6 +2793,7 @@ "comment": "Insert with on duplicate key update - foreign key with values function", "query": "insert into u_tbl1 (id, col1) values (1, 3) on duplicate key update col1 = values(col1)", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into u_tbl1 (id, col1) values (1, 3) on duplicate key update col1 = values(col1)", "Instructions": { @@ -2920,6 +2958,7 @@ "comment": "insert with on duplicate key update with multiple rows", "query": "insert into u_tbl2 (id, col2) values (:v1, :v2),(:v3, :v4), (:v5, :v6) on duplicate key update col2 = values(col2)", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into u_tbl2 (id, col2) values (:v1, :v2),(:v3, :v4), (:v5, :v6) on duplicate key update col2 = values(col2)", "Instructions": { @@ -3120,6 +3159,7 @@ "comment": "Unsharded multi-table delete with foreign keys", "query": "delete u from u_tbl6 u join u_tbl5 m on u.col = m.col where u.col2 = 4 and m.col3 = 6", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u from u_tbl6 u join u_tbl5 m on u.col = m.col where u.col2 = 4 and m.col3 = 6", "Instructions": { @@ -3198,6 +3238,7 @@ "comment": "Multi table delete with using", "query": "delete u_tbl10 from u_tbl10 join u_tbl11 using (id) where id = 5", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u_tbl10 from u_tbl10 join u_tbl11 using (id) where id = 5", "Instructions": { @@ -3275,6 +3316,7 @@ "comment": "Multi table delete with unrelated tables", "query": "delete u_tbl1 from u_tbl10 join u_tbl1 on u_tbl10.col = u_tbl1.col", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u_tbl1 from u_tbl10 join u_tbl1 on u_tbl10.col = u_tbl1.col", "Instructions": { @@ -3388,6 +3430,7 @@ "comment": "Delete with limit", "query": "delete from u_tbl1 order by id limit 1", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from u_tbl1 order by id limit 1", "Instructions": { @@ -3500,6 +3543,7 @@ "comment": "update query with an uncorrelated subquery", "query": "update u_tbl4 set col41 = (select col14 from u_tbl1 where x = 2 and y = 4) where col4 = 3", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl4 set col41 = (select col14 from u_tbl1 where x = 2 and y = 4) where col4 = 3", "Instructions": { @@ -3563,6 +3607,7 @@ "comment": "update with a subquery", "query": "update u_tbl1 set col1 = (select foo from u_tbl1 where id = 1) order by id desc", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 set col1 = (select foo from u_tbl1 where id = 1) order by id desc", "Instructions": { @@ -3729,6 +3774,7 @@ "comment": "Multi table delete such that the two tables are foreign key related", "query": "delete u_tbl6 from u_tbl6 join u_tbl8 on u_tbl6.id = u_tbl8.id where u_tbl6.id = 4", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u_tbl6 from u_tbl6 join u_tbl8 on u_tbl6.id = u_tbl8.id where u_tbl6.id = 4", "Instructions": { @@ -3806,6 +3852,7 @@ "comment": "multi table delete on foreign key enabled tables", "query": "delete u, m from u_tbl6 u join u_tbl5 m on u.col = m.col where u.col2 = 4 and m.col3 = 6", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete u, m from u_tbl6 u join u_tbl5 m on u.col = m.col where u.col2 = 4 and m.col3 = 6", "Instructions": { @@ -3896,6 +3943,7 @@ "comment": "update with limit with foreign keys", "query": "update u_tbl2 set col2 = 'bar' limit 2", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set col2 = 'bar' limit 2", "Instructions": { @@ -3973,6 +4021,7 @@ "comment": "non literal update with order by and limit", "query": "update u_tbl2 set col2 = id + 1 order by id limit 2", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set col2 = id + 1 order by id limit 2", "Instructions": { @@ -4076,6 +4125,7 @@ "comment": "multi table update", "query": "update u_tbl6 u join u_tbl5 m on u.col = m.col set u.col6 = 'foo' where u.col2 = 4 and m.col3 = 6", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl6 u join u_tbl5 m on u.col = m.col set u.col6 = 'foo' where u.col2 = 4 and m.col3 = 6", "Instructions": { @@ -4153,6 +4203,7 @@ "comment": "multi target update", "query": "update u_tbl1 u join u_multicol_tbl1 m on u.col = m.col set u.col1 = 'foo', m.cola = 'bar' where u.foo = 4 and m.bar = 6", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 u join u_multicol_tbl1 m on u.col = m.col set u.col1 = 'foo', m.cola = 'bar' where u.foo = 4 and m.bar = 6", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_off_cases.json b/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_off_cases.json index 264311696a3..c3d8c80d506 100644 --- a/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_off_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_off_cases.json @@ -3,6 +3,7 @@ "comment": "Insertion in a table with cross-shard foreign keys works with foreign_key_checks off", "query": "insert into tbl3 (col3, coly) values (1, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into tbl3 (col3, coly) values (1, 3)", "Instructions": { @@ -28,6 +29,7 @@ "comment": "Insertion in a table with shard-scoped multiple column foreign key is allowed", "query": "insert into multicol_tbl2 (cola, colb, colc) values (1, 2, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into multicol_tbl2 (cola, colb, colc) values (1, 2, 3)", "Instructions": { @@ -53,6 +55,7 @@ "comment": "Delete in a table with cross-shard foreign key works with foreign_key_checks off ", "query": "delete from tbl1", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from tbl1", "Instructions": { @@ -75,6 +78,7 @@ "comment": "Delete in a table with not all column shard-scoped foreign keys works with foreign_key_checks off", "query": "delete from tbl7", "plan": { + "Type": "Scatter", "QueryType": "DELETE", "Original": "delete from tbl7", "Instructions": { @@ -97,6 +101,7 @@ "comment": "Delete in a table with shard-scoped multiple column foreign key with cascade with foreign key checks on", "query": "delete /*+ SET_VAR(foreign_key_checks=1) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete /*+ SET_VAR(foreign_key_checks=1) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "Instructions": { @@ -176,6 +181,7 @@ "comment": "Delete in a table with shard-scoped foreign keys with SET NULL", "query": "delete from tbl8 where col8 = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from tbl8 where col8 = 1", "Instructions": { @@ -202,6 +208,7 @@ "comment": "Update in a table with cross-shard foreign keys works with foreign_key_checks off", "query": "update tbl1 set t1col1 = 'foo' where col1 = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update tbl1 set t1col1 = 'foo' where col1 = 1", "Instructions": { @@ -228,6 +235,7 @@ "comment": "Update in a table with column modified not shard-scoped foreign key whereas other column referencing same table is works with foreign_key_checks off", "query": "update tbl7 set t7col7 = 'foo', t7col72 = 42", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update tbl7 set t7col7 = 'foo', t7col72 = 42", "Instructions": { @@ -250,6 +258,7 @@ "comment": "Update in a table with shard-scoped foreign keys with cascade", "query": "update /*+ SET_VAR(foreign_key_checks=On) */ tbl5 set t5col5 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update /*+ SET_VAR(foreign_key_checks=On) */ tbl5 set t5col5 = 'foo'", "Instructions": { @@ -307,6 +316,7 @@ "comment": "Insertion in a table with 2 foreign keys constraint with same table on different columns - both are not shard scoped - works with foreign_key_checks off", "query": "insert into tbl6 (col6, t6col6) values (100, 'foo')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into tbl6 (col6, t6col6) values (100, 'foo')", "Instructions": { @@ -332,6 +342,7 @@ "comment": "delete table with shard scoped foreign key set default works with foreign_key_checks off", "query": "delete from tbl20 where col = 'bar'", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from tbl20 where col = 'bar'", "Instructions": { @@ -358,6 +369,7 @@ "comment": "Delete table with cross-shard foreign key with set null - should be eventually allowed", "query": "delete /*+ SET_VAR(foreign_key_checks=On) */ from tbl9 where col9 = 34", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete /*+ SET_VAR(foreign_key_checks=On) */ from tbl9 where col9 = 34", "Instructions": { @@ -423,6 +435,7 @@ "comment": "Delete with foreign key checks off", "query": "delete /*+ SET_VAR(foreign_key_checks=off) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete /*+ SET_VAR(foreign_key_checks=off) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "Instructions": { @@ -451,6 +464,7 @@ "comment": "Update with foreign key checks off", "query": "update /*+ SET_VAR(foreign_key_checks=0) */ u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update /*+ SET_VAR(foreign_key_checks=0) */ u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "Instructions": { @@ -473,6 +487,7 @@ "comment": "Insert with cross shard foreign keys and foreign key checks off", "query": "insert /*+ SET_VAR(foreign_key_checks=0) */ into tbl3 (col3, coly) values (1, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert /*+ SET_VAR(foreign_key_checks=0) */ into tbl3 (col3, coly) values (1, 3)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_on_cases.json b/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_on_cases.json index 5464ccbd619..3d5bd09622d 100644 --- a/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_on_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/foreignkey_checks_on_cases.json @@ -8,6 +8,7 @@ "comment": "Insertion in a table with shard-scoped foreign keys is allowed", "query": "insert into tbl2 (col2, coly) values (1, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into tbl2 (col2, coly) values (1, 3)", "Instructions": { @@ -33,6 +34,7 @@ "comment": "Insertion in a table with shard-scoped multiple column foreign key is allowed", "query": "insert into multicol_tbl2 (cola, colb, colc) values (1, 2, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into multicol_tbl2 (cola, colb, colc) values (1, 2, 3)", "Instructions": { @@ -68,6 +70,7 @@ "comment": "Delete in a table with shard-scoped multiple column foreign key with cascade", "query": "delete from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "Instructions": { @@ -147,6 +150,7 @@ "comment": "Delete in a table with shard-scoped foreign keys with cascade", "query": "delete from tbl5", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from tbl5", "Instructions": { @@ -229,6 +233,7 @@ "comment": "Delete in a table with unsharded foreign key with SET NULL", "query": "delete from u_tbl9 where col9 = 5", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from u_tbl9 where col9 = 5", "Instructions": { @@ -286,6 +291,7 @@ "comment": "update in unsharded table with restrict", "query": "update u_tbl5 set col5 = 'foo' where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update u_tbl5 set col5 = 'foo' where id = 1", "Instructions": { @@ -308,6 +314,7 @@ "comment": "update in unsharded table with cascade", "query": "update u_tbl2 set col2 = 'bar' where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set col2 = 'bar' where id = 1", "Instructions": { @@ -365,6 +372,7 @@ "comment": "update in unsharded table with cascade - on non-referenced column", "query": "update u_tbl2 set col_no_ref = 'baz' where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update u_tbl2 set col_no_ref = 'baz' where id = 1", "Instructions": { @@ -392,6 +400,7 @@ "comment": "Update in a table with cross-shard foreign keys, column not in update expression - allowed", "query": "update tbl1 set not_ref_col = 'foo' where id = 1", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update tbl1 set not_ref_col = 'foo' where id = 1", "Instructions": { @@ -419,6 +428,7 @@ "comment": "Update in a table with shard-scoped foreign keys with cascade", "query": "update tbl5 set t5col5 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl5 set t5col5 = 'foo'", "Instructions": { @@ -481,6 +491,7 @@ "comment": "Update a table with parent and child foreign keys - shard scoped", "query": "update tbl2 set col = 'foo'", "plan": { + "Type": "Scatter", "QueryType": "UPDATE", "Original": "update tbl2 set col = 'foo'", "Instructions": { @@ -503,6 +514,7 @@ "comment": "update table with column's parent foreign key cross shard", "query": "update tbl10 set col = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl10 set col = 'foo'", "Instructions": { @@ -588,6 +600,7 @@ "comment": "Delete table with cross-shard foreign key with set null - should be eventually allowed", "query": "delete from tbl9 where col9 = 34", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from tbl9 where col9 = 34", "Instructions": { @@ -653,6 +666,7 @@ "comment": "update table with same column having reference to different tables, one with on update cascade other with on update set null - child table have further reference", "query": "update u_tbl1 set col1 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 set col1 = 'foo'", "Instructions": { @@ -797,6 +811,7 @@ "comment": "update with limit with foreign keys", "query": "update u_tbl2 set col2 = 'bar' limit 2", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set col2 = 'bar' limit 2", "Instructions": { @@ -874,6 +889,7 @@ "comment": "update in a table with non-literal value - set null fail due to child update where condition", "query": "update u_tbl2 set m = 2, col2 = col1 + 'bar' where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set m = 2, col2 = col1 + 'bar' where id = 1", "Instructions": { @@ -957,6 +973,7 @@ "comment": "update in a table with non-literal value - with cascade fail as the cascade value is not known", "query": "update u_tbl1 set m = 2, col1 = x + 'bar' where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 set m = 2, col1 = x + 'bar' where id = 1", "Instructions": { @@ -1115,6 +1132,7 @@ "comment": "update in a table with set null, non-literal value on non-foreign key column - allowed", "query": "update u_tbl2 set m = col1 + 'bar', col2 = 2 where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl2 set m = col1 + 'bar', col2 = 2 where id = 1", "Instructions": { @@ -1172,6 +1190,7 @@ "comment": "update in a table with cascade, non-literal value on non-foreign key column - allowed", "query": "update u_tbl1 set m = x + 'bar', col1 = 2 where id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl1 set m = x + 'bar', col1 = 2 where id = 1", "Instructions": { @@ -1321,6 +1340,7 @@ "comment": "delete in a table with limit", "query": "delete from u_tbl2 limit 2", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete from u_tbl2 limit 2", "Instructions": { @@ -1398,6 +1418,7 @@ "comment": "update with fk on cross-shard with a where condition on non-literal value - disallowed", "query": "update tbl3 set coly = colx + 10 where coly = 10", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl3 set coly = colx + 10 where coly = 10", "Instructions": { @@ -1481,6 +1502,7 @@ "comment": "update with fk on cross-shard with a where condition", "query": "update tbl3 set coly = 20 where coly = 10", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update tbl3 set coly = 20 where coly = 10", "Instructions": { @@ -1561,6 +1583,7 @@ "comment": "Update in a table with shard-scoped foreign keys with cascade that requires a validation of a different parent foreign key", "query": "update u_tbl6 set col6 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl6 set col6 = 'foo'", "Instructions": { @@ -1637,6 +1660,7 @@ "comment": "Update that cascades and requires parent fk and restrict child fk verification", "query": "update u_tbl7 set col7 = 'foo'", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl7 set col7 = 'foo'", "Instructions": { @@ -1726,6 +1750,7 @@ "comment": "Update that cascades and requires parent fk and restrict child fk verification - bindVariable", "query": "update u_tbl7 set col7 = :v1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_tbl7 set col7 = :v1", "Instructions": { @@ -1815,6 +1840,7 @@ "comment": "Insert with on duplicate key update - foreign keys disallowed", "query": "insert into u_tbl1 (id, col1) values (1, 3) on duplicate key update col1 = 5", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "insert into u_tbl1 (id, col1) values (1, 3) on duplicate key update col1 = 5", "Instructions": { @@ -1979,6 +2005,7 @@ "comment": "Insert with on duplicate key update - foreign keys not on update column - allowed", "query": "insert into u_tbl1 (id, col1, foo) values (1, 3, 'bar') on duplicate key update foo = 'baz'", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into u_tbl1 (id, col1, foo) values (1, 3, 'bar') on duplicate key update foo = 'baz'", "Instructions": { @@ -2006,6 +2033,7 @@ "comment": "replace with fk reference unsupported", "query": "replace into u_tbl1 (id, col1) values (1, 2)", "plan": { + "Type": "Complex", "QueryType": "INSERT", "Original": "replace into u_tbl1 (id, col1) values (1, 2)", "Instructions": { @@ -2115,6 +2143,7 @@ "comment": "update on a multicol foreign key that set nulls and then cascades", "query": "update u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "Instructions": { @@ -2209,6 +2238,7 @@ "comment": "update on a multicol foreign key that set nulls and then cascades - bindVariables", "query": "update /*+ SET_VAR(foreign_key_checks=On) */ u_multicol_tbl1 set cola = :v1, colb = :v2 where id = :v3", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update /*+ SET_VAR(foreign_key_checks=On) */ u_multicol_tbl1 set cola = :v1, colb = :v2 where id = :v3", "Instructions": { @@ -2303,6 +2333,7 @@ "comment": "Cascaded delete run from prepared statement", "query": "execute prep_delete using @foo", "plan": { + "Type": "Complex", "QueryType": "EXECUTE", "Original": "execute prep_delete using @foo", "Instructions": { @@ -2388,6 +2419,7 @@ "comment": "Delete with foreign key checks off", "query": "delete /*+ SET_VAR(foreign_key_checks=off) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete /*+ SET_VAR(foreign_key_checks=off) */ from multicol_tbl1 where cola = 1 and colb = 2 and colc = 3", "Instructions": { @@ -2416,6 +2448,7 @@ "comment": "Update with foreign key checks off", "query": "update /*+ SET_VAR(foreign_key_checks=0) */ u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update /*+ SET_VAR(foreign_key_checks=0) */ u_multicol_tbl1 set cola = 1, colb = 2 where id = 3", "Instructions": { @@ -2438,6 +2471,7 @@ "comment": "Insert with cross shard foreign keys and foreign key checks off", "query": "insert /*+ SET_VAR(foreign_key_checks=0) */ into tbl3 (col3, coly) values (1, 3)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert /*+ SET_VAR(foreign_key_checks=0) */ into tbl3 (col3, coly) values (1, 3)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.json b/go/vt/vtgate/planbuilder/testdata/from_cases.json index bec64fd7b1e..ba8d4ff30ed 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.json @@ -3,6 +3,7 @@ "comment": "Single table sharded scatter", "query": "select col from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from user", "Instructions": { @@ -25,6 +26,7 @@ "comment": "Single table unsharded", "query": "select col from unsharded", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from unsharded", "Instructions": { @@ -47,6 +49,7 @@ "comment": "Select from sequence", "query": "select next 2 values from seq", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select next 2 values from seq", "Instructions": { @@ -94,6 +97,7 @@ "comment": "Select from reference", "query": "select * from ref", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from ref", "Instructions": { @@ -116,6 +120,7 @@ "comment": "Multi-table unsharded", "query": "select m1.col from unsharded as m1 join unsharded as m2", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select m1.col from unsharded as m1 join unsharded as m2", "Instructions": { @@ -138,6 +143,7 @@ "comment": "Multi-table, multi-chunk", "query": "select music.col from user join music", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select music.col from user join music", "Instructions": { @@ -180,6 +186,7 @@ "comment": "routing rules where table name matches, and there's no alias.", "query": "select * from second_user.user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from second_user.user", "Instructions": { @@ -202,6 +209,7 @@ "comment": "routing rules where table name matches, and there's an alias.", "query": "select * from second_user.user as a", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from second_user.user as a", "Instructions": { @@ -224,6 +232,7 @@ "comment": "routing rules where table name does not match, and there's no alias.", "query": "select * from route1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from route1", "Instructions": { @@ -246,6 +255,7 @@ "comment": "routing rules where table name does not match, and there's an alias.", "query": "select * from route1 as a", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from route1 as a", "Instructions": { @@ -268,6 +278,7 @@ "comment": "routing rules with primary targeting", "query": "select * from primary_redirect", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from primary_redirect", "Instructions": { @@ -300,6 +311,7 @@ "comment": "select second_user.foo.col from second_user.foo join user on second_user.foo.id = user.id where second_user.foo.col = 42", "query": "select second_user.foo.col from second_user.foo join user on second_user.foo.id = user.id where second_user.foo.col = 42", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select second_user.foo.col from second_user.foo join user on second_user.foo.id = user.id where second_user.foo.col = 42", "Instructions": { @@ -322,6 +334,7 @@ "comment": "select user.music.foo from user.music join user on user.music.id = user.id where user.music.col = 42", "query": "select user.music.foo from user.music join user on user.music.id = user.id where user.music.col = 42", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.music.foo from user.music join user on user.music.id = user.id where user.music.col = 42", "Instructions": { @@ -371,6 +384,7 @@ "comment": "',' join", "query": "select music.col from user, music", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select music.col from user, music", "Instructions": { @@ -413,6 +427,7 @@ "comment": "DISTINCT inside derived table", "query": "select * from (select distinct name from user) as t", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from (select distinct name from user) as t", "Instructions": { @@ -435,6 +450,7 @@ "comment": "',' join unsharded", "query": "select u1.a, u2.a from unsharded u1, unsharded u2", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u1.a, u2.a from unsharded u1, unsharded u2", "Instructions": { @@ -457,6 +473,7 @@ "comment": "',' 3-way join unsharded", "query": "select u1.a, u2.a from unsharded u1, unsharded u2, unsharded u3", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u1.a, u2.a from unsharded u1, unsharded u2, unsharded u3", "Instructions": { @@ -479,6 +496,7 @@ "comment": "Left join, single chunk", "query": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a=m2.b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select m1.col from unsharded as m1 left join unsharded as m2 on m1.a=m2.b", "Instructions": { @@ -501,6 +519,7 @@ "comment": "Left join, multi-chunk", "query": "select u.col from user u left join unsharded m on u.a = m.b", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.col from user u left join unsharded m on u.a = m.b", "Instructions": { @@ -546,6 +565,7 @@ "comment": "Three-way left join", "query": "select user.col, m2.foo from user left join unsharded as m1 on user.col = m1.col left join unsharded as m2 on m1.col = m2.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col, m2.foo from user left join unsharded as m1 on user.col = m1.col left join unsharded as m2 on m1.col = m2.col", "Instructions": { @@ -613,6 +633,7 @@ "comment": "Three-way left join, right-associated", "query": "select user.col from user left join user_extra as e left join unsharded as m1 on m1.col = e.col on user.col = e.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user left join user_extra as e left join unsharded as m1 on m1.col = e.col on user.col = e.col", "Instructions": { @@ -680,6 +701,7 @@ "comment": "Right join", "query": "select m1.col from unsharded as m1 right join unsharded as m2 on m1.a=m2.b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select m1.col from unsharded as m1 right join unsharded as m2 on m1.a=m2.b", "Instructions": { @@ -702,6 +724,7 @@ "comment": "Right join with a join LHS", "query": "select m1.col from unsharded as m1 join unsharded as m2 right join unsharded as m3 on m1.a=m2.b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select m1.col from unsharded as m1 join unsharded as m2 right join unsharded as m3 on m1.a=m2.b", "Instructions": { @@ -724,6 +747,7 @@ "comment": "Complex query that has hash left join underneath a memory sort and ordered aggregation", "query": "select 1 from user join user_extra on user.id = user_extra.user_id join music on music.intcol = user_extra.col left join (select user_metadata.col, count(*) as count from user_metadata group by user_metadata.col) um on um.col = user_extra.col where user.id IN (103) group by user_extra.col, music.intcol", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from user join user_extra on user.id = user_extra.user_id join music on music.intcol = user_extra.col left join (select user_metadata.col, count(*) as count from user_metadata group by user_metadata.col) um on um.col = user_extra.col where user.id IN (103) group by user_extra.col, music.intcol", "Instructions": { @@ -835,6 +859,7 @@ "comment": "Straight-join (ignores the straight_join hint)", "query": "select m1.col from unsharded as m1 straight_join unsharded as m2", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select m1.col from unsharded as m1 straight_join unsharded as m2", "Instructions": { @@ -857,6 +882,7 @@ "comment": "Three-way join", "query": "select user.col from user join unsharded as m1 join unsharded as m2", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join unsharded as m1 join unsharded as m2", "Instructions": { @@ -899,6 +925,7 @@ "comment": "Outer join with join predicates that only depend on the inner side", "query": "select 1 from user left join user_extra on user.foo = 42 and user.bar = user_extra.bar", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from user left join user_extra on user.foo = 42 and user.bar = user_extra.bar", "Instructions": { @@ -952,6 +979,7 @@ "comment": "Parenthesized, single chunk", "query": "select user.col from user join (unsharded as m1 join unsharded as m2)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join (unsharded as m1 join unsharded as m2)", "Instructions": { @@ -994,6 +1022,7 @@ "comment": "Parenthesized, multi-chunk", "query": "select user.col from user join (user as u1 join unsharded)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join (user as u1 join unsharded)", "Instructions": { @@ -1055,6 +1084,7 @@ "comment": "index hints, make sure they are not stripped.", "query": "select user.col from user use index(a)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user use index(a)", "Instructions": { @@ -1077,6 +1107,7 @@ "comment": "multiple index hints, make sure they are not stripped.", "query": "select user.col from user use index(a) use index for group by (b)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user use index(a) use index for group by (b)", "Instructions": { @@ -1099,6 +1130,7 @@ "comment": "mergeable sharded join on unique vindex", "query": "select user.col from user join user_extra on user.id = user_extra.user_id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user.id = user_extra.user_id", "Instructions": { @@ -1122,6 +1154,7 @@ "comment": "mergeable sharded join on unique vindex (parenthesized ON clause)", "query": "select user.col from user join user_extra on (user.id = user_extra.user_id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on (user.id = user_extra.user_id)", "Instructions": { @@ -1145,6 +1178,7 @@ "comment": "mergeable sharded join on unique vindex, with a stray condition", "query": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user.col between 1 and 2 and user.id = user_extra.user_id", "Instructions": { @@ -1168,6 +1202,7 @@ "comment": "mergeable sharded join on unique vindex, swapped operands", "query": "select user.col from user join user_extra on user_extra.user_id = user.id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user_extra.user_id = user.id", "Instructions": { @@ -1191,6 +1226,7 @@ "comment": "mergeable sharded join on unique vindex, and condition", "query": "select user.col from user join user_extra on user.id = 5 and user.id = user_extra.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user.id = 5 and user.id = user_extra.user_id", "Instructions": { @@ -1218,6 +1254,7 @@ "comment": "sharded join on unique vindex, inequality", "query": "select user.col from user join user_extra on user.id < user_extra.user_id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user.id < user_extra.user_id", "Instructions": { @@ -1263,6 +1300,7 @@ "comment": "sharded join, non-col reference RHS", "query": "select user.col from user join user_extra on user.id = 5", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user.id = 5", "Instructions": { @@ -1309,6 +1347,7 @@ "comment": "sharded join, non-col reference LHS", "query": "select user.col from user join user_extra on 5 = user.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on 5 = user.id", "Instructions": { @@ -1355,6 +1394,7 @@ "comment": "sharded join, non-vindex col", "query": "select user.col from user join user_extra on user.id = user_extra.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user.id = user_extra.col", "Instructions": { @@ -1404,6 +1444,7 @@ "comment": "sharded join, non-unique vindex", "query": "select user.col from user_extra join user on user_extra.user_id = user.name", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user_extra join user on user_extra.user_id = user.name", "Instructions": { @@ -1453,6 +1494,7 @@ "comment": "join with reference table", "query": "select user.col from user join ref", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join ref", "Instructions": { @@ -1476,6 +1518,7 @@ "comment": "reference table self-join", "query": "select r1.col from ref r1 join ref", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select r1.col from ref r1 join ref", "Instructions": { @@ -1498,6 +1541,7 @@ "comment": "reference table can merge with other opcodes left to right.", "query": "select ref.col from ref join user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select ref.col from ref join user", "Instructions": { @@ -1521,6 +1565,7 @@ "comment": "reference table can merge with other opcodes left to right and vindex value is in the plan.\n# This tests that route.Merge also copies the condition to the LHS.", "query": "select ref.col from ref join (select aa from user where user.id=1) user", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select ref.col from ref join (select aa from user where user.id=1) user", "Instructions": { @@ -1548,6 +1593,7 @@ "comment": "routing rules for join, unsharded route wins if we can't find a merged route", "query": "select route2.col from route2 join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select route2.col from route2 join user_extra", "Instructions": { @@ -1590,6 +1636,7 @@ "comment": "derived table", "query": "select id from (select id, col from user where id = 5) as t", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from (select id, col from user where id = 5) as t", "Instructions": { @@ -1616,6 +1663,7 @@ "comment": "derived table with join", "query": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.user_id", "Instructions": { @@ -1643,6 +1691,7 @@ "comment": "derived table with join, and aliased references", "query": "select t.id from (select user.id from user where user.id = 5) as t join user_extra on t.id = user_extra.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t.id from (select user.id from user where user.id = 5) as t join user_extra on t.id = user_extra.user_id", "Instructions": { @@ -1675,6 +1724,7 @@ "comment": "derived table in RHS of join", "query": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t.id from user_extra join (select id from user where id = 5) as t on t.id = user_extra.user_id", "Instructions": { @@ -1702,6 +1752,7 @@ "comment": "derived table in FROM with cross-shard join", "query": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.id from (select id from user where id = 5) as t join user_extra on t.id = user_extra.col", "Instructions": { @@ -1751,6 +1802,7 @@ "comment": "routing rules for derived table", "query": "select id from (select id, col from route1 where id = 5) as t", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from (select id, col from route1 where id = 5) as t", "Instructions": { @@ -1782,6 +1834,7 @@ "comment": "routing rules for derived table where the constraint is in the outer query", "query": "select id from (select id, col from route1) as t where id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from (select id, col from route1) as t where id = 5", "Instructions": { @@ -1813,6 +1866,7 @@ "comment": "push predicate on joined derived tables", "query": "select t.id from (select id, textcol1 as baz from route1) as t join (select id, textcol1+textcol1 as baz from user) as s ON t.id = s.id WHERE t.baz = '3' AND s.baz = '3'", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select t.id from (select id, textcol1 as baz from route1) as t join (select id, textcol1+textcol1 as baz from user) as s ON t.id = s.id WHERE t.baz = '3' AND s.baz = '3'", "Instructions": { @@ -1835,6 +1889,7 @@ "comment": "recursive derived table predicate push down", "query": "select bar from (select foo+4 as bar from (select colA+colB as foo from user) as u) as t where bar = 5", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select bar from (select foo+4 as bar from (select colA+colB as foo from user) as u) as t where bar = 5", "Instructions": { @@ -1857,6 +1912,7 @@ "comment": "recursive derived table lookups", "query": "select id from (select id from (select id from user) as u) as t where id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from (select id from (select id from user) as u) as t where id = 5", "Instructions": { @@ -1883,6 +1939,7 @@ "comment": "merge derived tables with single-shard routes", "query": "select u.col, e.col from (select col from user where id = 5) as u join (select col from user_extra where user_id = 5) as e", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u.col, e.col from (select col from user where id = 5) as u join (select col from user_extra where user_id = 5) as e", "Instructions": { @@ -1910,6 +1967,7 @@ "comment": "Unneeded ORDER BY inside derived table removed", "query": "select * from (select id from user order by foo) dt1, (select id from user order by baz) dt2", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select * from (select id from user order by foo) dt1, (select id from user order by baz) dt2", "Instructions": { @@ -1951,6 +2009,7 @@ "comment": "join of information_schema with normal table", "query": "select unsharded.foo from information_schema.CHARACTER_SETS join unsharded", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select unsharded.foo from information_schema.CHARACTER_SETS join unsharded", "Instructions": { @@ -1992,6 +2051,7 @@ "comment": "three table join with join predicate touching all tables", "query": "select 42 from user u join user_extra ue on u.id = ue.user_id join music m on m.user_id = u.id where u.foo or m.foo or ue.foo", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select 42 from user u join user_extra ue on u.id = ue.user_id join music m on m.user_id = u.id where u.foo or m.foo or ue.foo", "Instructions": { @@ -2016,6 +2076,7 @@ "comment": "join of normal table with information_schema", "query": "select unsharded.foo from unsharded join information_schema.CHARACTER_SETS", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select unsharded.foo from unsharded join information_schema.CHARACTER_SETS", "Instructions": { @@ -2057,6 +2118,7 @@ "comment": "wire-up on join with cross-shard derived table", "query": "select t.col1 from (select user.id, user.col1 from user join user_extra) as t join unsharded on unsharded.col1 = t.col1 and unsharded.id = t.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.col1 from (select user.id, user.col1 from user join user_extra) as t join unsharded on unsharded.col1 = t.col1 and unsharded.id = t.id", "Instructions": { @@ -2123,6 +2185,7 @@ "comment": "wire-up on within cross-shard derived table", "query": "select t.id from (select user.id, user.col1 from user join user_extra on user_extra.col = user.col) as t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.id from (select user.id, user.col1 from user join user_extra on user_extra.col = user.col) as t", "Instructions": { @@ -2168,6 +2231,7 @@ "comment": "Join with cross-shard derived table on rhs", "query": "select t.col1 from unsharded_a ua join (select user.id, user.col1 from user join user_extra) as t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.col1 from unsharded_a ua join (select user.id, user.col1 from user join user_extra) as t", "Instructions": { @@ -2230,6 +2294,7 @@ "comment": "Join with cross-shard derived table on rhs - push down join predicate to derived table", "query": "select t.col1 from unsharded_a ua join (select user.id, user.col1 from user join user_extra) as t on t.id = ua.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.col1 from unsharded_a ua join (select user.id, user.col1 from user join user_extra) as t on t.id = ua.id", "Instructions": { @@ -2299,6 +2364,7 @@ "comment": "subquery in ON clause, single route", "query": "select unsharded_a.col from unsharded_a join unsharded_b on (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select unsharded_a.col from unsharded_a join unsharded_b on (select col from user)", "Instructions": { @@ -2345,6 +2411,7 @@ "comment": "subquery in ON clause as sub-expression", "query": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col+(select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col+(select col from user)", "Instructions": { @@ -2391,6 +2458,7 @@ "comment": "IN subquery in ON clause, single route", "query": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col in (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select unsharded_a.col from unsharded_a join unsharded_b on unsharded_a.col in (select col from user)", "Instructions": { @@ -2438,6 +2506,7 @@ "comment": "subquery in ON clause, with join primitives", "query": "select unsharded.col from unsharded join user on user.col in (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select unsharded.col from unsharded join user on user.col in (select col from user)", "Instructions": { @@ -2510,6 +2579,7 @@ "comment": "subquery in ON clause, with join primitives, and join on top\n# The subquery is not pulled all the way out.", "query": "select unsharded.col from unsharded join user on user.col in (select col from user) join unsharded_a", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select unsharded.col from unsharded join user on user.col in (select col from user) join unsharded_a", "Instructions": { @@ -2601,6 +2671,7 @@ "comment": "keyspace-qualified queries", "query": "select user.user.col1, main.unsharded.col1 from user.user join main.unsharded where main.unsharded.col2 = user.user.col2", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.user.col1, main.unsharded.col1 from user.user join main.unsharded where main.unsharded.col2 = user.user.col2", "Instructions": { @@ -2646,6 +2717,7 @@ "comment": "implicit table reference for unsharded keyspace", "query": "select main.foo.col from main.foo", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select main.foo.col from main.foo", "Instructions": { @@ -2668,6 +2740,7 @@ "comment": "col refs should be case-insensitive", "query": "select user.col from user join user_extra on user.ID = user_extra.User_Id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join user_extra on user.ID = user_extra.User_Id", "Instructions": { @@ -2691,6 +2764,7 @@ "comment": "derived table with join primitive (FROM)", "query": "select id, t.id from (select user.id from user join user_extra) as t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select id, t.id from (select user.id from user join user_extra) as t", "Instructions": { @@ -2733,6 +2807,7 @@ "comment": "database call in ON clause.\n# The on clause is weird because the substitution must even for root expressions.", "query": "select u1.a from unsharded u1 join unsharded u2 on database()", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u1.a from unsharded u1 join unsharded u2 on database()", "Instructions": { @@ -2755,6 +2830,7 @@ "comment": "last_insert_id for dual", "query": "select last_insert_id()", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select last_insert_id()", "Instructions": { @@ -2777,6 +2853,7 @@ "comment": "last_insert_id for sharded keyspace", "query": "select last_insert_id() from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select last_insert_id() from user", "Instructions": { @@ -2799,6 +2876,7 @@ "comment": "last_insert_id for unsharded route", "query": "select last_insert_id() from main.unsharded", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select last_insert_id() from main.unsharded", "Instructions": { @@ -2821,6 +2899,7 @@ "comment": "join with bindvariables", "query": "SELECT `user`.`id` FROM `user` INNER JOIN `user_extra` ON `user`.`id` = `user_extra`.`assembly_id` WHERE `user_extra`.`user_id` = 2", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT `user`.`id` FROM `user` INNER JOIN `user_extra` ON `user`.`id` = `user_extra`.`assembly_id` WHERE `user_extra`.`user_id` = 2", "Instructions": { @@ -2874,6 +2953,7 @@ "comment": "verify ',' vs JOIN precedence", "query": "select u1.a from unsharded u1, unsharded u2 join unsharded u3 on u1.a = u2.a", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u1.a from unsharded u1, unsharded u2 join unsharded u3 on u1.a = u2.a", "Instructions": { @@ -2901,6 +2981,7 @@ "comment": "table names should be case-sensitive", "query": "select unsharded.id from unsharded where Unsharded.val = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select unsharded.id from unsharded where Unsharded.val = 1", "Instructions": { @@ -2953,6 +3034,7 @@ "comment": "query with parens is planned correctly", "query": "select m1.col from (unsharded as m1, unsharded as m2)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select m1.col from (unsharded as m1, unsharded as m2)", "Instructions": { @@ -2975,6 +3057,7 @@ "comment": "optimise plan by merging user_extra and music first, and then querying for user info", "query": "select 1 from user u join user_extra ue on ue.id = u.id join music m on m.user_id = ue.user_id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select 1 from user u join user_extra ue on ue.id = u.id join music m on m.user_id = ue.user_id", "Instructions": { @@ -3025,6 +3108,7 @@ "comment": "join column selected as alias", "query": "SELECT u.id as uid, ue.id as ueid FROM user u join user_extra ue where u.id = ue.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT u.id as uid, ue.id as ueid FROM user u join user_extra ue where u.id = ue.id", "Instructions": { @@ -3074,6 +3158,7 @@ "comment": "Hash join has to be used since we have LIMIT on both sides", "query": "select id from (select id from user limit 10) u join (select user_id from user_extra limit 10) ue on u.id = ue.user_id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from (select id from user limit 10) u join (select user_id from user_extra limit 10) ue on u.id = ue.user_id", "Instructions": { @@ -3130,6 +3215,7 @@ "comment": "alias on column from derived table. TODO: to support alias in SimpleProjection engine primitive.", "query": "select a as k from (select count(*) as a from user) t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a as k from (select count(*) as a from user) t", "Instructions": { @@ -3167,6 +3253,7 @@ "comment": "select star from derived table on expandable and unsharded table", "query": "select u.* from (select * from unsharded) u", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select u.* from (select * from unsharded) u", "Instructions": { @@ -3189,6 +3276,7 @@ "comment": "filtering on a cross-shard derived table", "query": "select id from (select user.id, user.col from user join user_extra) as t where id=5", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select id from (select user.id, user.col from user join user_extra) as t where id=5", "Instructions": { @@ -3235,6 +3323,7 @@ "comment": "expression on a cross-shard derived table", "query": "select id+1 from (select user.id, user.col from user join user_extra) as t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select id+1 from (select user.id, user.col from user join user_extra) as t", "Instructions": { @@ -3277,6 +3366,7 @@ "comment": "derived table with aliased columns and outer predicate pushed in derived table", "query": "select u.a from (select id as b, name from user) u(a, n) where u.n = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.a from (select id as b, name from user) u(a, n) where u.n = 1", "Instructions": { @@ -3328,6 +3418,7 @@ "comment": "derived table with aliased columns predicate in both the outer and inner", "query": "select u.a from (select id as b, name from user where b = 1) u(a, n) where u.n = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.a from (select id as b, name from user where b = 1) u(a, n) where u.n = 1", "Instructions": { @@ -3379,6 +3470,7 @@ "comment": "derived table with aliased columns and a join that requires pushProjection", "query": "select i+1 from (select user.id from user join user_extra) t(i)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select i+1 from (select user.id from user join user_extra) t(i)", "Instructions": { @@ -3421,6 +3513,7 @@ "comment": "two subqueries with different Select and OpCode", "query": "select id from user where id in (select id from user_extra) and col = (select user_id from user_extra limit 1)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id in (select id from user_extra) and col = (select user_id from user_extra limit 1)", "Instructions": { @@ -3499,6 +3592,7 @@ "comment": "join on int columns", "query": "select u.id from user as u join user as uu on u.intcol = uu.intcol", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.id from user as u join user as uu on u.intcol = uu.intcol", "Instructions": { @@ -3543,6 +3637,7 @@ "comment": "Duplicate output column from derived table having a join", "query": "select 0 from (select `user`.col1 from `user` join unsharded) as t join unsharded on unsharded.col1 = t.col1 and unsharded.a = t.col1", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select 0 from (select `user`.col1 from `user` join unsharded) as t join unsharded on unsharded.col1 = t.col1 and unsharded.a = t.col1", "Instructions": { @@ -3607,6 +3702,7 @@ "comment": "left join where clauses #2", "query": "select user.id from user left join user_extra on user.col = user_extra.col where coalesce(user_extra.col, 4) = 5", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.id from user left join user_extra on user.col = user_extra.col where coalesce(user_extra.col, 4) = 5", "Instructions": { @@ -3659,6 +3755,7 @@ "comment": "dont merge unsharded tables from different keyspaces", "query": "select 1 from main.unsharded join main_2.unsharded_tab", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select 1 from main.unsharded join main_2.unsharded_tab", "Instructions": { @@ -3701,6 +3798,7 @@ "comment": "Unsharded join with using", "query": "select * from unsharded_a join unsharded_b using (propertyId);", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from unsharded_a join unsharded_b using (propertyId);", "Instructions": { @@ -3724,6 +3822,7 @@ "comment": "Column aliases in Derived Table", "query": "select id2 from (select id from user) as x (id2)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id2 from (select id from user) as x (id2)", "Instructions": { @@ -3746,6 +3845,7 @@ "comment": "single unsharded keyspace with derived table", "query": "select col from (select col from unsharded join unsharded_b) as u join unsharded_a ua limit 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from (select col from unsharded join unsharded_b) as u join unsharded_a ua limit 1", "Instructions": { @@ -3770,6 +3870,7 @@ "comment": "query builder with derived table having join inside it", "query": "select u.col from (select user.col from user join user_extra) as u join user_extra ue limit 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.col from (select user.col from user join user_extra) as u join user_extra ue limit 1", "Instructions": { @@ -3843,6 +3944,7 @@ "comment": "left join with expressions", "query": "select user_extra.col+1 from user left join user_extra on user.col = user_extra.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user_extra.col+1 from user left join user_extra on user.col = user_extra.col", "Instructions": { @@ -3896,6 +3998,7 @@ "comment": "left join with expressions, with three-way join (different code path)", "query": "select user.id, user_extra.col+1 from user left join user_extra on user.col = user_extra.col join user_extra e", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.id, user_extra.col+1 from user left join user_extra on user.col = user_extra.col join user_extra e", "Instructions": { @@ -3969,6 +4072,7 @@ "comment": "left join with expressions coming from both sides", "query": "select user.foo+user_extra.col+1 from user left join user_extra on user.col = user_extra.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.foo+user_extra.col+1 from user left join user_extra on user.col = user_extra.col", "Instructions": { @@ -4022,6 +4126,7 @@ "comment": "Do not rewrite derived expressions when the derived table is merged with the outer", "query": "select col1, count(*) from (select colC+colD as col1 from user) as tbl group by col1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1, count(*) from (select colC+colD as col1 from user) as tbl group by col1", "Instructions": { @@ -4054,6 +4159,7 @@ "comment": "join with USING construct", "query": "select * from authoritative join unsharded_authoritative using(col1)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select * from authoritative join unsharded_authoritative using(col1)", "Instructions": { @@ -4099,6 +4205,7 @@ "comment": "derived table inside derived table with a where clause depending on columns from the derived table", "query": "select * from (select bar as push_it from (select foo as bar from (select id as foo from user) as t1) as t2) as t3 where push_it = 12", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from (select bar as push_it from (select foo as bar from (select id as foo from user) as t1) as t2) as t3 where push_it = 12", "Instructions": { @@ -4125,6 +4232,7 @@ "comment": "use a view", "query": "select * from user.user_details_view", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from user.user_details_view", "Instructions": { @@ -4148,6 +4256,7 @@ "comment": "use a view without qualifying the keyspace", "query": "select * from user_details_view", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from user_details_view", "Instructions": { @@ -4171,6 +4280,7 @@ "comment": "left join where clauses #3 - assert that we can evaluate BETWEEN with the evalengine", "query": "select user.id from user left join user_extra on user.col = user_extra.col where user_extra.col between 10 and 20", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.id from user left join user_extra on user.col = user_extra.col where user_extra.col between 10 and 20", "Instructions": { @@ -4223,6 +4333,7 @@ "comment": "missing and ambiguous column info is OK as long as we can send the query to a single unsharded keyspace", "query": "select missing_column from unsharded, unsharded_a", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select missing_column from unsharded, unsharded_a", "Instructions": { @@ -4251,6 +4362,7 @@ "comment": "join predicate only depending on the RHS should not turn outer join into inner join", "query": "select t1.id1, t2.id1 from t1 left join t1 as t2 on t2.id1 = t2.id2", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t1.id1, t2.id1 from t1 left join t1 as t2 on t2.id1 = t2.id2", "Instructions": { @@ -4292,6 +4404,7 @@ "comment": "left join with using has to be transformed into inner join with on condition", "query": "SELECT * FROM unsharded_authoritative as A LEFT JOIN unsharded_authoritative as B USING(col1)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM unsharded_authoritative as A LEFT JOIN unsharded_authoritative as B USING(col1)", "Instructions": { @@ -4314,6 +4427,7 @@ "comment": "join query using table with muticolumn vindex", "query": "select 1 from multicol_tbl m1 join multicol_tbl m2 on m1.cola = m2.cola", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select 1 from multicol_tbl m1 join multicol_tbl m2 on m1.cola = m2.cola", "Instructions": { @@ -4367,6 +4481,7 @@ "comment": "query that needs a hash join", "query": "select id from user left join (select col from user_extra limit 10) ue on user.col = ue.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user left join (select col from user_extra limit 10) ue on user.col = ue.col", "Instructions": { @@ -4418,6 +4533,7 @@ "comment": "query that needs a hash join - both sides have limits", "query": "select id, user_id from (select id, col from user limit 10) u join (select col, user_id from user_extra limit 10) ue on u.col = ue.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, user_id from (select id, col from user limit 10) u join (select col, user_id from user_extra limit 10) ue on u.col = ue.col", "Instructions": { @@ -4475,6 +4591,7 @@ "comment": "query that needs a hash join - both sides have limits. check that it can be merged even with the hash join", "query": "select id, user_id from (select id, col from user where id = 17 limit 10) u join (select col, user_id from user_extra where user_id = 17 limit 10) ue on u.col = ue.col", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id, user_id from (select id, col from user where id = 17 limit 10) u join (select col, user_id from user_extra where user_id = 17 limit 10) ue on u.col = ue.col", "Instructions": { @@ -4502,6 +4619,7 @@ "comment": "query that needs a hash join - outer side has LIMIT. distinct should be pushed down", "query": "select distinct id, user_id from (select id, col from user) u left join (select col, user_id from user_extra limit 10) ue on u.col = ue.col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct id, user_id from (select id, col from user) u left join (select col, user_id from user_extra limit 10) ue on u.col = ue.col", "Instructions": { @@ -4562,6 +4680,7 @@ "comment": "unexpanded columns are fine if we can push down into single route", "query": "select x from (select t.*, 1 as x from unsharded t union select t.*, 1 as x from unsharded t) as x", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select x from (select t.*, 1 as x from unsharded t union select t.*, 1 as x from unsharded t) as x", "Instructions": { @@ -4584,6 +4703,7 @@ "comment": "pushing derived projection under the join should not cause problems", "query": "SELECT count(*) FROM (SELECT DISTINCT u.user_id FROM user u JOIN user_extra ue ON u.id = ue.user_id JOIN music m ON m.id = u.id) subquery_for_count", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT count(*) FROM (SELECT DISTINCT u.user_id FROM user u JOIN user_extra ue ON u.id = ue.user_id JOIN music m ON m.id = u.id) subquery_for_count", "Instructions": { @@ -4657,6 +4777,7 @@ "comment": "join table influencing vindex selection with ignore and use vindex syntax", "query": "select u.intcol, u.id from user u use vindex (name_user_map) join music m ignore vindex(user_index) on u.col = m.col where u.name = 'bb' and u.id = 3 and m.user_id = 5 and m.id = 20", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.intcol, u.id from user u use vindex (name_user_map) join music m ignore vindex(user_index) on u.col = m.col where u.name = 'bb' and u.id = 3 and m.user_id = 5 and m.id = 20", "Instructions": { @@ -4760,6 +4881,7 @@ "comment": "Cross keyspace join", "query": "select 1 from user join t1 on user.id = t1.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select 1 from user join t1 on user.id = t1.id", "Instructions": { @@ -4809,6 +4931,7 @@ "comment": "Select everything from a derived table having a cross-shard join", "query": "select * from (select u.foo * ue.bar from user u join user_extra ue) as dt", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select * from (select u.foo * ue.bar from user u join user_extra ue) as dt", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/info_schema57_cases.json b/go/vt/vtgate/planbuilder/testdata/info_schema57_cases.json index 31246a2f40f..89dd123733e 100644 --- a/go/vt/vtgate/planbuilder/testdata/info_schema57_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/info_schema57_cases.json @@ -3,6 +3,7 @@ "comment": "Single information_schema query", "query": "select TABLE_NAME from information_schema.TABLES", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select TABLE_NAME from information_schema.TABLES", "Instructions": { @@ -22,6 +23,7 @@ "comment": "',' join information_schema", "query": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b", "Instructions": { @@ -41,6 +43,7 @@ "comment": "information schema query that uses table_schema", "query": "select column_name from information_schema.columns where table_schema = (select schema())", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select column_name from information_schema.columns where table_schema = (select schema())", "Instructions": { @@ -60,6 +63,7 @@ "comment": "information schema join", "query": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files", "Instructions": { @@ -79,6 +83,7 @@ "comment": "access to qualified column names in information_schema", "query": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'", "Instructions": { @@ -98,6 +103,7 @@ "comment": "union of information_schema", "query": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables", "Instructions": { @@ -141,6 +147,7 @@ "comment": "union between information_schema tables that should not be merged", "query": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", "Instructions": { @@ -206,6 +213,7 @@ "comment": "Select from information schema query with two tables that route should be merged", "query": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "Instructions": { @@ -227,6 +235,7 @@ "comment": "Select from information schema query with three tables such that route for 2 should be merged but not for the last.", "query": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "Instructions": { @@ -248,6 +257,7 @@ "comment": "information_schema.routines", "query": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", "Instructions": { @@ -268,6 +278,7 @@ "comment": "information_schema table sizes", "query": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", "Instructions": { @@ -288,6 +299,7 @@ "comment": "information_schema referential contraints", "query": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", "Instructions": { @@ -331,6 +343,7 @@ "comment": "rails query", "query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", "Instructions": { @@ -351,6 +364,7 @@ "comment": "rails_query 2", "query": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", "Instructions": { @@ -371,6 +385,7 @@ "comment": "rails_query 3", "query": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", "Instructions": { @@ -392,6 +407,7 @@ "comment": "rails_query 4", "query": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", "Instructions": { @@ -413,6 +429,7 @@ "comment": "rails_query 6", "query": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", "Instructions": { @@ -434,6 +451,7 @@ "comment": "rails_query 7", "query": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", "Instructions": { @@ -455,6 +473,7 @@ "comment": "rails_query 8", "query": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", "Instructions": { @@ -474,6 +493,7 @@ "comment": "rails_query 9", "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", "Instructions": { @@ -494,6 +514,7 @@ "comment": "rails_query 10", "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", "Instructions": { @@ -514,6 +535,7 @@ "comment": "system schema in where clause of information_schema query", "query": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", "Instructions": { @@ -535,6 +557,7 @@ "comment": "subquery of information_schema with itself", "query": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)", "Instructions": { @@ -554,6 +577,7 @@ "comment": "query trying to query two different keyspaces at the same time", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", "Instructions": { @@ -574,6 +598,7 @@ "comment": "information_schema query using database() func", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", "Instructions": { @@ -593,6 +618,7 @@ "comment": "table_schema predicate the wrong way around", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", "Instructions": { @@ -613,6 +639,7 @@ "comment": "table_name predicate against a routed table", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", "Instructions": { @@ -634,6 +661,7 @@ "comment": "information_schema query with additional predicates", "query": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42", "Instructions": { @@ -654,6 +682,7 @@ "comment": "able to isolate table_schema value even when hidden inside of ORs", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')", "Instructions": { @@ -674,6 +703,7 @@ "comment": "expand star with information schema", "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", "Instructions": { @@ -693,6 +723,7 @@ "comment": "expand star with information schema in a derived table", "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id", "Instructions": { @@ -741,6 +772,7 @@ "comment": "join of information_schema queries with select stars exprs", "query": "select a.*, b.* from information_schema.GLOBAL_STATUS a, information_schema.CHARACTER_SETS b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select a.*, b.* from information_schema.GLOBAL_STATUS a, information_schema.CHARACTER_SETS b", "Instructions": { @@ -760,6 +792,7 @@ "comment": "join two routes with SysTableTableName entries in LHS and RHS", "query": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", "Instructions": { @@ -780,6 +813,7 @@ "comment": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "Instructions": { @@ -824,6 +858,7 @@ "comment": "union as a derived table", "query": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "Instructions": { @@ -861,6 +896,7 @@ "comment": "merge system schema queries as long as they have any same table_schema", "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "Instructions": { @@ -898,6 +934,7 @@ "comment": "merge system schema queries as long as they have any same table_name", "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "Instructions": { @@ -935,6 +972,7 @@ "comment": "merge union subquery with outer query referencing the same system schemas", "query": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", "Instructions": { @@ -1001,6 +1039,7 @@ "comment": "merge even one side have schema name in derived table", "query": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt", "Instructions": { @@ -1045,6 +1084,7 @@ "comment": "merge even one side have schema name in subquery", "query": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `TABLE_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `TABLE_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)", "Instructions": { @@ -1112,6 +1152,7 @@ "comment": "table_schema OR predicate\n# It is unsupported because we do not route queries to multiple keyspaces right now", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", "Instructions": { @@ -1131,6 +1172,7 @@ "comment": "Non-existing information_schema table is still OK", "query": "select TABLE_NAME from information_schema.apa", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select TABLE_NAME from information_schema.apa", "Instructions": { @@ -1150,6 +1192,7 @@ "comment": "LIMIT 1 inside derived table on the RHS should not be a problem", "query": "SELECT c.column_name FROM information_schema.columns c JOIN ( SELECT table_name FROM information_schema.tables WHERE table_schema != 'information_schema' LIMIT 1 ) AS tables ON tables.table_name = c.table_name", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT c.column_name FROM information_schema.columns c JOIN ( SELECT table_name FROM information_schema.tables WHERE table_schema != 'information_schema' LIMIT 1 ) AS tables ON tables.table_name = c.table_name", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/info_schema80_cases.json b/go/vt/vtgate/planbuilder/testdata/info_schema80_cases.json index 9553210174c..791ee22003e 100644 --- a/go/vt/vtgate/planbuilder/testdata/info_schema80_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/info_schema80_cases.json @@ -3,6 +3,7 @@ "comment": "Single information_schema query", "query": "select TABLE_NAME from information_schema.TABLES", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select TABLE_NAME from information_schema.TABLES", "Instructions": { @@ -22,6 +23,7 @@ "comment": "',' join information_schema", "query": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b", "Instructions": { @@ -41,6 +43,7 @@ "comment": "information schema query that uses table_schema", "query": "select column_name from information_schema.columns where table_schema = (select schema())", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select column_name from information_schema.columns where table_schema = (select schema())", "Instructions": { @@ -60,6 +63,7 @@ "comment": "information schema join", "query": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files", "Instructions": { @@ -79,6 +83,7 @@ "comment": "access to qualified column names in information_schema", "query": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'", "Instructions": { @@ -98,6 +103,7 @@ "comment": "union of information_schema", "query": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables", "Instructions": { @@ -141,6 +147,7 @@ "comment": "union between information_schema tables that should not be merged", "query": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", "Instructions": { @@ -206,6 +213,7 @@ "comment": "Select from information schema query with two tables that route should be merged", "query": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "Instructions": { @@ -227,6 +235,7 @@ "comment": "Select from information schema query with three tables such that route for 2 should be merged but not for the last.", "query": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", "Instructions": { @@ -248,6 +257,7 @@ "comment": "information_schema.routines", "query": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", "Instructions": { @@ -268,6 +278,7 @@ "comment": "information_schema table sizes", "query": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", "Instructions": { @@ -288,6 +299,7 @@ "comment": "information_schema referential contraints - cant merge without knowing values", "query": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", "Instructions": { @@ -331,6 +343,7 @@ "comment": "rails query", "query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", "Instructions": { @@ -351,6 +364,7 @@ "comment": "rails_query 2", "query": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", "Instructions": { @@ -371,6 +385,7 @@ "comment": "rails_query 3", "query": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", "Instructions": { @@ -392,6 +407,7 @@ "comment": "rails_query 4", "query": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", "Instructions": { @@ -413,6 +429,7 @@ "comment": "rails_query 5", "query": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT cc.constraint_name AS 'name', cc.check_clause AS 'expression' FROM information_schema.check_constraints cc JOIN information_schema.table_constraints tc USING (constraint_schema, constraint_name) WHERE tc.table_schema = 'table_schema' AND tc.table_name = 'table_name' AND cc.constraint_schema = 'constraint_schema'", "Instructions": { @@ -458,6 +475,7 @@ "comment": "rails_query 6", "query": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", "Instructions": { @@ -479,6 +497,7 @@ "comment": "rails_query 7", "query": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", "Instructions": { @@ -500,6 +519,7 @@ "comment": "rails_query 8", "query": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", "Instructions": { @@ -519,6 +539,7 @@ "comment": "rails_query 9", "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", "Instructions": { @@ -539,6 +560,7 @@ "comment": "rails_query 10", "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", "Instructions": { @@ -559,6 +581,7 @@ "comment": "two predicates specifying the database for the same table work if the database is the same", "query": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc WHERE cc.constraint_schema = 'a' AND cc.`CONSTRAINT_CATALOG` = 'a'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc WHERE cc.constraint_schema = 'a' AND cc.`CONSTRAINT_CATALOG` = 'a'", "Instructions": { @@ -579,6 +602,7 @@ "comment": "system schema in where clause of information_schema query", "query": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", "Instructions": { @@ -600,6 +624,7 @@ "comment": "subquery of information_schema with itself", "query": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)", "Instructions": { @@ -619,6 +644,7 @@ "comment": "query trying to query two different keyspaces at the same time", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", "Instructions": { @@ -639,6 +665,7 @@ "comment": "information_schema query using database() func", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", "Instructions": { @@ -658,6 +685,7 @@ "comment": "table_schema predicate the wrong way around", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", "Instructions": { @@ -678,6 +706,7 @@ "comment": "table_name predicate against a routed table", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", "Instructions": { @@ -699,6 +728,7 @@ "comment": "information_schema query with additional predicates", "query": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42", "Instructions": { @@ -719,6 +749,7 @@ "comment": "able to isolate table_schema value even when hidden inside of ORs", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')", "Instructions": { @@ -739,6 +770,7 @@ "comment": "expand star with information schema", "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", "Instructions": { @@ -758,6 +790,7 @@ "comment": "expand star with information schema in a derived table", "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id", "Instructions": { @@ -806,6 +839,7 @@ "comment": "join of information_schema queries with select stars exprs", "query": "select a.*, b.* from information_schema.CHECK_CONSTRAINTS a, information_schema.CHARACTER_SETS b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select a.*, b.* from information_schema.CHECK_CONSTRAINTS a, information_schema.CHARACTER_SETS b", "Instructions": { @@ -825,6 +859,7 @@ "comment": "join two routes with SysTableTableName entries in LHS and RHS", "query": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", "Instructions": { @@ -845,6 +880,7 @@ "comment": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "Instructions": { @@ -889,6 +925,7 @@ "comment": "union as a derived table", "query": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "Instructions": { @@ -926,6 +963,7 @@ "comment": "merge system schema queries as long as they have any same table_schema", "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "Instructions": { @@ -963,6 +1001,7 @@ "comment": "merge system schema queries as long as they have any same table_name", "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", "Instructions": { @@ -1000,6 +1039,7 @@ "comment": "merge union subquery with outer query referencing the same system schemas", "query": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", "Instructions": { @@ -1066,6 +1106,7 @@ "comment": "merge even one side have schema name in derived table", "query": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt", "Instructions": { @@ -1110,6 +1151,7 @@ "comment": "merge even one side have schema name in subquery", "query": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `TABLE_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `TABLE_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)", "Instructions": { @@ -1177,6 +1219,7 @@ "comment": "table_schema OR predicate\n# It is unsupported because we do not route queries to multiple keyspaces right now", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", "Instructions": { @@ -1196,6 +1239,7 @@ "comment": "select variable, value from sys.sys_config", "query": "select variable, value from sys.sys_config", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select variable, value from sys.sys_config", "Instructions": { @@ -1215,6 +1259,7 @@ "comment": "select host, db from mysql.`db`", "query": "select host, db from mysql.`db`", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select host, db from mysql.`db`", "Instructions": { @@ -1234,6 +1279,7 @@ "comment": "select logged, prio from performance_schema.error_log", "query": "select logged, prio from performance_schema.error_log", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select logged, prio from performance_schema.error_log", "Instructions": { @@ -1253,6 +1299,7 @@ "comment": "Non-existing information_schema table is still OK", "query": "select TABLE_NAME from information_schema.apa", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select TABLE_NAME from information_schema.apa", "Instructions": { @@ -1272,6 +1319,7 @@ "comment": "LIMIT 1 inside derived table on the RHS should not be a problem", "query": "SELECT c.column_name FROM information_schema.columns c JOIN ( SELECT table_name FROM information_schema.tables WHERE table_schema != 'information_schema' LIMIT 1 ) AS tables ON tables.table_name = c.table_name", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT c.column_name FROM information_schema.columns c JOIN ( SELECT table_name FROM information_schema.tables WHERE table_schema != 'information_schema' LIMIT 1 ) AS tables ON tables.table_name = c.table_name", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/large_cases.json b/go/vt/vtgate/planbuilder/testdata/large_cases.json index 43adc1f5343..c1d65a9af91 100644 --- a/go/vt/vtgate/planbuilder/testdata/large_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/large_cases.json @@ -3,6 +3,7 @@ "comment": "select user.id from user, user_extra, user_metadata, music, unsharded, unsharded_a, unsharded_b, unsharded_auto, music_extra where user.id = user_extra.user_id and user_metadata.user_id = user_extra.user_id and music.id = music_extra.music_id and unsharded.x = unsharded_a.y", "query": "select user.id from user, user_extra, user_metadata, music, unsharded, unsharded_a, unsharded_b, unsharded_auto, music_extra where user.id = user_extra.user_id and user_metadata.user_id = user_extra.user_id and music.id = music_extra.music_id and unsharded.x = unsharded_a.y", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.id from user, user_extra, user_metadata, music, unsharded, unsharded_a, unsharded_b, unsharded_auto, music_extra where user.id = user_extra.user_id and user_metadata.user_id = user_extra.user_id and music.id = music_extra.music_id and unsharded.x = unsharded_a.y", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/large_union_cases.json b/go/vt/vtgate/planbuilder/testdata/large_union_cases.json index ac39682be4c..5ae3554c3eb 100644 --- a/go/vt/vtgate/planbuilder/testdata/large_union_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/large_union_cases.json @@ -3,6 +3,7 @@ "comment": "this testcase breaks goland, so it lives on its own file", "query": "(SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270698330 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270699497 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270703806 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270707364 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270714657 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270721330 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270812079 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271011532 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271034164 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271034177 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271066849 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271098740 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271355000 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271639345 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271914117 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271924504 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272086055 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272127855 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272191137 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272468271 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270637436 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270644941 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270650576 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270652906 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270660650 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270670201 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270698330 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270699497 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270707364 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271799956 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271914117 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270637436 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271799956 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270637436 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271639345 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270644941 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270649256 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270653671 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270670201 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270717223 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270720898 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270982590 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271346411 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271352121 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271354908 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271367516 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271472522 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271607757 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271639345 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271821733 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271914117 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272068709 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272127855 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272191137 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272244005 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272468271 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270982590 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271607757 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270982590 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271607757 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272244005 ORDER BY created_at ASC, id ASC LIMIT 11)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270698330 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270699497 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270703806 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270707364 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270714657 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270721330 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270812079 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271011532 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271034164 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271034177 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271066849 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271098740 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271355000 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271639345 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271914117 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271924504 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272086055 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272127855 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272191137 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272468271 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270637436 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270644941 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270650576 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270652906 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270660650 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270670201 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270698330 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270699497 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270707364 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271799956 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271914117 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270637436 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271799956 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270637436 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271639345 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270644941 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270649256 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270653671 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270670201 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270717223 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270720898 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270982590 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271346411 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271352121 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271354908 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271367516 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271472522 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271607757 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271639345 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271821733 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271914117 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272068709 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272127855 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272191137 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272244005 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272468271 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270982590 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271607757 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1270982590 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271365691 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1271607757 ORDER BY created_at ASC, id ASC LIMIT 11) UNION (SELECT `content`, `user_id` FROM `music` WHERE `user_id` = 1272244005 ORDER BY created_at ASC, id ASC LIMIT 11)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/lock_cases.json b/go/vt/vtgate/planbuilder/testdata/lock_cases.json index 2490424a1ec..7e090fc1898 100644 --- a/go/vt/vtgate/planbuilder/testdata/lock_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/lock_cases.json @@ -3,6 +3,7 @@ "comment": "get_lock from dual", "query": "select get_lock('xyz', 10) from dual", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select get_lock('xyz', 10) from dual", "Instructions": { @@ -26,6 +27,7 @@ "comment": "is_free_lock from dual", "query": "select is_free_lock('xyz') from dual", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select is_free_lock('xyz') from dual", "Instructions": { @@ -49,6 +51,7 @@ "comment": "get_lock from dual prepare query", "query": "select get_lock(?, ?)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select get_lock(?, ?)", "Instructions": { @@ -72,6 +75,7 @@ "comment": "lock tables read", "query": "lock tables t as x read local", "plan": { + "Type": "Complex", "QueryType": "LOCK_TABLES", "Original": "lock tables t as x read local", "Instructions": { @@ -83,6 +87,7 @@ "comment": "lock tables write", "query": "lock tables t low_priority write", "plan": { + "Type": "Complex", "QueryType": "LOCK_TABLES", "Original": "lock tables t low_priority write", "Instructions": { @@ -94,6 +99,7 @@ "comment": "unlock tables", "query": "unlock tables", "plan": { + "Type": "Complex", "QueryType": "UNLOCK_TABLES", "Original": "unlock tables", "Instructions": { @@ -105,6 +111,7 @@ "comment": "multiple lock functions", "query": "select get_lock('xyz', 10), is_free_lock('abc') from dual", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select get_lock('xyz', 10), is_free_lock('abc') from dual", "Instructions": { @@ -129,6 +136,7 @@ "comment": "select nowait", "query": "select u.col, u.bar from user u join music m on u.foo = m.foo for update nowait", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.col, u.bar from user u join music m on u.foo = m.foo for update nowait", "Instructions": { @@ -174,6 +182,7 @@ "comment": "select skip locked", "query": "select u.col, u.bar from user u join music m on u.foo = m.foo for share skip locked", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.col, u.bar from user u join music m on u.foo = m.foo for share skip locked", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.json b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.json index a35949cd4c1..b63f456f4da 100644 --- a/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/memory_sort_cases.json @@ -3,6 +3,7 @@ "comment": "Test cases in this file follow the code in memory_sort.go.\n# scatter aggregate order by references ungrouped column", "query": "select a, b, count(*) from user group by a order by b", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) from user group by a order by b", "Instructions": { @@ -42,6 +43,7 @@ "comment": "scatter aggregate order by references aggregate expression", "query": "select a, b, count(*) k from user group by a order by k", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) k from user group by a order by k", "Instructions": { @@ -81,6 +83,7 @@ "comment": "select a, b, count(*) k from user group by a order by b, a, k", "query": "select a, b, count(*) k from user group by a order by b, a, k", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) k from user group by a order by b, a, k", "Instructions": { @@ -120,6 +123,7 @@ "comment": "scatter aggregate with memory sort and limit", "query": "select a, b, count(*) k from user group by a order by k desc limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) k from user group by a order by k desc limit 10", "Instructions": { @@ -165,6 +169,7 @@ "comment": "scatter aggregate with memory sort and order by number", "query": "select a, b, count(*) k from user group by a order by 1,3", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, b, count(*) k from user group by a order by 1,3", "Instructions": { @@ -204,6 +209,7 @@ "comment": "scatter aggregate with memory sort and order by number, reuse weight_string\n# we have to use a meaningless construct to test this", "query": "select textcol1 as t, count(*) k from user group by textcol1 order by textcol1, k, textcol1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select textcol1 as t, count(*) k from user group by textcol1 order by textcol1, k, textcol1", "Instructions": { @@ -242,6 +248,7 @@ "comment": "order by on a cross-shard derived table", "query": "select id from (select user.id, user.col from user join user_extra) as t order by id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select id from (select user.id, user.col from user join user_extra) as t order by id", "Instructions": { @@ -285,6 +292,7 @@ "comment": "order by on a cross-shard query. Note: this happens only when an order by column is from the second table", "query": "select user.col1 as a, user.col2 b, music.col3 c from user, music where user.id = music.id and user.id = 1 order by c", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.col1 as a, user.col2 b, music.col3 c from user, music where user.id = music.id and user.id = 1 order by c", "Instructions": { @@ -371,6 +379,7 @@ "comment": "Order by for join, with mixed cross-shard ordering", "query": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by 1 asc, 3 desc, 2 asc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by 1 asc, 3 desc, 2 asc", "Instructions": { @@ -457,6 +466,7 @@ "comment": "Order by for join, on text column in LHS.", "query": "select u.a, u.textcol1, un.col2 from user u join unsharded un order by u.textcol1, un.col2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.a, u.textcol1, un.col2 from user u join unsharded un order by u.textcol1, un.col2", "Instructions": { @@ -507,6 +517,7 @@ "comment": "Order by for join, on text column in RHS.", "query": "select u.a, u.textcol1, un.col2 from unsharded un join user u order by u.textcol1, un.col2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.a, u.textcol1, un.col2 from unsharded un join user u order by u.textcol1, un.col2", "Instructions": { @@ -557,6 +568,7 @@ "comment": "order by for vindex func", "query": "select id, keyspace_id, range_start, range_end from user_index where id = :id order by range_start", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, keyspace_id, range_start, range_end from user_index where id = :id order by range_start", "Instructions": { @@ -593,6 +605,7 @@ "comment": "unary expression", "query": "select a from user order by binary a desc", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select a from user order by binary a desc", "Instructions": { @@ -617,6 +630,7 @@ "comment": "unary expression in join query", "query": "select u.a from user u join music m on u.a = m.a order by binary a desc", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.a from user u join music m on u.a = m.a order by binary a desc", "Instructions": { @@ -663,6 +677,7 @@ "comment": "intcol order by", "query": "select id, intcol from user order by intcol", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, intcol from user order by intcol", "Instructions": { @@ -686,6 +701,7 @@ "comment": "scatter order by with order by column not present", "query": "select col from user order by id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from user order by id", "Instructions": { @@ -710,6 +726,7 @@ "comment": "Derived table split across two shards, and ordered by both", "query": "select * from (select u.foo, ue.bar from user u, user_extra ue) tbl order by tbl.bar, tbl.foo", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from (select u.foo, ue.bar from user u, user_extra ue) tbl order by tbl.bar, tbl.foo", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/migration_cases.json b/go/vt/vtgate/planbuilder/testdata/migration_cases.json index db77a3d4a41..acbdf63fa41 100644 --- a/go/vt/vtgate/planbuilder/testdata/migration_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/migration_cases.json @@ -3,6 +3,7 @@ "comment": "revert migration", "query": "revert vitess_migration 'abc'", "plan": { + "Type": "Complex", "QueryType": "REVERT", "Original": "revert vitess_migration 'abc'", "Instructions": { @@ -19,6 +20,7 @@ "comment": "retry migration", "query": "alter vitess_migration 'abc' retry", "plan": { + "Type": "Unknown", "QueryType": "UNKNOWN", "Original": "alter vitess_migration 'abc' retry", "Instructions": { @@ -36,6 +38,7 @@ "comment": "complete migration", "query": "alter vitess_migration 'abc' complete", "plan": { + "Type": "Unknown", "QueryType": "UNKNOWN", "Original": "alter vitess_migration 'abc' complete", "Instructions": { @@ -53,6 +56,7 @@ "comment": "complete migration", "query": "alter vitess_migration 'abc' cleanup", "plan": { + "Type": "Unknown", "QueryType": "UNKNOWN", "Original": "alter vitess_migration 'abc' cleanup", "Instructions": { @@ -70,6 +74,7 @@ "comment": "cancel migration", "query": "alter vitess_migration 'abc' cancel", "plan": { + "Type": "Unknown", "QueryType": "UNKNOWN", "Original": "alter vitess_migration 'abc' cancel", "Instructions": { @@ -87,6 +92,7 @@ "comment": "cancel all migrations", "query": "alter vitess_migration cancel all", "plan": { + "Type": "Unknown", "QueryType": "UNKNOWN", "Original": "alter vitess_migration cancel all", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/mirror_cases.json b/go/vt/vtgate/planbuilder/testdata/mirror_cases.json index 2466b3dca12..993d49d3515 100644 --- a/go/vt/vtgate/planbuilder/testdata/mirror_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/mirror_cases.json @@ -3,6 +3,7 @@ "comment": "select unsharded, qualified, table mirrored to unsharded table", "query": "select t1.id from unsharded_src1.t1 where t1.id = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select t1.id from unsharded_src1.t1 where t1.id = 1", "Instructions": { @@ -44,6 +45,7 @@ "comment": "select unsharded, qualified, table mirrored to unsharded table with zero percentage", "query": "select t3.id from unsharded_src1.t3 where t3.id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t3.id from unsharded_src1.t3 where t3.id = 1", "Instructions": { @@ -66,6 +68,7 @@ "comment": "select unsharded, qualified, table mirrored to sharded table", "query": "select t2.id from unsharded_src1.t2 where t2.id = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select t2.id from unsharded_src1.t2 where t2.id = 1", "Instructions": { @@ -111,6 +114,7 @@ "comment": "select two unsharded, qualified, tables, one mirrored to unsharded table, other to sharded table", "query": "select t1.id, t2.id from unsharded_src1.t1, unsharded_src1.t2 where t1.id = t2.id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select t1.id, t2.id from unsharded_src1.t1, unsharded_src1.t2 where t1.id = t2.id", "Instructions": { @@ -180,6 +184,7 @@ "comment": "union of selects from unsharded, qualified, tables, one mirrored to unsharded table, other to sharded table", "query": "select t1.id from unsharded_src1.t1 union select t2.id from unsharded_src1.t2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select t1.id from unsharded_src1.t1 union select t2.id from unsharded_src1.t2", "Instructions": { @@ -247,6 +252,7 @@ "comment": "inserts are not mirrored", "query": "insert into unsharded_src1.t1 (id) values(1)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into unsharded_src1.t1 (id) values(1)", "Instructions": { @@ -269,6 +275,7 @@ "comment": "updates are not mirrored", "query": "update unsharded_src1.t1 set data = 'a' where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update unsharded_src1.t1 set data = 'a' where id = 1", "Instructions": { @@ -291,6 +298,7 @@ "comment": "deletes are not mirrored", "query": "delete from unsharded_src1.t1 where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from unsharded_src1.t1 where id = 1", "Instructions": { @@ -313,6 +321,7 @@ "comment": "self-mirror is not allowed", "query": "select t1.id from unsharded_src2.t1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t1.id from unsharded_src2.t1", "Instructions": { @@ -335,6 +344,7 @@ "comment": "chained mirror is not allowed", "query": "select t2.id from unsharded_src2.t2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select t2.id from unsharded_src2.t2", "Instructions": { @@ -376,6 +386,7 @@ "comment": "circular mirror is not allowed", "query": "select t1.id from unsharded_src3.t1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t1.id from unsharded_src3.t1", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/misc_cases.json b/go/vt/vtgate/planbuilder/testdata/misc_cases.json index 399cebe8939..cdfe98e62bb 100644 --- a/go/vt/vtgate/planbuilder/testdata/misc_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/misc_cases.json @@ -3,6 +3,7 @@ "comment": "prepare statement with select", "query": "prepare prep from 'select * from user where id = ?'", "plan": { + "Type": "Complex", "QueryType": "PREPARE", "Original": "prepare prep from 'select * from user where id = ?'", "Instructions": { @@ -17,6 +18,7 @@ "comment": "prepare statement with delete", "query": "prepare prep from 'delete from user where id between ? and ?'", "plan": { + "Type": "Complex", "QueryType": "PREPARE", "Original": "prepare prep from 'delete from user where id between ? and ?'", "Instructions": { @@ -31,6 +33,7 @@ "comment": "prepare statement with drop", "query": "prepare prep from 'drop table user'", "plan": { + "Type": "Complex", "QueryType": "PREPARE", "Original": "prepare prep from 'drop table user'", "Instructions": { @@ -45,6 +48,7 @@ "comment": "prepare statement with user defined variable", "query": "prepare prep from @prep_stmt", "plan": { + "Type": "Complex", "QueryType": "PREPARE", "Original": "prepare prep from @prep_stmt", "Instructions": { @@ -69,6 +73,7 @@ "comment": "execute one param statement", "query": "execute prep_one_param using @foo", "plan": { + "Type": "Complex", "QueryType": "EXECUTE", "Original": "execute prep_one_param using @foo", "Instructions": { @@ -103,6 +108,7 @@ "comment": "execute in param statement", "query": "execute prep_in_param using @x, @y", "plan": { + "Type": "Complex", "QueryType": "EXECUTE", "Original": "execute prep_in_param using @x, @y", "Instructions": { @@ -138,6 +144,7 @@ "comment": "execute no param statement", "query": "execute prep_no_param", "plan": { + "Type": "Complex", "QueryType": "EXECUTE", "Original": "execute prep_no_param", "Instructions": { @@ -181,6 +188,7 @@ "comment": "prepare a dual query", "query": "prepare prep_dual from 'select 1+?, 10/?'", "plan": { + "Type": "Complex", "QueryType": "PREPARE", "Original": "prepare prep_dual from 'select 1+?, 10/?'", "Instructions": { @@ -195,6 +203,7 @@ "comment": "drop prepare", "query": "drop prepare prep_no_param", "plan": { + "Type": "Complex", "QueryType": "DEALLOCATE PREPARE", "Original": "drop prepare prep_no_param", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/oltp_cases.json b/go/vt/vtgate/planbuilder/testdata/oltp_cases.json index 45f1ac8c618..0f548311c48 100644 --- a/go/vt/vtgate/planbuilder/testdata/oltp_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/oltp_cases.json @@ -3,6 +3,7 @@ "comment": "OLTP simple select", "query": "SELECT c FROM sbtest34 WHERE id=15", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT c FROM sbtest34 WHERE id=15", "Instructions": { @@ -29,6 +30,7 @@ "comment": "OLTP simple range select", "query": "SELECT c FROM sbtest12 WHERE id BETWEEN 1 AND 10", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT c FROM sbtest12 WHERE id BETWEEN 1 AND 10", "Instructions": { @@ -51,6 +53,7 @@ "comment": "OLTP sum range select", "query": "SELECT SUM(k) FROM sbtest43 WHERE id BETWEEN 90 AND 990", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT SUM(k) FROM sbtest43 WHERE id BETWEEN 90 AND 990", "Instructions": { @@ -80,6 +83,7 @@ "comment": "OLTP order range select", "query": "SELECT c FROM sbtest1 WHERE id BETWEEN 50 AND 235 ORDER BY c", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT c FROM sbtest1 WHERE id BETWEEN 50 AND 235 ORDER BY c", "Instructions": { @@ -103,6 +107,7 @@ "comment": "OLTP distinct range select", "query": "SELECT DISTINCT c FROM sbtest30 WHERE id BETWEEN 1 AND 10 ORDER BY c", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT DISTINCT c FROM sbtest30 WHERE id BETWEEN 1 AND 10 ORDER BY c", "Instructions": { @@ -133,6 +138,7 @@ "comment": "OLTP index udpate", "query": "UPDATE sbtest6 SET k=k+1 WHERE id=5", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE sbtest6 SET k=k+1 WHERE id=5", "Instructions": { @@ -159,6 +165,7 @@ "comment": "OLTP non index update", "query": "UPDATE sbtest9 SET c=7 WHERE id=8", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE sbtest9 SET c=7 WHERE id=8", "Instructions": { @@ -185,6 +192,7 @@ "comment": "OLTP delete", "query": "DELETE FROM sbtest15 WHERE id=7525", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "DELETE FROM sbtest15 WHERE id=7525", "Instructions": { @@ -211,6 +219,7 @@ "comment": "OLTP insert", "query": "INSERT INTO sbtest16 (id, k, c, pad) VALUES (42, 1, 2, 50)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO sbtest16 (id, k, c, pad) VALUES (42, 1, 2, 50)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/other_admin_cases.json b/go/vt/vtgate/planbuilder/testdata/other_admin_cases.json index 2eb3432e1b7..fdde48c29ca 100644 --- a/go/vt/vtgate/planbuilder/testdata/other_admin_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/other_admin_cases.json @@ -3,6 +3,7 @@ "comment": "Repair statement", "query": "repair table t1,t2 quick", "plan": { + "Type": "Unknown", "QueryType": "OTHER", "Original": "repair table t1,t2 quick", "Instructions": { @@ -21,6 +22,7 @@ "comment": "Optimize statement", "query": "optimize table t1", "plan": { + "Type": "Unknown", "QueryType": "OTHER", "Original": "optimize table t1", "Instructions": { @@ -39,6 +41,7 @@ "comment": "DO statement", "query": "DO 1", "plan": { + "Type": "Unknown", "QueryType": "OTHER", "Original": "DO 1", "Instructions": { @@ -53,4 +56,4 @@ } } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/other_read_cases.json b/go/vt/vtgate/planbuilder/testdata/other_read_cases.json index 1a7c9ddac2a..4d31f983121 100644 --- a/go/vt/vtgate/planbuilder/testdata/other_read_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/other_read_cases.json @@ -3,6 +3,7 @@ "comment": "Explain statement", "query": "explain select * from user", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "explain select * from user", "Instructions": { @@ -24,6 +25,7 @@ "comment": "Analyze statement", "query": "analyze table main.t1", "plan": { + "Type": "Unknown", "QueryType": "ANALYZE", "Original": "analyze table main.t1", "Instructions": { @@ -44,6 +46,7 @@ "comment": "Describe statement", "query": "describe select * from user", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "describe select * from user", "Instructions": { @@ -65,6 +68,7 @@ "comment": "Desc statement", "query": "desc select * from user", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "desc select * from user", "Instructions": { @@ -86,6 +90,7 @@ "comment": "explain - routed table with same name", "query": "explain select 1, second_user.user.id from second_user.user", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "explain select 1, second_user.user.id from second_user.user", "Instructions": { @@ -107,6 +112,7 @@ "comment": "explain - routed table with different name", "query": "explain select 1, second_user.foo.id, foo.col from second_user.foo", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "explain select 1, second_user.foo.id, foo.col from second_user.foo", "Instructions": { @@ -128,6 +134,7 @@ "comment": "explain - routed table with join on different table on routed keyspace", "query": "explain select 1, second_user.foo.id, foo.col from second_user.foo join user.user join user.music", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "explain select 1, second_user.foo.id, foo.col from second_user.foo join user.user join user.music", "Instructions": { @@ -151,6 +158,7 @@ "comment": "describe info_schema table", "query": "describe information_schema.administrable_role_authorizations", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "describe information_schema.administrable_role_authorizations", "Instructions": { @@ -172,6 +180,7 @@ "comment": "describe table without qualifier", "query": "describe user", "plan": { + "Type": "Unknown", "QueryType": "EXPLAIN", "Original": "describe user", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.json b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.json index 6a8e94c0241..711b2e80aa0 100644 --- a/go/vt/vtgate/planbuilder/testdata/postprocess_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/postprocess_cases.json @@ -3,6 +3,7 @@ "comment": "HAVING implicitly references table col", "query": "select user.col1 from user having col2 = 2", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col1 from user having col2 = 2", "Instructions": { @@ -30,6 +31,7 @@ "comment": "TODO: this should be 'Column 'col1' in having clause is ambiguous'\n# non-ambiguous symbol reference", "query": "select user.col1, user_extra.col1 from user join user_extra having user_extra.col1 = 2", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col1, user_extra.col1 from user join user_extra having user_extra.col1 = 2", "Instructions": { @@ -72,6 +74,7 @@ "comment": "HAVING multi-route", "query": "select user.col1 as a, user.col2, user_extra.col3 from user join user_extra having 1 = 1 and a = 1 and a = user.col2 and user_extra.col3 = 1", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col1 as a, user.col2, user_extra.col3 from user join user_extra having 1 = 1 and a = 1 and a = user.col2 and user_extra.col3 = 1", "Instructions": { @@ -114,6 +117,7 @@ "comment": "HAVING uses subquery", "query": "select id from user having id in (select col from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user having id in (select col from user)", "Instructions": { @@ -163,6 +167,7 @@ "comment": "ORDER BY, reference col from local table.", "query": "select col from user where id = 5 order by aa", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from user where id = 5 order by aa", "Instructions": { @@ -189,6 +194,7 @@ "comment": "ORDER BY uses column numbers", "query": "select col from user where id = 1 order by 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from user where id = 1 order by 1", "Instructions": { @@ -215,6 +221,7 @@ "comment": "ORDER BY on scatter", "query": "select col from user order by col", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from user order by col", "Instructions": { @@ -238,6 +245,7 @@ "comment": "ORDER BY works for select * from authoritative table", "query": "select * from authoritative order by user_id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from authoritative order by user_id", "Instructions": { @@ -262,6 +270,7 @@ "comment": "Test that LIMIT can be pushed to the route even in the presence of an outer join", "query": "SELECT user_extra.`id` FROM user LEFT JOIN user_extra ON user_extra.`b` = 2 AND user.`c` = user_extra.`c` WHERE user.`a` = 1 LIMIT 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT user_extra.`id` FROM user LEFT JOIN user_extra ON user_extra.`b` = 2 AND user.`c` = user_extra.`c` WHERE user.`a` = 1 LIMIT 1", "Instructions": { @@ -325,6 +334,7 @@ "comment": "ORDER BY works for select * from authoritative table", "query": "select * from authoritative order by col1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from authoritative order by col1", "Instructions": { @@ -348,6 +358,7 @@ "comment": "ORDER BY on scatter with text column", "query": "select a, textcol1, b from user order by a, textcol1, b", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select a, textcol1, b from user order by a, textcol1, b", "Instructions": { @@ -372,6 +383,7 @@ "comment": "ORDER BY on scatter with text column, qualified name TODO: can plan better", "query": "select a, user.textcol1, b from user order by a, textcol1, b", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select a, user.textcol1, b from user order by a, textcol1, b", "Instructions": { @@ -396,6 +408,7 @@ "comment": "ORDER BY on scatter with multiple text columns", "query": "select a, textcol1, b, textcol2 from user order by a, textcol1, b, textcol2", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select a, textcol1, b, textcol2 from user order by a, textcol1, b, textcol2", "Instructions": { @@ -425,6 +438,7 @@ "comment": "ORDER BY column offset", "query": "select id as foo from music order by 1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id as foo from music order by 1", "Instructions": { @@ -449,6 +463,7 @@ "comment": "ORDER BY NULL", "query": "select col from user order by null", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from user order by null", "Instructions": { @@ -471,6 +486,7 @@ "comment": "ORDER BY after pull-out subquery", "query": "select col from user where col in (select col2 from user) order by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user where col in (select col2 from user) order by col", "Instructions": { @@ -517,6 +533,7 @@ "comment": "ORDER BY NULL for join", "query": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by null", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by null", "Instructions": { @@ -595,6 +612,7 @@ "comment": "ORDER BY non-key column for join", "query": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by a", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by a", "Instructions": { @@ -673,6 +691,7 @@ "comment": "ORDER BY non-key column for implicit join", "query": "select user.col1 as a, user.col2, music.col3 from user, music where user.id = music.id and user.id = 1 order by a", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col1 as a, user.col2, music.col3 from user, music where user.id = music.id and user.id = 1 order by a", "Instructions": { @@ -751,6 +770,7 @@ "comment": "ORDER BY NULL after pull-out subquery", "query": "select col from user where col in (select col2 from user) order by null", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user where col in (select col2 from user) order by null", "Instructions": { @@ -796,6 +816,7 @@ "comment": "ORDER BY RAND()", "query": "select col from user order by RAND()", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col from user order by RAND()", "Instructions": { @@ -818,6 +839,7 @@ "comment": "ORDER BY RAND() for join", "query": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by RAND()", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col1 as a, user.col2, music.col3 from user join music on user.id = music.id where user.id = 1 order by RAND()", "Instructions": { @@ -896,6 +918,7 @@ "comment": "ORDER BY RAND() after pull-out subquery", "query": "select col from user where col in (select col2 from user) order by rand()", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user where col in (select col2 from user) order by rand()", "Instructions": { @@ -941,6 +964,7 @@ "comment": "Order by, '*' expression", "query": "select * from user where id = 5 order by col", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 5 order by col", "Instructions": { @@ -967,6 +991,7 @@ "comment": "Order by, qualified '*' expression", "query": "select user.* from user where id = 5 order by user.col", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user.* from user where id = 5 order by user.col", "Instructions": { @@ -993,6 +1018,7 @@ "comment": "Order by, '*' expression with qualified reference", "query": "select * from user where id = 5 order by user.col", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 5 order by user.col", "Instructions": { @@ -1019,6 +1045,7 @@ "comment": "Order by, '*' expression in a subquery", "query": "select u.id, e.id from user u join user_extra e where u.col = e.col and u.col in (select * from user where user.id = u.id order by col)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.id, e.id from user u join user_extra e where u.col = e.col and u.col in (select * from user where user.id = u.id order by col)", "Instructions": { @@ -1064,6 +1091,7 @@ "comment": "Order by, verify outer symtab is searched according to its own context.", "query": "select u.id from user u having u.id in (select col2 from user where user.id = u.id order by u.col)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select u.id from user u having u.id in (select col2 from user where user.id = u.id order by u.col)", "Instructions": { @@ -1101,6 +1129,7 @@ "comment": "Order by, '*' expression with qualified reference and using collate", "query": "select * from user where id = 5 order by user.col collate utf8_general_ci", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 5 order by user.col collate utf8_general_ci", "Instructions": { @@ -1127,6 +1156,7 @@ "comment": "Order by with math functions", "query": "select * from user where id = 5 order by -col1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 5 order by -col1", "Instructions": { @@ -1153,6 +1183,7 @@ "comment": "Order by with string operations", "query": "select * from user where id = 5 order by concat(col,col1) collate utf8_general_ci desc", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 5 order by concat(col,col1) collate utf8_general_ci desc", "Instructions": { @@ -1179,6 +1210,7 @@ "comment": "Order by with math operations", "query": "select * from user where id = 5 order by id+col collate utf8_general_ci desc", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 5 order by id+col collate utf8_general_ci desc", "Instructions": { @@ -1205,6 +1237,7 @@ "comment": "Order by derived table column", "query": "select * from user u join (select user_id from user_extra where user_id = 5) eu on u.id = eu.user_id where u.id = 5 order by eu.user_id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user u join (select user_id from user_extra where user_id = 5) eu on u.id = eu.user_id where u.id = 5 order by eu.user_id", "Instructions": { @@ -1232,6 +1265,7 @@ "comment": "routing rules: order by gets pushed for routes", "query": "select col from route1 where id = 1 order by col", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from route1 where id = 1 order by col", "Instructions": { @@ -1258,6 +1292,7 @@ "comment": "LIMIT", "query": "select col1 from user where id = 1 limit 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col1 from user where id = 1 limit 1", "Instructions": { @@ -1284,6 +1319,7 @@ "comment": "limit for joins. Can't push down the limit because result\n# counts get multiplied by join operations.", "query": "select user.col from user join user_extra limit 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user.col from user join user_extra limit 1", "Instructions": { @@ -1338,6 +1374,7 @@ "comment": "limit for scatter", "query": "select col from user limit 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user limit 1", "Instructions": { @@ -1366,6 +1403,7 @@ "comment": "limit for scatter with bind var", "query": "select col from user limit :a", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user limit :a", "Instructions": { @@ -1394,6 +1432,7 @@ "comment": "cross-shard expression in parenthesis with limit", "query": "select * from user where (id1 = 4 AND name1 ='abc') limit 5", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from user where (id1 = 4 AND name1 ='abc') limit 5", "Instructions": { @@ -1422,6 +1461,7 @@ "comment": "scatter limit after pullout subquery", "query": "select col from user where col in (select col1 from user) limit 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user where col in (select col1 from user) limit 1", "Instructions": { @@ -1473,6 +1513,7 @@ "comment": "limit on reference table", "query": "select col from ref limit 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col from ref limit 1", "Instructions": { @@ -1495,6 +1536,7 @@ "comment": "arithmetic limit", "query": "select id from user limit 1+1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user limit 1+1", "Instructions": { @@ -1523,6 +1565,7 @@ "comment": "order by column alias", "query": "select id as foo from music order by foo", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id as foo from music order by foo", "Instructions": { @@ -1547,6 +1590,7 @@ "comment": "column alias for a table column in order by", "query": "select id as foo, id2 as id from music order by id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id as foo, id2 as id from music order by id", "Instructions": { @@ -1571,6 +1615,7 @@ "comment": "ordering on the left side of the join", "query": "select name from user, music order by name", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select name from user, music order by name", "Instructions": { @@ -1614,6 +1659,7 @@ "comment": "aggregation and non-aggregations column without group by", "query": "select count(id), num from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(id), num from user", "Instructions": { @@ -1643,6 +1689,7 @@ "comment": "aggregation and non-aggregations column with order by", "query": "select count(id), num from user order by 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(id), num from user order by 2", "Instructions": { @@ -1680,6 +1727,7 @@ "comment": "aggregation and non-aggregations column with group by", "query": "select count(id), num from user group by 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(id), num from user group by 2", "Instructions": { @@ -1712,6 +1760,7 @@ "comment": "aggregation and non-aggregations column with group by and order by", "query": "select count(id), num from user group by 2 order by 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(id), num from user group by 2 order by 1", "Instructions": { @@ -1751,6 +1800,7 @@ "comment": "join order by with ambiguous column reference ; valid in MySQL", "query": "select name, name from user, music order by name", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select name, name from user, music order by name", "Instructions": { @@ -1794,6 +1844,7 @@ "comment": "order by with ambiguous column reference ; valid in MySQL", "query": "select id, id from user order by id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id, id from user order by id", "Instructions": { @@ -1818,6 +1869,7 @@ "comment": "Scatter order by and aggregation: order by column must reference column from select list", "query": "select col, count(*) from user group by col order by c1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col, count(*) from user group by col order by c1", "Instructions": { @@ -1857,6 +1909,7 @@ "comment": "Distinct with cross shard query", "query": "select distinct user.a from user join user_extra", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct user.a from user join user_extra", "Instructions": { @@ -1908,6 +1961,7 @@ "comment": "Distinct with column alias", "query": "select distinct a as c, a from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct a as c, a from user", "Instructions": { @@ -1940,6 +1994,7 @@ "comment": "Distinct with same column", "query": "select distinct a, a from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct a, a from user", "Instructions": { @@ -1972,6 +2027,7 @@ "comment": "Order by has subqueries", "query": "select id from unsharded order by (select id from unsharded)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from unsharded order by (select id from unsharded)", "Instructions": { @@ -1994,6 +2050,7 @@ "comment": "Equal filter with hexadecimal value", "query": "select count(*) a from user having a = 0x01", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) a from user having a = 0x01", "Instructions": { @@ -2029,6 +2086,7 @@ "comment": "Order by uses cross-shard expression", "query": "select id from user order by id+1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user order by id+1", "Instructions": { @@ -2053,6 +2111,7 @@ "comment": "Order by column number with collate", "query": "select user.col1 as a from user order by 1 collate utf8_general_ci", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col1 as a from user order by 1 collate utf8_general_ci", "Instructions": { @@ -2077,6 +2136,7 @@ "comment": "Order by uses cross-shard expression", "query": "select id from user order by id+1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user order by id+1", "Instructions": { @@ -2101,6 +2161,7 @@ "comment": "Order by column number with collate", "query": "select user.col1 as a from user order by 1 collate utf8_general_ci", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col1 as a from user order by 1 collate utf8_general_ci", "Instructions": { @@ -2125,6 +2186,7 @@ "comment": "Order by column number with coalesce with columns from both sides", "query": "select id from user, user_extra order by coalesce(user.col, user_extra.col)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user, user_extra order by coalesce(user.col, user_extra.col)", "Instructions": { @@ -2178,6 +2240,7 @@ "comment": "having filter with %", "query": "select a.tcol1 from user a join music b where a.tcol1 = b.tcol2 group by a.tcol1 having repeat(a.tcol1,min(a.id)) like \"A\\%B\" order by a.tcol1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a.tcol1 from user a join music b where a.tcol1 = b.tcol2 group by a.tcol1 having repeat(a.tcol1,min(a.id)) like \"A\\%B\" order by a.tcol1", "Instructions": { @@ -2239,6 +2302,7 @@ "comment": "distinct with order by using aggregation engine", "query": "select distinct col from user where id between :vtg1 and :vtg2 order by col asc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct col from user where id between :vtg1 and :vtg2 order by col asc", "Instructions": { @@ -2269,6 +2333,7 @@ "comment": "distinct with order by having additional non-order by columns in the selection using aggregation engine", "query": "select distinct foo, col from user where id between :vtg1 and :vtg2 order by col asc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct foo, col from user where id between :vtg1 and :vtg2 order by col asc", "Instructions": { @@ -2300,6 +2365,7 @@ "comment": "distinct with order by having no overalap with the selection columns - using distinct engine", "query": "select distinct foo from user where id between :vtg1 and :vtg2 order by col asc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct foo from user where id between :vtg1 and :vtg2 order by col asc", "Instructions": { @@ -2339,6 +2405,7 @@ "comment": "DISTINCT on an unsupported collation should fall back on weightstrings", "query": "select distinct textcol2 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select distinct textcol2 from user", "Instructions": { @@ -2370,6 +2437,7 @@ "comment": "No weightstrings or derived table needed", "query": "select textcol1 from user union select textcol1 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select textcol1 from user union select textcol1 from user", "Instructions": { @@ -2400,6 +2468,7 @@ "comment": "ORDER BY literal works fine even when the columns have the same name", "query": "select a.id, b.id from user as a, user_extra as b union all select 1, 2 order by 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a.id, b.id from user as a, user_extra as b union all select 1, 2 order by 1", "Instructions": { @@ -2467,6 +2536,7 @@ "comment": "ORDER BY literal works fine even when the columns have the same name", "query": "select a.id, b.id from user as a, user_extra as b union all select 1, 2 order by 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a.id, b.id from user as a, user_extra as b union all select 1, 2 order by 2", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/rails_cases.json b/go/vt/vtgate/planbuilder/testdata/rails_cases.json index 3887547e628..ea2279da284 100644 --- a/go/vt/vtgate/planbuilder/testdata/rails_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/rails_cases.json @@ -3,6 +3,7 @@ "comment": "Author5.joins(books: [{orders: :customer}, :supplier])", "query": "select author5s.* from author5s join book6s on book6s.author5_id = author5s.id join book6s_order2s on book6s_order2s.book6_id = book6s.id join order2s on order2s.id = book6s_order2s.order2_id join customer2s on customer2s.id = order2s.customer2_id join supplier5s on supplier5s.id = book6s.supplier5_id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select author5s.* from author5s join book6s on book6s.author5_id = author5s.id join book6s_order2s on book6s_order2s.book6_id = book6s.id join order2s on order2s.id = book6s_order2s.order2_id join customer2s on customer2s.id = order2s.customer2_id join supplier5s on supplier5s.id = book6s.supplier5_id", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/reference_cases.json b/go/vt/vtgate/planbuilder/testdata/reference_cases.json index 1bf893beeef..4f2d946279e 100644 --- a/go/vt/vtgate/planbuilder/testdata/reference_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/reference_cases.json @@ -2,8 +2,8 @@ { "comment": "select from unqualified ambiguous reference routes to reference source", "query": "select * from ambiguous_ref_with_source", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from ambiguous_ref_with_source", "Instructions": { @@ -20,13 +20,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "join with unqualified ambiguous reference table routes to optimal keyspace", "query": "select user.col from user join ambiguous_ref_with_source", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join ambiguous_ref_with_source", "Instructions": { @@ -44,13 +45,14 @@ "user.ambiguous_ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "ambiguous unqualified reference table self-join routes to reference source", "query": "select r1.col from ambiguous_ref_with_source r1 join ambiguous_ref_with_source", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select r1.col from ambiguous_ref_with_source r1 join ambiguous_ref_with_source", "Instructions": { @@ -67,13 +69,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "ambiguous unqualified reference table can merge with other opcodes left to right.", "query": "select ambiguous_ref_with_source.col from ambiguous_ref_with_source join user", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select ambiguous_ref_with_source.col from ambiguous_ref_with_source join user", "Instructions": { @@ -91,13 +94,14 @@ "user.ambiguous_ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "ambiguous unqualified reference table can merge with other opcodes left to right and vindex value is in the plan", "query": "select ambiguous_ref_with_source.col from ambiguous_ref_with_source join (select aa from user where user.id=1) user", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select ambiguous_ref_with_source.col from ambiguous_ref_with_source join (select aa from user where user.id=1) user", "Instructions": { @@ -119,13 +123,14 @@ "user.ambiguous_ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "qualified join to reference table routes to optimal keyspace", "query": "select user.col from user join main.ambiguous_ref_with_source", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join main.ambiguous_ref_with_source", "Instructions": { @@ -143,13 +148,14 @@ "user.ambiguous_ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "insert into ambiguous unqualified reference table routes to source", "query": "insert into ambiguous_ref_with_source(col) values(1)", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into ambiguous_ref_with_source(col) values(1)", "Instructions": { @@ -166,13 +172,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "Reference tables using left join with a derived table having a limit clause", "query": "SELECT u.id FROM ( SELECT a.id, a.u_id FROM user.ref_with_source AS a WHERE a.id IN (3) ORDER BY a.d_at LIMIT 1) as u LEFT JOIN user.ref_with_source AS u0 ON u.u_id = u0.u_uid ORDER BY u.id", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT u.id FROM ( SELECT a.id, a.u_id FROM user.ref_with_source AS a WHERE a.id IN (3) ORDER BY a.d_at LIMIT 1) as u LEFT JOIN user.ref_with_source AS u0 ON u.u_id = u0.u_uid ORDER BY u.id", "Instructions": { @@ -211,13 +218,14 @@ "TablesUsed": [ "user.ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "insert into qualified ambiguous reference table routes to source", "query": "insert into user.ambiguous_ref_with_source(col) values(1)", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user.ambiguous_ref_with_source(col) values(1)", "Instructions": { @@ -234,13 +242,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "update unqualified ambiguous reference table routes to source", "query": "update ambiguous_ref_with_source set col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update ambiguous_ref_with_source set col = 1", "Instructions": { @@ -257,13 +266,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "update qualified ambiguous reference table route to source", "query": "update user.ambiguous_ref_with_source set col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user.ambiguous_ref_with_source set col = 1", "Instructions": { @@ -280,13 +290,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "delete from unqualified ambiguous reference table routes to source", "query": "delete from ambiguous_ref_with_source where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from ambiguous_ref_with_source where col = 1", "Instructions": { @@ -303,13 +314,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "delete from qualified ambiguous reference table route to source", "query": "delete from user.ambiguous_ref_with_source where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from user.ambiguous_ref_with_source where col = 1", "Instructions": { @@ -326,13 +338,14 @@ "TablesUsed": [ "main.ambiguous_ref_with_source" ] - } + }, + "skip_e2e": true }, { "comment": "join with unqualified unambiguous ref with source routes to requested table", "query": "select user.col from user join ref_with_source", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join ref_with_source", "Instructions": { @@ -350,13 +363,14 @@ "user.ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "join with unqualified reference optimize routes when source & reference have different names", "query": "select user.col from user join source_of_ref", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join source_of_ref", "Instructions": { @@ -374,13 +388,14 @@ "user.ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "join with unqualified reference respects routing rules", "query": "select user.col from user join rerouted_ref", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join rerouted_ref", "Instructions": { @@ -398,13 +413,14 @@ "user.ref", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "join with reference to unqualified source routes to optimal keyspace", "query": "select user.col from user join global_ref", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.col from user join global_ref", "Instructions": { @@ -422,13 +438,14 @@ "user.global_ref", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "insert into qualified reference with unqualified source routes to source", "query": "insert into user.global_ref(col) values(1)", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user.global_ref(col) values(1)", "Instructions": { @@ -445,13 +462,14 @@ "TablesUsed": [ "main.global_ref" ] - } + }, + "skip_e2e": true }, { "comment": "delete from reference table with another name - query send to source table", "query": "delete from user.ref_with_source where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from user.ref_with_source where col = 1", "Instructions": { @@ -468,13 +486,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "update from reference table with another name - query send to source table", "query": "update user.ref_with_source set x = 4 where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user.ref_with_source set x = 4 where col = 1", "Instructions": { @@ -491,13 +510,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "insert from reference table with another name - query send to source table", "query": "insert into user.ref_with_source(x) values(4)", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user.ref_with_source(x) values(4)", "Instructions": { @@ -514,13 +534,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "delete from reference table - query send to source table", "query": "delete from source_of_ref where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from source_of_ref where col = 1", "Instructions": { @@ -537,13 +558,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "update from reference table - query send to source table", "query": "update source_of_ref set x = 4 where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update source_of_ref set x = 4 where col = 1", "Instructions": { @@ -560,13 +582,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "insert from reference table - query send to source table", "query": "insert into source_of_ref(x) values(4)", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into source_of_ref(x) values(4)", "Instructions": { @@ -583,13 +606,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "delete from reference table qualified with unsharded - query send to source table", "query": "delete from main.source_of_ref where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from main.source_of_ref where col = 1", "Instructions": { @@ -606,13 +630,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "update from reference table qualified with unsharded - query send to source table", "query": "update main.source_of_ref set x = 4 where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update main.source_of_ref set x = 4 where col = 1", "Instructions": { @@ -629,13 +654,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "insert from reference table qualified with unsharded - query send to source table", "query": "insert into main.source_of_ref(x) values(4)", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into main.source_of_ref(x) values(4)", "Instructions": { @@ -652,13 +678,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "delete from reference table with another name - query send to source table", "query": "delete from user.ref_with_source where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "delete from user.ref_with_source where col = 1", "Instructions": { @@ -675,13 +702,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "update from reference table with another name - query send to source table", "query": "update user.ref_with_source set x = 4 where col = 1", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "update user.ref_with_source set x = 4 where col = 1", "Instructions": { @@ -698,13 +726,14 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "insert from reference table with another name - query send to source table", "query": "insert into user.ref_with_source(x) values(4)", - "skip_e2e": true, "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "insert into user.ref_with_source(x) values(4)", "Instructions": { @@ -721,69 +750,72 @@ "TablesUsed": [ "main.source_of_ref" ] - } + }, + "skip_e2e": true }, { "comment": "select with join to reference table in sharded keyspace: should route shard-scoped", "query": "select * from user.ref_with_source ref, `user`.`user` u where ref.id = u.ref_id and u.id = 2", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user.ref_with_source ref, `user`.`user` u where ref.id = u.ref_id and u.id = 2", "Instructions": { - "FieldQuery": "select * from ref_with_source as ref, `user` as u where 1 != 1", "OperatorType": "Route", "Variant": "EqualUnique", - "Vindex": "user_index", "Keyspace": { "Name": "user", "Sharded": true }, + "FieldQuery": "select * from ref_with_source as ref, `user` as u where 1 != 1", "Query": "select * from ref_with_source as ref, `user` as u where u.id = 2 and ref.id = u.ref_id", "Table": "`user`, ref_with_source", "Values": [ "2" - ] + ], + "Vindex": "user_index" }, "TablesUsed": [ "user.ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "select with join to reference table in unsharded keyspace: should route shard-scoped", "query": "select * from source_of_ref ref, `user`.`user` u where ref.id = u.ref_id and u.id = 2", - "skip_e2e": true, "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from source_of_ref ref, `user`.`user` u where ref.id = u.ref_id and u.id = 2", "Instructions": { - "FieldQuery": "select * from ref_with_source as ref, `user` as u where 1 != 1", "OperatorType": "Route", "Variant": "EqualUnique", - "Vindex": "user_index", "Keyspace": { "Name": "user", "Sharded": true }, + "FieldQuery": "select * from ref_with_source as ref, `user` as u where 1 != 1", "Query": "select * from ref_with_source as ref, `user` as u where u.id = 2 and ref.id = u.ref_id", "Table": "`user`, ref_with_source", "Values": [ "2" - ] + ], + "Vindex": "user_index" }, "TablesUsed": [ "user.ref_with_source", "user.user" ] - } + }, + "skip_e2e": true }, { "comment": "two sharded and two unsharded reference table join - all should be merged into one route", "query": "select 1 from user u join user_extra ue on u.id = ue.user_id join main.source_of_ref sr on sr.foo = ue.foo join main.rerouted_ref rr on rr.bar = sr.bar", - "skip_e2e": true, "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select 1 from user u join user_extra ue on u.id = ue.user_id join main.source_of_ref sr on sr.foo = ue.foo join main.rerouted_ref rr on rr.bar = sr.bar", "Instructions": { @@ -803,12 +835,14 @@ "user.user", "user.user_extra" ] - } + }, + "skip_e2e": true }, { "comment": "update reference table with join on sharded table", "query": "update main.source_of_ref as sr join main.rerouted_ref as rr on sr.id = rr.id inner join user.music as m on sr.col = m.col set sr.tt = 5 where m.user_id = 1", "plan": { + "Type": "Complex", "QueryType": "UPDATE", "Original": "update main.source_of_ref as sr join main.rerouted_ref as rr on sr.id = rr.id inner join user.music as m on sr.col = m.col set sr.tt = 5 where m.user_id = 1", "Instructions": { @@ -879,6 +913,7 @@ "comment": "delete from reference table with join on sharded table", "query": "delete sr from main.source_of_ref as sr join main.rerouted_ref as rr on sr.id = rr.id inner join user.music as m on sr.col = m.col where m.user_id = 1", "plan": { + "Type": "Complex", "QueryType": "DELETE", "Original": "delete sr from main.source_of_ref as sr join main.rerouted_ref as rr on sr.id = rr.id inner join user.music as m on sr.col = m.col where m.user_id = 1", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.json b/go/vt/vtgate/planbuilder/testdata/select_cases.json index e18fa274d7e..2f38f82be86 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.json @@ -3,6 +3,7 @@ "comment": "No column referenced", "query": "select 1 from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select 1 from user", "Instructions": { @@ -25,6 +26,7 @@ "comment": "'*' expression for simple route", "query": "select user.* from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.* from user", "Instructions": { @@ -47,6 +49,7 @@ "comment": "unqualified '*' expression for simple route", "query": "select * from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from user", "Instructions": { @@ -69,6 +72,7 @@ "comment": "join on sharding column with limit - should be a simple scatter query and limit on top with non resolved columns", "query": "select * from user u join user_metadata um on u.id = um.user_id where foo=41 limit 20", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from user u join user_metadata um on u.id = um.user_id where foo=41 limit 20", "Instructions": { @@ -99,6 +103,7 @@ "comment": "select with timeout directive sets QueryTimeout in the route", "query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user", "Instructions": { @@ -122,6 +127,7 @@ "comment": "select aggregation with timeout directive sets QueryTimeout in the route", "query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ count(*) from user", "Instructions": { @@ -152,6 +158,7 @@ "comment": "select limit with timeout directive sets QueryTimeout in the route", "query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from user limit 10", "Instructions": { @@ -181,6 +188,7 @@ "comment": "select limit with timeout directive sets QueryTimeout in the route", "query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from main.unsharded limit 10", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from main.unsharded limit 10", "Instructions": { @@ -205,6 +213,7 @@ "comment": "select with partial scatter directive", "query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS */ * from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS */ * from user", "Instructions": { @@ -228,6 +237,7 @@ "comment": "select aggregation with partial scatter directive", "query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Instructions": { @@ -258,6 +268,7 @@ "comment": "select aggregation with partial scatter directive - added comments to try to confuse the hint extraction", "query": "/*VT_SPAN_CONTEXT=123*/select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "/*VT_SPAN_CONTEXT=123*/select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ count(*) from user", "Instructions": { @@ -288,6 +299,7 @@ "comment": "select limit with partial scatter directive", "query": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select /*vt+ SCATTER_ERRORS_AS_WARNINGS=1 */ * from user limit 10", "Instructions": { @@ -317,6 +329,7 @@ "comment": "qualified '*' expression for simple route", "query": "select user.* from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.* from user", "Instructions": { @@ -339,6 +352,7 @@ "comment": "fully qualified '*' expression for simple route", "query": "select user.user.* from user.user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.user.* from user.user", "Instructions": { @@ -361,6 +375,7 @@ "comment": "select * from authoritative table", "query": "select * from authoritative", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from authoritative", "Instructions": { @@ -383,6 +398,7 @@ "comment": "select * from join of authoritative tables", "query": "select * from authoritative a join authoritative b on a.user_id=b.user_id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from authoritative a join authoritative b on a.user_id=b.user_id", "Instructions": { @@ -411,6 +427,7 @@ "comment": "select * from qualified authoritative table", "query": "select a.* from authoritative a", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select a.* from authoritative a", "Instructions": { @@ -433,6 +450,7 @@ "comment": "select * from intermixing of authoritative table with non-authoritative results in no expansion", "query": "select * from authoritative join user on authoritative.user_id=user.id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from authoritative join user on authoritative.user_id=user.id", "Instructions": { @@ -456,6 +474,7 @@ "comment": "select authoritative.* with intermixing still expands", "query": "select user.id, a.*, user.col1 from authoritative a join user on a.user_id=user.id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.id, a.*, user.col1 from authoritative a join user on a.user_id=user.id", "Instructions": { @@ -480,6 +499,7 @@ "comment": "auto-resolve anonymous columns for simple route", "query": "select anon_col from user join user_extra on user.id = user_extra.user_id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select anon_col from user join user_extra on user.id = user_extra.user_id", "Instructions": { @@ -504,6 +524,7 @@ "comment": "json_arrayagg in single sharded query", "query": "select count(1) from user where id = 'abc' group by n_id having json_arrayagg(a_id) = '[]'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select count(1) from user where id = 'abc' group by n_id having json_arrayagg(a_id) = '[]'", "Instructions": { @@ -531,6 +552,7 @@ "comment": "json_objectagg in single sharded query", "query": "select count(1) from user where id = 'abc' group by n_id having json_objectagg(a_id, b_id) = '[]'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select count(1) from user where id = 'abc' group by n_id having json_objectagg(a_id, b_id) = '[]'", "Instructions": { @@ -570,6 +592,7 @@ "comment": "Auto-resolve should work if unique vindex columns are referenced", "query": "select id, user_id from user join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select id, user_id from user join user_extra", "Instructions": { @@ -613,6 +636,7 @@ "comment": "database calls should be substituted", "query": "select database() from dual", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select database() from dual", "Instructions": { @@ -636,6 +660,7 @@ "comment": "last_insert_id for unsharded route", "query": "select last_insert_id() as x from main.unsharded", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select last_insert_id() as x from main.unsharded", "Instructions": { @@ -659,6 +684,7 @@ "comment": "select from dual on unqualified keyspace", "query": "select @@session.auto_increment_increment from dual", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select @@session.auto_increment_increment from dual", "Instructions": { @@ -681,6 +707,7 @@ "comment": "select from pinned table", "query": "select * from pin_test", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from pin_test", "Instructions": { @@ -713,6 +740,7 @@ "comment": "RHS route referenced", "query": "select user_extra.id from user join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_extra.id from user join user_extra", "Instructions": { @@ -756,6 +784,7 @@ "comment": "Both routes referenced", "query": "select user.col, user_extra.id from user join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col, user_extra.id from user join user_extra", "Instructions": { @@ -799,6 +828,7 @@ "comment": "Expression with single-route reference", "query": "select user.col, user_extra.id + user_extra.col from user join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col, user_extra.id + user_extra.col from user join user_extra", "Instructions": { @@ -842,6 +872,7 @@ "comment": "subquery with an aggregation in order by that can be merged into a single route", "query": "select col, trim((select user_name from user where id = 3)) val from user_extra where user_id = 3 group by col order by val", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select col, trim((select user_name from user where id = 3)) val from user_extra where user_id = 3 group by col order by val", "Instructions": { @@ -870,6 +901,7 @@ "comment": "Jumbled references", "query": "select user.col, user_extra.id, user.col2 from user join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col, user_extra.id, user.col2 from user join user_extra", "Instructions": { @@ -913,6 +945,7 @@ "comment": "Comments", "query": "select /* comment */ user.col from user join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select /* comment */ user.col from user join user_extra", "Instructions": { @@ -956,6 +989,7 @@ "comment": "for update", "query": "select user.col from user join user_extra for update", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col from user join user_extra for update", "Instructions": { @@ -999,6 +1033,7 @@ "comment": "Field query should work for joins select bind vars", "query": "select user.id, (select user.id+outm.m+unsharded.m from unsharded) from user join unsharded outm", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.id, (select user.id+outm.m+unsharded.m from unsharded) from user join unsharded outm", "Instructions": { @@ -1045,6 +1080,7 @@ "comment": "Case preservation", "query": "select user.Col, user_extra.Id from user join user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.Col, user_extra.Id from user join user_extra", "Instructions": { @@ -1094,6 +1130,7 @@ "comment": "Hex number is not treated as a simple value", "query": "select * from user where id = 0x04", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 0x04", "Instructions": { @@ -1120,6 +1157,7 @@ "comment": "Selection but explicitly ignore a vindex", "query": "select * from user ignore vindex (user_index) where id = 1", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from user ignore vindex (user_index) where id = 1", "Instructions": { @@ -1143,6 +1181,7 @@ "comment": "Selection but make the planner explicitly use a vindex", "query": "select intcol, id from user use vindex (name_user_map) where costly = 'aa' and name = 'bb' and id = 3", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select intcol, id from user use vindex (name_user_map) where costly = 'aa' and name = 'bb' and id = 3", "Instructions": { @@ -1201,6 +1240,7 @@ "comment": "sharded limit offset", "query": "select user_id from music order by user_id limit 10, 20", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user_id from music order by user_id limit 10, 20", "Instructions": { @@ -1232,6 +1272,7 @@ "comment": "sharded limit offset with arguments", "query": "select user_id from music order by user_id limit :limit, :offset", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select user_id from music order by user_id limit :limit, :offset", "Instructions": { @@ -1264,6 +1305,7 @@ "comment": "Sharding Key Condition in Parenthesis", "query": "select * from user where name ='abc' AND (id = 4) limit 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where name ='abc' AND (id = 4) limit 5", "Instructions": { @@ -1291,6 +1333,7 @@ "comment": "Multiple parenthesized expressions", "query": "select * from user where (id = 4) AND (name ='abc') limit 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where (id = 4) AND (name ='abc') limit 5", "Instructions": { @@ -1318,6 +1361,7 @@ "comment": "Multiple parenthesized expressions", "query": "select * from user where (id = 4 and name ='abc') limit 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where (id = 4 and name ='abc') limit 5", "Instructions": { @@ -1345,6 +1389,7 @@ "comment": "Column Aliasing with Table.Column", "query": "select user0_.col as col0_ from user user0_ where id = 1 order by user0_.col desc limit 2", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user0_.col as col0_ from user user0_ where id = 1 order by user0_.col desc limit 2", "Instructions": { @@ -1371,6 +1416,7 @@ "comment": "Column Aliasing with Column", "query": "select user0_.col as col0_ from user user0_ where id = 1 order by col0_ desc limit 3", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select user0_.col as col0_ from user user0_ where id = 1 order by col0_ desc limit 3", "Instructions": { @@ -1397,6 +1443,7 @@ "comment": "Booleans and parenthesis", "query": "select * from user where (id = 1) AND name = true limit 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where (id = 1) AND name = true limit 5", "Instructions": { @@ -1424,6 +1471,7 @@ "comment": "Column as boolean-ish", "query": "select * from user where (id = 1) AND name limit 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where (id = 1) AND name limit 5", "Instructions": { @@ -1451,6 +1499,7 @@ "comment": "PK as fake boolean, and column as boolean-ish", "query": "select * from user where (id = 5) AND name = true limit 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where (id = 5) AND name = true limit 5", "Instructions": { @@ -1478,6 +1527,7 @@ "comment": "top level subquery in select", "query": "select a, (select col from user) from unsharded", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, (select col from user) from unsharded", "Instructions": { @@ -1524,6 +1574,7 @@ "comment": "sub-expression subquery in select", "query": "select a, 1+(select col from user) from unsharded", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select a, 1+(select col from user) from unsharded", "Instructions": { @@ -1570,6 +1621,7 @@ "comment": "select * from derived table expands specific columns", "query": "select * from (select user.id id1, user_extra.id id2 from user join user_extra) as t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select * from (select user.id id1, user_extra.id id2 from user join user_extra) as t", "Instructions": { @@ -1625,6 +1677,7 @@ "comment": "union with the same target shard", "query": "select * from music where user_id = 1 union select * from user where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from music where user_id = 1 union select * from user where id = 1", "Instructions": { @@ -1653,6 +1706,7 @@ "comment": "union with the same target shard last_insert_id", "query": "select *, last_insert_id() from music where user_id = 1 union select * from user where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select *, last_insert_id() from music where user_id = 1 union select * from user where id = 1", "Instructions": { @@ -1681,6 +1735,7 @@ "comment": "unsharded union in derived table", "query": "select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) a", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from (select col1, col2 from unsharded where id = 1 union select col1, col2 from unsharded where id = 3) a", "Instructions": { @@ -1703,6 +1758,7 @@ "comment": "unsharded union in subquery", "query": "select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id, name from unsharded where id in (select id from unsharded where id = 1 union select id from unsharded where id = 3)", "Instructions": { @@ -1725,6 +1781,7 @@ "comment": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "query": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "Instructions": { @@ -1748,6 +1805,7 @@ "comment": "unsharded union", "query": "select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select id from unsharded union select id from unsharded_auto union select id from unsharded_auto where id in (132)", "Instructions": { @@ -1771,6 +1829,7 @@ "comment": "unsharded nested union", "query": "(select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "(select id from unsharded union select id from unsharded_auto) union (select id from unsharded_auto union select name from unsharded)", "Instructions": { @@ -1794,6 +1853,7 @@ "comment": "unsharded nested union with limit", "query": "(select id from unsharded order by id asc limit 1) union (select id from unsharded order by id desc limit 1) order by id asc limit 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "(select id from unsharded order by id asc limit 1) union (select id from unsharded order by id desc limit 1) order by id asc limit 1", "Instructions": { @@ -1816,6 +1876,7 @@ "comment": "routing rules: ensure directives are not lost", "query": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from route2", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select /*vt+ QUERY_TIMEOUT_MS=1000 */ * from route2", "Instructions": { @@ -1840,6 +1901,7 @@ "comment": "routing table on music", "query": "select * from second_user.bar where id > 2", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from second_user.bar where id > 2", "Instructions": { @@ -1863,6 +1925,7 @@ "comment": "testing SingleRow Projection", "query": "select 42", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 42", "Instructions": { @@ -1885,6 +1948,7 @@ "comment": "avg in sharded keyspace with group by without selecting the group by columns", "query": "select avg(intcol) as avg_col from user group by textcol1, textcol2 order by textcol1, textcol2;", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select avg(intcol) as avg_col from user group by textcol1, textcol2 order by textcol1, textcol2;", "Instructions": { @@ -1935,6 +1999,7 @@ "comment": "don't filter on the vtgate", "query": "select 42 from dual where false", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "select 42 from dual where false", "Instructions": { @@ -1957,6 +2022,7 @@ "comment": "Complex expression in a subquery used in IN clause of an aggregate query", "query": "select count(*) from user where user.id = 2 or user.id in (select id from unsharded_a where colb = 2)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user where user.id = 2 or user.id in (select id from unsharded_a where colb = 2)", "Instructions": { @@ -2011,6 +2077,7 @@ "comment": "Complex expression in a subquery used in NOT IN clause of an aggregate query", "query": "select count(*) from user where user.id = 2 or user.id not in (select id from unsharded_a where colb = 2)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) from user where user.id = 2 or user.id not in (select id from unsharded_a where colb = 2)", "Instructions": { @@ -2065,6 +2132,7 @@ "comment": "testing SingleRow Projection with arithmetics", "query": "select 42+2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 42+2", "Instructions": { @@ -2087,6 +2155,7 @@ "comment": "sql_calc_found_rows without limit", "query": "select sql_calc_found_rows * from music where user_id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select sql_calc_found_rows * from music where user_id = 1", "Instructions": { @@ -2113,6 +2182,7 @@ "comment": "sql_calc_found_rows with limit", "query": "select sql_calc_found_rows * from music limit 100", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sql_calc_found_rows * from music limit 100", "Instructions": { @@ -2164,6 +2234,7 @@ "comment": "sql_calc_found_rows with SelectEqualUnique plans", "query": "select sql_calc_found_rows * from music where user_id = 1 limit 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sql_calc_found_rows * from music where user_id = 1 limit 2", "Instructions": { @@ -2210,6 +2281,7 @@ "comment": "sql_calc_found_rows with group by and having", "query": "select sql_calc_found_rows user_id, count(id) from music group by user_id having count(user_id) = 1 order by user_id limit 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sql_calc_found_rows user_id, count(id) from music group by user_id having count(user_id) = 1 order by user_id limit 2", "Instructions": { @@ -2275,6 +2347,7 @@ "comment": "select from unsharded keyspace into dumpfile", "query": "select * from main.unsharded into Dumpfile 'x.txt'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from main.unsharded into Dumpfile 'x.txt'", "Instructions": { @@ -2298,6 +2371,7 @@ "comment": "select from unsharded keyspace into outfile", "query": "select * from main.unsharded into outfile 'x.txt' character set binary fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from main.unsharded into outfile 'x.txt' character set binary fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n'", "Instructions": { @@ -2321,6 +2395,7 @@ "comment": "select from unsharded keyspace into outfile s3", "query": "select * from main.unsharded into outfile s3 'out_file_name' character set binary format csv header fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n' manifest on overwrite off", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from main.unsharded into outfile s3 'out_file_name' character set binary format csv header fields terminated by 'term' optionally enclosed by 'c' escaped by 'e' lines starting by 'a' terminated by '\n' manifest on overwrite off", "Instructions": { @@ -2344,6 +2419,7 @@ "comment": "left join with a dual table on left - merge-able", "query": "select t.title, user.col from (select 'hello' as title) as t left join user on user.id=1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t.title, user.col from (select 'hello' as title) as t left join user on user.id=1", "Instructions": { @@ -2371,6 +2447,7 @@ "comment": "left join with a dual table on left - non-merge-able", "query": "select t.title, user.col from (select 'hello' as title) as t left join user on user.id <= 4", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.title, user.col from (select 'hello' as title) as t left join user on user.id <= 4", "Instructions": { @@ -2413,6 +2490,7 @@ "comment": "left join with dual non-merge-able with predicate with cross dependencies", "query": "select t.title, user.col from (select 'hello' as title) as t left join user on user.id <= 4 and t.title = user.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.title, user.col from (select 'hello' as title) as t left join user on user.id <= 4 and t.title = user.col", "Instructions": { @@ -2458,6 +2536,7 @@ "comment": "right join with a dual table on left", "query": "select t.title, user.col from (select 'hello' as title) as t right join user on user.id<=4", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select t.title, user.col from (select 'hello' as title) as t right join user on user.id<=4", "Instructions": { @@ -2481,6 +2560,7 @@ "comment": "right join with a dual table on right - merge-able", "query": "select t.title, user.col from user right join (select 'hello' as title) as t on user.id=1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t.title, user.col from user right join (select 'hello' as title) as t on user.id=1", "Instructions": { @@ -2508,6 +2588,7 @@ "comment": "right join with a dual table on right - non-merge-able", "query": "select t.title, user.col from user right join (select 'hello' as title) as t on user.id>=4", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.title, user.col from user right join (select 'hello' as title) as t on user.id>=4", "Instructions": { @@ -2568,6 +2649,7 @@ "comment": "select (select u.id from user as u where u.id = 1), a.id from user as a where a.id = 1", "query": "select (select u.id from user as u where u.id = 1), a.id from user as a where a.id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select (select u.id from user as u where u.id = 1), a.id from user as a where a.id = 1", "Instructions": { @@ -2594,6 +2676,7 @@ "comment": "Add two tables with the same column in a join", "query": "select t.id, s.id from user t join user_extra s on t.id = s.user_id join unsharded", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.id, s.id from user t join user_extra s on t.id = s.user_id join unsharded", "Instructions": { @@ -2638,6 +2721,7 @@ "comment": "((((select 1))))", "query": "((((select 1))))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "((((select 1))))", "Instructions": { @@ -2660,6 +2744,7 @@ "comment": "Merging dual with user", "query": "select 42, id from dual, user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select 42, id from dual, user", "Instructions": { @@ -2684,6 +2769,7 @@ "comment": "subquery in select expression of derived table", "query": "select t.a from (select (select col from user limit 1) as a from user join user_extra) t", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select t.a from (select (select col from user limit 1) as a from user join user_extra) t", "Instructions": { @@ -2755,6 +2841,7 @@ "comment": "ORDER BY subquery", "query": "select (select col from user limit 1) as a from user join user_extra order by a", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select (select col from user limit 1) as a from user join user_extra order by a", "Instructions": { @@ -2826,6 +2913,7 @@ "comment": "plan test for a natural character set string", "query": "select N'string' from dual", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select N'string' from dual", "Instructions": { @@ -2848,6 +2936,7 @@ "comment": "select expression having dependencies on both sides of a join", "query": "select user.id * user_id as amount from user, user_extra", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.id * user_id as amount from user, user_extra", "Instructions": { @@ -2894,6 +2983,7 @@ "comment": "Straight Join ensures specific ordering of joins", "query": "select user.id, user_extra.user_id from user straight_join user_extra where user.id = user_extra.foo", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.id, user_extra.user_id from user straight_join user_extra where user.id = user_extra.foo", "Instructions": { @@ -2940,6 +3030,7 @@ "comment": "Dual query should be handled on the vtgate even with a LIMIT", "query": "select last_insert_id() limit 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select last_insert_id() limit 1", "Instructions": { @@ -2962,6 +3053,7 @@ "comment": "PullOut subquery with an aggregation that should be typed in the final output", "query": "select (select sum(col) from user) from user_extra", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select (select sum(col) from user) from user_extra", "Instructions": { @@ -3015,6 +3107,7 @@ "comment": "Straight Join preserved in MySQL query", "query": "select user.id, user_extra.user_id from user straight_join user_extra where user.id = user_extra.user_id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.id, user_extra.user_id from user straight_join user_extra where user.id = user_extra.user_id", "Instructions": { @@ -3039,6 +3132,7 @@ "comment": "correlated subquery in exists clause", "query": "select col from user where exists(select user_id from user_extra where user_id = 3 and user_id < user.id)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user where exists(select user_id from user_extra where user_id = 3 and user_id < user.id)", "Instructions": { @@ -3098,6 +3192,7 @@ "comment": "correlated subquery in exists clause with an order by", "query": "select col from user where exists(select user_id from user_extra where user_id = 3 and user_id < user.id) order by col", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from user where exists(select user_id from user_extra where user_id = 3 and user_id < user.id) order by col", "Instructions": { @@ -3158,6 +3253,7 @@ "comment": "correlated subquery having dependencies on two tables", "query": "select 1 from user u1, user u2 where exists (select 1 from user_extra ue where ue.col = u1.col and ue.col = u2.col)", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select 1 from user u1, user u2 where exists (select 1 from user_extra ue where ue.col = u1.col and ue.col = u2.col)", "Instructions": { @@ -3232,6 +3328,7 @@ "comment": "correlated subquery using a column twice", "query": "select 1 from user u where exists (select 1 from user_extra ue where ue.col = u.col and u.col = ue.col2)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from user u where exists (select 1 from user_extra ue where ue.col = u.col and u.col = ue.col2)", "Instructions": { @@ -3290,6 +3387,7 @@ "comment": "correlated subquery that is dependent on one side of a join, fully mergeable", "query": "SELECT music.id FROM music INNER JOIN user ON music.user_id = user.id WHERE music.user_id = 5 AND music.id = (SELECT MAX(m2.id) FROM music m2 WHERE m2.user_id = user.id)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music INNER JOIN user ON music.user_id = user.id WHERE music.user_id = 5 AND music.id = (SELECT MAX(m2.id) FROM music m2 WHERE m2.user_id = user.id)", "Instructions": { @@ -3317,6 +3415,7 @@ "comment": "Complex join with multiple conditions merged into single route", "query": "select 0 from user as u join user_extra as s on u.id = s.user_id join music as m on m.user_id = u.id and (s.foo or m.bar)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select 0 from user as u join user_extra as s on u.id = s.user_id join music as m on m.user_id = u.id and (s.foo or m.bar)", "Instructions": { @@ -3342,6 +3441,7 @@ "comment": "union as a derived table", "query": "select found from (select id as found from user union all (select id from unsharded)) as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select found from (select id as found from user union all (select id from unsharded)) as t", "Instructions": { @@ -3381,6 +3481,7 @@ "comment": "use output column containing data from both sides of the join", "query": "select user_extra.col + user.col from user join user_extra on user.id = user_extra.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_extra.col + user.col from user join user_extra on user.id = user_extra.id", "Instructions": { @@ -3432,6 +3533,7 @@ "comment": "mergeable derived table with order by and limit", "query": "select 1 from (select col from main.unsharded order by main.unsharded.col1 desc limit 12 offset 0) as f left join unsharded as u on f.col = u.id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select 1 from (select col from main.unsharded order by main.unsharded.col1 desc limit 12 offset 0) as f left join unsharded as u on f.col = u.id", "Instructions": { @@ -3455,6 +3557,7 @@ "comment": "mergeable derived table with group by and limit", "query": "select 1 from (select col, count(*) as a from main.unsharded group by col having a > 0 limit 12 offset 0) as f left join unsharded as u on f.col = u.id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select 1 from (select col, count(*) as a from main.unsharded group by col having a > 0 limit 12 offset 0) as f left join unsharded as u on f.col = u.id", "Instructions": { @@ -3478,6 +3581,7 @@ "comment": "select user.id, trim(leading 'x' from user.name) from user", "query": "select user.id, trim(leading 'x' from user.name) from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select user.id, trim(leading 'x' from user.name) from user", "Instructions": { @@ -3501,6 +3605,7 @@ "comment": "json utility functions", "query": "select jcol, JSON_STORAGE_SIZE(jcol), JSON_STORAGE_FREE(jcol), JSON_PRETTY(jcol) from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select jcol, JSON_STORAGE_SIZE(jcol), JSON_STORAGE_FREE(jcol), JSON_PRETTY(jcol) from user", "Instructions": { @@ -3524,6 +3629,7 @@ "comment": "dual query with exists clause", "query": "select 1 from dual where exists (select 1 from information_schema.TABLES where information_schema.TABLES.TABLE_NAME = 'proc' and information_schema.TABLES.TABLE_SCHEMA = 'mysql')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select 1 from dual where exists (select 1 from information_schema.TABLES where information_schema.TABLES.TABLE_NAME = 'proc' and information_schema.TABLES.TABLE_SCHEMA = 'mysql')", "Instructions": { @@ -3548,6 +3654,7 @@ "comment": "json_quote, json_object and json_array", "query": "SELECT JSON_QUOTE('null'), JSON_QUOTE('\"null\"'), JSON_OBJECT(BIN(1),2,'abc',ASCII(4)), JSON_ARRAY(1, \"abc\", NULL, TRUE, CURTIME())", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT JSON_QUOTE('null'), JSON_QUOTE('\"null\"'), JSON_OBJECT(BIN(1),2,'abc',ASCII(4)), JSON_ARRAY(1, \"abc\", NULL, TRUE, CURTIME())", "Instructions": { @@ -3570,6 +3677,7 @@ "comment": "select (select id from user order by id limit 1) from user_extra", "query": "select (select id from user order by id limit 1) from user_extra", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select (select id from user order by id limit 1) from user_extra", "Instructions": { @@ -3623,6 +3731,7 @@ "comment": "yeah, it does not make sense, but it's valid", "query": "select exists(select 1) from user where id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select exists(select 1) from user where id = 5", "Instructions": { @@ -3650,6 +3759,7 @@ "comment": "json schema validation functions", "query": "SELECT JSON_SCHEMA_VALID('{\"type\":\"string\",\"pattern\":\"(\"}', '\"abc\"'), JSON_SCHEMA_VALIDATION_REPORT('{\"type\":\"string\",\"pattern\":\"(\"}', '\"abc\"')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT JSON_SCHEMA_VALID('{\"type\":\"string\",\"pattern\":\"(\"}', '\"abc\"'), JSON_SCHEMA_VALIDATION_REPORT('{\"type\":\"string\",\"pattern\":\"(\"}', '\"abc\"')", "Instructions": { @@ -3672,6 +3782,7 @@ "comment": "json search functions", "query": "SELECT JSON_CONTAINS('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}', '1'), JSON_CONTAINS_PATH('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}', 'one', '$.a', '$.e'), JSON_EXTRACT('[10, 20, [30, 40]]', '$[1]'), JSON_UNQUOTE(JSON_EXTRACT('[\"a\",\"b\"]', '$[1]')), JSON_KEYS('{\"a\": 1, \"b\": {\"c\": 30}}'), JSON_OVERLAPS(\"[1,3,5,7]\", \"[2,5,7]\"), JSON_SEARCH('[\"abc\"]', 'one', 'abc'), JSON_VALUE('{\"fname\": \"Joe\", \"lname\": \"Palmer\"}', '$.fname'), JSON_ARRAY(4,5) MEMBER OF('[[3,4],[4,5]]')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT JSON_CONTAINS('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}', '1'), JSON_CONTAINS_PATH('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}', 'one', '$.a', '$.e'), JSON_EXTRACT('[10, 20, [30, 40]]', '$[1]'), JSON_UNQUOTE(JSON_EXTRACT('[\"a\",\"b\"]', '$[1]')), JSON_KEYS('{\"a\": 1, \"b\": {\"c\": 30}}'), JSON_OVERLAPS(\"[1,3,5,7]\", \"[2,5,7]\"), JSON_SEARCH('[\"abc\"]', 'one', 'abc'), JSON_VALUE('{\"fname\": \"Joe\", \"lname\": \"Palmer\"}', '$.fname'), JSON_ARRAY(4,5) MEMBER OF('[[3,4],[4,5]]')", "Instructions": { @@ -3694,6 +3805,7 @@ "comment": "Json extract and json unquote shorthands", "query": "SELECT a->\"$[4]\", a->>\"$[3]\" FROM user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT a->\"$[4]\", a->>\"$[3]\" FROM user", "Instructions": { @@ -3717,6 +3829,7 @@ "comment": "groupe by with non aggregated columns and table alias", "query": "select u.id, u.age from user u group by u.id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select u.id, u.age from user u group by u.id", "Instructions": { @@ -3740,6 +3853,7 @@ "comment": "Functions that return JSON value attributes", "query": "select JSON_DEPTH('{}'), JSON_LENGTH('{\"a\": 1, \"b\": {\"c\": 30}}', '$.b'), JSON_TYPE(JSON_EXTRACT('{\"a\": [10, true]}', '$.a')), JSON_VALID('{\"a\": 1}')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select JSON_DEPTH('{}'), JSON_LENGTH('{\"a\": 1, \"b\": {\"c\": 30}}', '$.b'), JSON_TYPE(JSON_EXTRACT('{\"a\": [10, true]}', '$.a')), JSON_VALID('{\"a\": 1}')", "Instructions": { @@ -3762,6 +3876,7 @@ "comment": "Json array functions", "query": "select JSON_ARRAY_APPEND('{\"a\": 1}', '$', 'z'), JSON_ARRAY_INSERT('[\"a\", {\"b\": [1, 2]}, [3, 4]]', '$[0]', 'x', '$[2][1]', 'y'), JSON_INSERT('{ \"a\": 1, \"b\": [2, 3]}', '$.a', 10, '$.c', CAST('[true, false]' AS JSON))", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select JSON_ARRAY_APPEND('{\"a\": 1}', '$', 'z'), JSON_ARRAY_INSERT('[\"a\", {\"b\": [1, 2]}, [3, 4]]', '$[0]', 'x', '$[2][1]', 'y'), JSON_INSERT('{ \"a\": 1, \"b\": [2, 3]}', '$.a', 10, '$.c', CAST('[true, false]' AS JSON))", "Instructions": { @@ -3784,6 +3899,7 @@ "comment": "Json merge functions", "query": "select JSON_MERGE('[1, 2]', '[true, false]'), JSON_MERGE_PATCH('{\"name\": \"x\"}', '{\"id\": 47}'), JSON_MERGE_PRESERVE('[1, 2]', '{\"id\": 47}')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select JSON_MERGE('[1, 2]', '[true, false]'), JSON_MERGE_PATCH('{\"name\": \"x\"}', '{\"id\": 47}'), JSON_MERGE_PRESERVE('[1, 2]', '{\"id\": 47}')", "Instructions": { @@ -3806,6 +3922,7 @@ "comment": "JSON modifier functions", "query": "select JSON_REMOVE('[1, [2, 3], 4]', '$[1]'), JSON_REPLACE('{ \"a\": 1, \"b\": [2, 3]}', '$.a', 10, '$.c', '[true, false]'), JSON_SET('{ \"a\": 1, \"b\": [2, 3]}', '$.a', 10, '$.c', '[true, false]'), JSON_UNQUOTE('\"abc\"')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select JSON_REMOVE('[1, [2, 3], 4]', '$[1]'), JSON_REPLACE('{ \"a\": 1, \"b\": [2, 3]}', '$.a', 10, '$.c', '[true, false]'), JSON_SET('{ \"a\": 1, \"b\": [2, 3]}', '$.a', 10, '$.c', '[true, false]'), JSON_UNQUOTE('\"abc\"')", "Instructions": { @@ -3828,6 +3945,7 @@ "comment": "Reference with a subquery which can be merged", "query": "select exists(select id from user where id = 4)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select exists(select id from user where id = 4)", "Instructions": { @@ -3855,6 +3973,7 @@ "comment": "Reference with a subquery which cannot be merged", "query": "select exists(select * from user)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select exists(select * from user)", "Instructions": { @@ -3901,6 +4020,7 @@ "comment": "insert function not requiring any table", "query": "select insert('Quadratic', 3, 4, 'What')", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select insert('Quadratic', 3, 4, 'What')", "Instructions": { @@ -3923,6 +4043,7 @@ "comment": "insert function using column names as arguments", "query": "select insert(tcol1, id, 3, tcol2) from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select insert(tcol1, id, 3, tcol2) from user", "Instructions": { @@ -3946,6 +4067,7 @@ "comment": "gtid functions", "query": "select gtid_subset('3E11FA47-71CA-11E1-9E33-C80AA9429562:23','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57'), gtid_subtract('3E11FA47-71CA-11E1-9E33-C80AA9429562:23','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57')", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select gtid_subset('3E11FA47-71CA-11E1-9E33-C80AA9429562:23','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57'), gtid_subtract('3E11FA47-71CA-11E1-9E33-C80AA9429562:23','3E11FA47-71CA-11E1-9E33-C80AA9429562:21-57')", "Instructions": { @@ -3968,6 +4090,7 @@ "comment": "Predicate in apply join which is merged", "query": "select user.col, user_metadata.user_id from user join user_extra on user.col = user_extra.col join user_metadata on user_extra.user_id = user_metadata.user_id where user.textcol1 = 'alice@gmail.com'", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.col, user_metadata.user_id from user join user_extra on user.col = user_extra.col join user_metadata on user_extra.user_id = user_metadata.user_id where user.textcol1 = 'alice@gmail.com'", "Instructions": { @@ -4015,6 +4138,7 @@ "comment": "Join across multiple tables, with conditions on different vindexes, but mergeable through join predicates", "query": "SELECT user.id FROM user INNER JOIN music_extra ON user.id = music_extra.user_id INNER JOIN music ON music_extra.user_id = music.user_id WHERE user.id = 123 and music.id = 456", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT user.id FROM user INNER JOIN music_extra ON user.id = music_extra.user_id INNER JOIN music ON music_extra.user_id = music.user_id WHERE user.id = 123 and music.id = 456", "Instructions": { @@ -4044,6 +4168,7 @@ "comment": "SQL_CALC_FOUND_ROWS with vindex lookup", "query": "select SQL_CALC_FOUND_ROWS id, name from user where name = 'aa' order by id limit 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select SQL_CALC_FOUND_ROWS id, name from user where name = 'aa' order by id limit 2", "Instructions": { @@ -4156,6 +4281,7 @@ "comment": "`None` route being merged with another route via join predicate on Vindex columns", "query": "SELECT `music`.id FROM `music` INNER JOIN `user` ON music.user_id = user.id WHERE music.user_id IN (NULL) AND user.id = 5", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "SELECT `music`.id FROM `music` INNER JOIN `user` ON music.user_id = user.id WHERE music.user_id IN (NULL) AND user.id = 5", "Instructions": { @@ -4179,6 +4305,7 @@ "comment": "Treating single value tuples as `EqualUnique` routes", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (5)) AND music.user_id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (5)) AND music.user_id = 5", "Instructions": { @@ -4206,6 +4333,7 @@ "comment": "Subquery with `IN` condition using columns with matching lookup vindexes", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3))", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3))", "Instructions": { @@ -4232,6 +4360,7 @@ "comment": "Subquery with `IN` condition using columns with matching lookup vindexes, with derived table", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3)) _inner)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3)) _inner)", "Instructions": { @@ -4258,6 +4387,7 @@ "comment": "Subquery with `IN` condition using columns with matching lookup vindexes, with inner scatter query", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.foo = 'bar') AND music.user_id IN (3, 4, 5)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.foo = 'bar') AND music.user_id IN (3, 4, 5)", "Instructions": { @@ -4285,6 +4415,7 @@ "comment": "Subquery with `IN` condition using columns with matching lookup vindexes", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3)) and music.user_id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3)) and music.user_id = 5", "Instructions": { @@ -4311,6 +4442,7 @@ "comment": "Subquery with `IN` condition using columns with matching lookup vindexes, but not a top level predicate", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3)) OR music.user_id = 5", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (1, 2, 3)) OR music.user_id = 5", "Instructions": { @@ -4333,6 +4465,7 @@ "comment": "`IN` comparison on Vindex with `None` subquery, as routing predicate", "query": "SELECT `music`.id FROM `music` WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) AND music.user_id = 5", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "SELECT `music`.id FROM `music` WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) AND music.user_id = 5", "Instructions": { @@ -4355,6 +4488,7 @@ "comment": "`IN` comparison on Vindex with `None` subquery, as non-routing predicate", "query": "SELECT `music`.id FROM `music` WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) OR music.user_id = 5", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT `music`.id FROM `music` WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) OR music.user_id = 5", "Instructions": { @@ -4377,6 +4511,7 @@ "comment": "Mergeable scatter subquery", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop')", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop')", "Instructions": { @@ -4400,6 +4535,7 @@ "comment": "Mergeable scatter subquery with `GROUP BY` on unique vindex column", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop' GROUP BY music.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop' GROUP BY music.id)", "Instructions": { @@ -4423,6 +4559,7 @@ "comment": "Unmergeable scatter subquery with `GROUP BY` on-non vindex column", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop' GROUP BY music.genre)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop' GROUP BY music.genre)", "Instructions": { @@ -4507,6 +4644,7 @@ "comment": "Unmergeable scatter subquery with LIMIT", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop' LIMIT 10)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.genre = 'pop' LIMIT 10)", "Instructions": { @@ -4588,6 +4726,7 @@ "comment": "Mergeable subquery with `MAX` aggregate and grouped by unique vindex", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id IN (5, 6) GROUP BY music.user_id)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id IN (5, 6) GROUP BY music.user_id)", "Instructions": { @@ -4667,6 +4806,7 @@ "comment": "Unmergeable subquery with `MAX` aggregate", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id IN (5, 6))", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id IN (5, 6))", "Instructions": { @@ -4752,6 +4892,7 @@ "comment": "Mergeable subquery with `MAX` aggregate with `EqualUnique` route operator", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id = 5)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id = 5)", "Instructions": { @@ -4830,6 +4971,7 @@ "comment": "Mergeable subquery with `LIMIT` due to `EqualUnique` route", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id = 5 LIMIT 10)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT MAX(music.id) FROM music WHERE music.user_id = 5 LIMIT 10)", "Instructions": { @@ -4909,6 +5051,7 @@ "comment": "Mergeable subquery with multiple levels of derived statements", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id = 5 LIMIT 10) subquery_for_limit) subquery_for_limit)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id = 5 LIMIT 10) subquery_for_limit) subquery_for_limit)", "Instructions": { @@ -4935,6 +5078,7 @@ "comment": "Mergeable subquery with multiple levels of derived statements, using a single value `IN` predicate", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id IN (5) LIMIT 10) subquery_for_limit) subquery_for_limit)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id IN (5) LIMIT 10) subquery_for_limit) subquery_for_limit)", "Instructions": { @@ -4961,6 +5105,7 @@ "comment": "We are using last_insert_id with argument, so we need to fetch all results", "query": "select last_insert_id(5) from user limit 12", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select last_insert_id(5) from user limit 12", "Instructions": { @@ -4991,6 +5136,7 @@ "comment": "Unmergeable subquery with multiple levels of derived statements, using a multi value `IN` predicate", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id IN (5, 6) LIMIT 10) subquery_for_limit) subquery_for_limit)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music WHERE music.user_id IN (5, 6) LIMIT 10) subquery_for_limit) subquery_for_limit)", "Instructions": { @@ -5076,6 +5222,7 @@ "comment": "Unmergeable subquery with multiple levels of derived statements", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music LIMIT 10) subquery_for_limit) subquery_for_limit)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT * FROM (SELECT * FROM (SELECT music.id FROM music LIMIT 10) subquery_for_limit) subquery_for_limit)", "Instructions": { @@ -5157,6 +5304,7 @@ "comment": "`None` subquery as top level predicate - outer query changes from `Scatter` to `None` on merge", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL))", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL))", "Instructions": { @@ -5179,6 +5327,7 @@ "comment": "`None` subquery as top level predicate - outer query changes from `EqualUnique` to `None` on merge", "query": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) AND music.user_id = 5", "plan": { + "Type": "Local", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) AND music.user_id = 5", "Instructions": { @@ -5201,6 +5350,7 @@ "comment": "`None` subquery nested inside `OR` expression - outer query keeps routing information", "query": "SELECT music.id FROM music WHERE (music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) OR music.user_id = 5)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "SELECT music.id FROM music WHERE (music.id IN (SELECT music.id FROM music WHERE music.user_id IN (NULL)) OR music.user_id = 5)", "Instructions": { @@ -5223,6 +5373,7 @@ "comment": "Joining with a subquery that uses an aggregate column and an `EqualUnique` route can be merged together", "query": "SELECT music.id FROM music INNER JOIN (SELECT MAX(id) as maxt FROM music WHERE music.user_id = 5) other ON other.maxt = music.id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music INNER JOIN (SELECT MAX(id) as maxt FROM music WHERE music.user_id = 5) other ON other.maxt = music.id", "Instructions": { @@ -5249,6 +5400,7 @@ "comment": "Joining with a subquery that uses an `EqualUnique` route can be merged", "query": "SELECT music.id FROM music INNER JOIN (SELECT id FROM music WHERE music.user_id = 5) other ON other.id = music.id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM music INNER JOIN (SELECT id FROM music WHERE music.user_id = 5) other ON other.id = music.id", "Instructions": { @@ -5275,6 +5427,7 @@ "comment": "Joining with a subquery that has an `IN` route can be merged", "query": "SELECT music.id FROM music INNER JOIN (SELECT id FROM music WHERE music.user_id IN (5, 6, 7)) other ON other.id = music.id", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "SELECT music.id FROM music INNER JOIN (SELECT id FROM music WHERE music.user_id IN (5, 6, 7)) other ON other.id = music.id", "Instructions": { @@ -5301,6 +5454,7 @@ "comment": "limit on the vtgate has to be executed on the LHS of a join", "query": "select id from user join (select user_id from user_extra limit 10) ue on user.id = ue.user_id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select id from user join (select user_id from user_extra limit 10) ue on user.id = ue.user_id", "Instructions": { @@ -5357,6 +5511,7 @@ "comment": "select user.a, t.b from user join (select id, count(*) b, req from user_extra group by req, id) as t on user.id = t.id", "query": "select user.a, t.b from user join (select id, count(*) b, req from user_extra group by req, id) as t on user.id = t.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user.a, t.b from user join (select id, count(*) b, req from user_extra group by req, id) as t on user.id = t.id", "Instructions": { @@ -5422,6 +5577,7 @@ "comment": "SELECT music.id FROM (SELECT MAX(id) as maxt FROM music WHERE music.user_id = 5) other JOIN music ON other.maxt = music.id", "query": "SELECT music.id FROM (SELECT MAX(id) as maxt FROM music WHERE music.user_id = 5) other JOIN music ON other.maxt = music.id", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT music.id FROM (SELECT MAX(id) as maxt FROM music WHERE music.user_id = 5) other JOIN music ON other.maxt = music.id", "Instructions": { @@ -5448,6 +5604,7 @@ "comment": "Earlier columns are in scope in subqueries https://github.com/vitessio/vitess/issues/11246", "query": "SELECT 1 as x, (SELECT x)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT 1 as x, (SELECT x)", "Instructions": { @@ -5470,6 +5627,7 @@ "comment": "(OR 1 = 0) doesn't cause unnecessary scatter", "query": "select * from user where id = 1 or 1 = 0", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 1 or 1 = 0", "Instructions": { @@ -5496,6 +5654,7 @@ "comment": "(OR 2 < 1) doesn't cause unnecessary scatter", "query": "select * from user where id = 1 or 2 < 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from user where id = 1 or 2 < 1", "Instructions": { @@ -5522,6 +5681,7 @@ "comment": "query with a derived table and dual table in unsharded keyspace", "query": "SELECT * FROM unsharded_a AS t1 JOIN (SELECT trim((SELECT MAX(name) FROM unsharded_a)) AS name) AS t2 WHERE t1.name >= t2.name ORDER BY t1.name ASC LIMIT 1;", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * FROM unsharded_a AS t1 JOIN (SELECT trim((SELECT MAX(name) FROM unsharded_a)) AS name) AS t2 WHERE t1.name >= t2.name ORDER BY t1.name ASC LIMIT 1;", "Instructions": { @@ -5546,6 +5706,7 @@ "comment": "subquery having join table on clause, using column reference of outer select table", "query": "select (select 1 from user u1 join user u2 on u1.id = u2.id and u1.id = u3.id) subquery from user u3 where u3.id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select (select 1 from user u1 join user u2 on u1.id = u2.id and u1.id = u3.id) subquery from user u3 where u3.id = 1", "Instructions": { @@ -5572,6 +5733,7 @@ "comment": "SOME modifier on unsharded table works well", "query": "select 1 from unsharded where foo = SOME (select 1 from unsharded_a where foo = 1)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select 1 from unsharded where foo = SOME (select 1 from unsharded_a where foo = 1)", "Instructions": { @@ -5596,6 +5758,7 @@ "comment": "ALL modifier on unsharded table works well", "query": "select 1 from unsharded where foo = ALL (select 1 from unsharded_a where foo = 1)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select 1 from unsharded where foo = ALL (select 1 from unsharded_a where foo = 1)", "Instructions": { @@ -5620,6 +5783,7 @@ "comment": "allow last_insert_id with argument", "query": "select last_insert_id(id) from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select last_insert_id(id) from user", "Instructions": { @@ -5643,6 +5807,7 @@ "comment": "merge subquery using MAX and join into single route", "query": "select 1 from user join music_extra on user.id = music_extra.user_id where music_extra.music_id = (select max(music_id) from music_extra where user_id = user.id)", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select 1 from user join music_extra on user.id = music_extra.user_id where music_extra.music_id = (select max(music_id) from music_extra where user_id = user.id)", "Instructions": { @@ -5667,6 +5832,7 @@ "comment": "Query with non-plannable lookup vindex", "query": "SELECT * FROM user_metadata WHERE user_metadata.non_planable = 'foo'", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "SELECT * FROM user_metadata WHERE user_metadata.non_planable = 'foo'", "Instructions": { @@ -5694,6 +5860,7 @@ "comment": "join query with lookup and join on different vindex column", "query": "select u.id from user u, user_metadata um where u.name = 'foo' and u.id = um.user_id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.id from user u, user_metadata um where u.name = 'foo' and u.id = um.user_id", "Instructions": { @@ -5747,6 +5914,7 @@ "comment": "pick email as vindex lookup", "query": "select * from customer where email = 'a@mail.com'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from customer where email = 'a@mail.com'", "Instructions": { @@ -5798,6 +5966,7 @@ "comment": "phone is in backfill vindex - not selected for vindex lookup", "query": "select * from customer where phone = 123456", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from customer where phone = 123456", "Instructions": { @@ -5820,6 +5989,7 @@ "comment": "name is in backfill vindex - not selected for vindex lookup", "query": "select * from customer where name = 'x'", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from customer where name = 'x'", "Instructions": { @@ -5843,6 +6013,7 @@ "comment": "email vindex is costly than phone vindex - but phone vindex is backfiling hence ignored", "query": "select * from customer where email = 'a@mail.com' and phone = 123456", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from customer where email = 'a@mail.com' and phone = 123456", "Instructions": { @@ -5894,6 +6065,7 @@ "comment": "predicate order changed: email vindex is costly than phone vindex - but phone vindex is backfiling hence ignored", "query": "select * from customer where phone = 123456 and email = 'a@mail.com'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from customer where phone = 123456 and email = 'a@mail.com'", "Instructions": { @@ -5945,6 +6117,7 @@ "comment": "invisible column is not expanded, but valid in predicate", "query": "select * from samecolvin where secret = 12", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from samecolvin where secret = 12", "Instructions": { @@ -5968,6 +6141,7 @@ "comment": "column with qualifier is correctly used", "query": "select u.foo, ue.foo as apa from user u, user_extra ue order by foo ", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u.foo, ue.foo as apa from user u, user_extra ue order by foo ", "Instructions": { @@ -6012,6 +6186,7 @@ "comment": "Derived tables going to a single shard still need to expand derived table columns", "query": "SELECT c.column_name FROM user c JOIN (SELECT table_name FROM unsharded LIMIT 1) AS tables ON tables.table_name = c.table_name", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "SELECT c.column_name FROM user c JOIN (SELECT table_name FROM unsharded LIMIT 1) AS tables ON tables.table_name = c.table_name", "Instructions": { @@ -6058,6 +6233,7 @@ "comment": "column name aliases in outer join queries", "query": "select name as t0, name as t1 from user left outer join user_extra on user.cola = user_extra.cola", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select name as t0, name as t1 from user left outer join user_extra on user.cola = user_extra.cola", "Instructions": { @@ -6114,6 +6290,7 @@ "comment": "Over clause works for unsharded tables", "query": "SELECT val, CUME_DIST() OVER w, ROW_NUMBER() OVER w, DENSE_RANK() OVER w, PERCENT_RANK() OVER w, RANK() OVER w AS 'cd' FROM unsharded_a", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT val, CUME_DIST() OVER w, ROW_NUMBER() OVER w, DENSE_RANK() OVER w, PERCENT_RANK() OVER w, RANK() OVER w AS 'cd' FROM unsharded_a", "Instructions": { @@ -6137,6 +6314,7 @@ "comment": "join with derived table with alias and join condition - merge into route", "query": "select 1 from user join (select id as uid from user) as t where t.uid = user.id", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select 1 from user join (select id as uid from user) as t where t.uid = user.id", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases_with_default.json b/go/vt/vtgate/planbuilder/testdata/select_cases_with_default.json index 146432d9655..6404076a2f4 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases_with_default.json +++ b/go/vt/vtgate/planbuilder/testdata/select_cases_with_default.json @@ -3,6 +3,7 @@ "comment": "EXISTS subquery when the default ks is different than the inner query", "query": "select exists(select * from user where id = 5)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select exists(select * from user where id = 5)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases_with_user_as_default.json b/go/vt/vtgate/planbuilder/testdata/select_cases_with_user_as_default.json index 4d66f913f1d..a59d0e50c18 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases_with_user_as_default.json +++ b/go/vt/vtgate/planbuilder/testdata/select_cases_with_user_as_default.json @@ -3,6 +3,7 @@ "comment": "EXISTS subquery", "query": "select exists(select * from user where id = 5)", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select exists(select * from user where id = 5)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/set_cases.json b/go/vt/vtgate/planbuilder/testdata/set_cases.json index 02c5603a03c..ed485930b77 100644 --- a/go/vt/vtgate/planbuilder/testdata/set_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/set_cases.json @@ -3,6 +3,7 @@ "comment": "set single user defined variable", "query": "set @foo = 42", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @foo = 42", "Instructions": { @@ -26,6 +27,7 @@ "comment": "set multi user defined variable", "query": "set @foo = 42, @bar = @foo", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @foo = 42, @bar = @foo", "Instructions": { @@ -54,6 +56,7 @@ "comment": "set multi user defined variable with complex expression", "query": "set @foo = 42, @bar = @foo + 1", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @foo = 42, @bar = @foo + 1", "Instructions": { @@ -82,6 +85,7 @@ "comment": "set UDV to expression that can't be evaluated at vtgate", "query": "set @foo = SOUNDEX('Hello')", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @foo = SOUNDEX('Hello')", "Instructions": { @@ -112,6 +116,7 @@ "comment": "single sysvar cases", "query": "SET sql_mode = 'STRICT_ALL_TABLES,NO_AUTO_VALUE_ON_ZERO'", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "SET sql_mode = 'STRICT_ALL_TABLES,NO_AUTO_VALUE_ON_ZERO'", "Instructions": { @@ -140,6 +145,7 @@ "comment": "multiple sysvar cases", "query": "SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_safe_updates = 0", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_safe_updates = 0", "Instructions": { @@ -178,6 +184,7 @@ "comment": "autocommit case", "query": "SET autocommit = 1, autocommit = on, autocommit = 'on', autocommit = @myudv, autocommit = `on`, autocommit = `off`", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "SET autocommit = 1, autocommit = on, autocommit = 'on', autocommit = @myudv, autocommit = `on`, autocommit = `off`", "Instructions": { @@ -226,6 +233,7 @@ "comment": "set ignore plan", "query": "set @@default_storage_engine = 'DONOTCHANGEME'", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@default_storage_engine = 'DONOTCHANGEME'", "Instructions": { @@ -249,6 +257,7 @@ "comment": "set check and ignore plan", "query": "set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER')", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER')", "Instructions": { @@ -277,6 +286,7 @@ "comment": "set system settings", "query": "set @@sql_safe_updates = 1", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@sql_safe_updates = 1", "Instructions": { @@ -305,6 +315,7 @@ "comment": "set plan building with ON/OFF enum", "query": "set @@innodb_strict_mode = OFF", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@innodb_strict_mode = OFF", "Instructions": { @@ -328,6 +339,7 @@ "comment": "set plan building with string literal", "query": "set @@innodb_strict_mode = 'OFF'", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@innodb_strict_mode = 'OFF'", "Instructions": { @@ -351,6 +363,7 @@ "comment": "set plan building with string literal", "query": "set @@innodb_tmpdir = 'OFF'", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@innodb_tmpdir = 'OFF'", "Instructions": { @@ -379,6 +392,7 @@ "comment": "set autocommit", "query": "set autocommit = 1", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set autocommit = 1", "Instructions": { @@ -402,6 +416,7 @@ "comment": "set autocommit false", "query": "set autocommit = 0", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set autocommit = 0", "Instructions": { @@ -425,6 +440,7 @@ "comment": "set autocommit with backticks", "query": "set @@session.`autocommit` = 0", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@session.`autocommit` = 0", "Instructions": { @@ -448,6 +464,7 @@ "comment": "more vitess aware settings", "query": "set client_found_rows = off, skip_query_plan_cache = ON, sql_select_limit=20", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set client_found_rows = off, skip_query_plan_cache = ON, sql_select_limit=20", "Instructions": { @@ -481,6 +498,7 @@ "comment": "set autocommit to default", "query": "set @@autocommit = default", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@autocommit = default", "Instructions": { @@ -504,6 +522,7 @@ "comment": "set global autocommit to default", "query": "set global autocommit = off", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set global autocommit = off", "Instructions": { @@ -537,6 +556,7 @@ "comment": "set transaction read only", "query": "set session transaction read only", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set session transaction read only", "Instructions": { @@ -560,6 +580,7 @@ "comment": "set transaction isolation level", "query": "set transaction isolation level read committed", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set transaction isolation level read committed", "Instructions": { @@ -588,6 +609,7 @@ "comment": "set vitess_metadata", "query": "set @@vitess_metadata.app_v1= '1'", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@vitess_metadata.app_v1= '1'", "Instructions": { @@ -610,6 +632,7 @@ "comment": "set last_insert_id with agrument to user defined variable", "query": "set @foo = last_insert_id(1)", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @foo = last_insert_id(1)", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/set_sysvar_disabled_cases.json b/go/vt/vtgate/planbuilder/testdata/set_sysvar_disabled_cases.json index dea7b35ff3e..f38cde5e61c 100644 --- a/go/vt/vtgate/planbuilder/testdata/set_sysvar_disabled_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/set_sysvar_disabled_cases.json @@ -3,6 +3,7 @@ "comment": "set passthrough disabled - check and ignore plan", "query": "set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER'), @@sql_safe_updates = 1", "plan": { + "Type": "Complex", "QueryType": "SET", "Original": "set @@sql_mode = concat(@@sql_mode, ',NO_AUTO_CREATE_USER'), @@sql_safe_updates = 1", "Instructions": { @@ -37,4 +38,4 @@ } } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/show_cases.json b/go/vt/vtgate/planbuilder/testdata/show_cases.json index 00bd37fe8f2..d437c0b1a8d 100644 --- a/go/vt/vtgate/planbuilder/testdata/show_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/show_cases.json @@ -3,6 +3,7 @@ "comment": "Show table status without database name or conditions.", "query": "SHOW table StatUs", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "SHOW table StatUs", "Instructions": { @@ -21,6 +22,7 @@ "comment": "Show Table status with a keyspace name", "query": "SHOW table StatUs from main", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "SHOW table StatUs from main", "Instructions": { @@ -39,6 +41,7 @@ "comment": "Show Table status with a keyspace name using IN", "query": "SHOW table StatUs In main", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "SHOW table StatUs In main", "Instructions": { @@ -57,6 +60,7 @@ "comment": "Show Table status with a keyspace name with a condition", "query": "SHOW table StatUs In user WHERE `Rows` > 70", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "SHOW table StatUs In user WHERE `Rows` > 70", "Instructions": { @@ -75,6 +79,7 @@ "comment": "Show Table status with a Like condition", "query": "SHOW table StatUs LIKe '%a'", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "SHOW table StatUs LIKe '%a'", "Instructions": { @@ -93,6 +98,7 @@ "comment": "show columns from user keyspace", "query": "show full columns from user.user_extra", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show full columns from user.user_extra", "Instructions": { @@ -111,6 +117,7 @@ "comment": "show columns from main keyspace", "query": "show full columns from unsharded", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show full columns from unsharded", "Instructions": { @@ -129,6 +136,7 @@ "comment": "show columns pass as dbname in from clause supersedes the qualifier", "query": "show full columns from user.unsharded from main", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show full columns from user.unsharded from main", "Instructions": { @@ -157,6 +165,7 @@ "comment": "show charset", "query": "show charset", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show charset", "Instructions": { @@ -175,6 +184,7 @@ "comment": "show function", "query": "show function status", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show function status", "Instructions": { @@ -193,6 +203,7 @@ "comment": "show privileges", "query": "show privileges", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show privileges", "Instructions": { @@ -211,6 +222,7 @@ "comment": "show procedure status", "query": "show procedure status", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show procedure status", "Instructions": { @@ -229,6 +241,7 @@ "comment": "show variables", "query": "show variables", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show variables", "Instructions": { @@ -252,6 +265,7 @@ "comment": "show global variables", "query": "show global variables", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show global variables", "Instructions": { @@ -275,6 +289,7 @@ "comment": "show databases", "query": "show databases", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show databases", "Instructions": { @@ -290,6 +305,7 @@ "comment": "show create database", "query": "show create database user", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create database user", "Instructions": { @@ -308,6 +324,7 @@ "comment": "show create database system_schema", "query": "show create database mysql", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create database mysql", "Instructions": { @@ -326,6 +343,7 @@ "comment": "show create procedure", "query": "show create procedure proc", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create procedure proc", "Instructions": { @@ -344,6 +362,7 @@ "comment": "show create procedure from system_schema", "query": "show create procedure information_schema.proc", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create procedure information_schema.proc", "Instructions": { @@ -362,6 +381,7 @@ "comment": "show create table on table present in sharded but as unsharded is selected it goes to unsharded keyspace", "query": "show create table user_extra", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create table user_extra", "Instructions": { @@ -380,6 +400,7 @@ "comment": "show create table with qualifier", "query": "show create table user.user_extra", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create table user.user_extra", "Instructions": { @@ -398,6 +419,7 @@ "comment": "show create table with unsharded as default keyspace", "query": "show create table unknown", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create table unknown", "Instructions": { @@ -421,6 +443,7 @@ "comment": "show create table from system_schema", "query": "show create table information_schema.tables", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show create table information_schema.tables", "Instructions": { @@ -439,6 +462,7 @@ "comment": "show tables", "query": "show tables", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show tables", "Instructions": { @@ -468,6 +492,7 @@ "comment": "show tables from db", "query": "show tables from user", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show tables from user", "Instructions": { @@ -497,6 +522,7 @@ "comment": "show tables from system schema", "query": "show tables from performance_schema", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show tables from performance_schema", "Instructions": { @@ -526,6 +552,7 @@ "comment": "show migrations with db and like", "query": "show vitess_migrations from user like '%format'", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show vitess_migrations from user like '%format'", "Instructions": { @@ -543,6 +570,7 @@ "comment": "show migrations with db and where", "query": "show vitess_migrations from user where id = 5", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show vitess_migrations from user where id = 5", "Instructions": { @@ -560,6 +588,7 @@ "comment": "show vgtid", "query": "show global vgtid_executed", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show global vgtid_executed", "Instructions": { @@ -586,6 +615,7 @@ "comment": "show gtid", "query": "show global gtid_executed from user", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show global gtid_executed from user", "Instructions": { @@ -604,6 +634,7 @@ "comment": "show warnings", "query": "show warnings", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show warnings", "Instructions": { @@ -615,6 +646,7 @@ "comment": "show global status", "query": "show global status", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show global status", "Instructions": { @@ -633,6 +665,7 @@ "comment": "show plugins", "query": "show plugins", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show plugins", "Instructions": { @@ -652,6 +685,7 @@ "comment": "show engines", "query": "show engines", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show engines", "Instructions": { @@ -672,6 +706,7 @@ "comment": "show vitess_shards", "query": "show vitess_shards", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_shards", "Instructions": { @@ -684,6 +719,7 @@ "comment": "show vitess_tablets", "query": "show vitess_tablets", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_tablets", "Instructions": { @@ -696,6 +732,7 @@ "comment": "show vitess_tablets with filter", "query": "show vitess_tablets like '-2%'", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_tablets like '-2%'", "Instructions": { @@ -709,6 +746,7 @@ "comment": "show vschema tables", "query": "show vschema tables", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vschema tables", "Instructions": { @@ -724,6 +762,7 @@ "comment": "show vschema keyspaces", "query": "show vschema keyspaces", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vschema keyspaces", "Instructions": { @@ -742,6 +781,7 @@ "comment": "show vschema vindexes", "query": "show vschema vindexes", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vschema vindexes", "Instructions": { @@ -760,6 +800,7 @@ "comment": "show vschema vindexes on a table", "query": "show vschema vindexes on user.user", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vschema vindexes on user.user", "Instructions": { @@ -778,6 +819,7 @@ "comment": "show vitess target", "query": "show vitess_target", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_target", "Instructions": { @@ -793,6 +835,7 @@ "comment": "show vitess_replication_status", "query": "show vitess_replication_status", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_replication_status", "Instructions": { @@ -805,6 +848,7 @@ "comment": "show vitess_replication_status with filter", "query": "show vitess_replication_status like 'x'", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_replication_status like 'x'", "Instructions": { @@ -818,6 +862,7 @@ "comment": "show vitess_metadata variables", "query": "show vitess_metadata variables", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_metadata variables", "Instructions": { @@ -830,6 +875,7 @@ "comment": "show vitess_metadata variables with filter", "query": "show vitess_metadata variables like 'x'", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show vitess_metadata variables like 'x'", "Instructions": { @@ -843,6 +889,7 @@ "comment": "show transaction status plan", "query": "show transaction status for 'ks:-80:v24s7843sf78934l3'", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show transaction status for 'ks:-80:v24s7843sf78934l3'", "Instructions": { @@ -855,6 +902,7 @@ "comment": "show unresolved transactions for default keyspace", "query": "show unresolved transactions", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show unresolved transactions", "Instructions": { @@ -866,6 +914,7 @@ "comment": "show unresolved transactions for explicitly provided keyspace", "query": "show unresolved transactions for ks", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show unresolved transactions for ks", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.json b/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.json index 72d441c52ea..58d2aef4830 100644 --- a/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.json +++ b/go/vt/vtgate/planbuilder/testdata/show_cases_no_default_keyspace.json @@ -3,6 +3,7 @@ "comment": "show columns from user keyspace", "query": "show full columns from user_extra", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show full columns from user_extra", "Instructions": { @@ -21,6 +22,7 @@ "comment": "show columns from routed table", "query": "show full fields from `route1`", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show full fields from `route1`", "Instructions": { @@ -39,6 +41,7 @@ "comment": "show variables", "query": "show variables", "plan": { + "Type": "Complex", "QueryType": "SHOW", "Original": "show variables", "Instructions": { @@ -62,6 +65,7 @@ "comment": "show full columns from system schema", "query": "show full columns from sys.sys_config", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show full columns from sys.sys_config", "Instructions": { @@ -80,6 +84,7 @@ "comment": "show full columns from system schema replacing qualifier", "query": "show full columns from x.sys_config from sys", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show full columns from x.sys_config from sys", "Instructions": { @@ -98,6 +103,7 @@ "comment": "show global status", "query": "show global status", "plan": { + "Type": "Unknown", "QueryType": "SHOW", "Original": "show global status", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/stream_cases.json b/go/vt/vtgate/planbuilder/testdata/stream_cases.json index e527d668694..54d9507be8d 100644 --- a/go/vt/vtgate/planbuilder/testdata/stream_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/stream_cases.json @@ -3,6 +3,7 @@ "comment": "stream table", "query": "stream * from music", "plan": { + "Type": "Complex", "QueryType": "STREAM", "Original": "stream * from music", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/symtab_cases.json b/go/vt/vtgate/planbuilder/testdata/symtab_cases.json index db9fe66d41e..be042940d67 100644 --- a/go/vt/vtgate/planbuilder/testdata/symtab_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/symtab_cases.json @@ -3,6 +3,7 @@ "comment": "Tests in this file are for testing symtab functionality\n#\n# Column names need not be qualified if they are predefined in vschema and unambiguous.", "query": "select predef2, predef3 from user join unsharded on predef2 = predef3", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select predef2, predef3 from user join unsharded on predef2 = predef3", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/sysschema_default.json b/go/vt/vtgate/planbuilder/testdata/sysschema_default.json index 8b4aa5323cf..d7a480f9cce 100644 --- a/go/vt/vtgate/planbuilder/testdata/sysschema_default.json +++ b/go/vt/vtgate/planbuilder/testdata/sysschema_default.json @@ -3,6 +3,7 @@ "comment": "max_allowed_packet", "query": "select @@max_allowed_packet from dual", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select @@max_allowed_packet from dual", "Instructions": { @@ -25,6 +26,7 @@ "comment": "unqualified table name", "query": "select t.table_schema,t.table_name,c.column_name,c.column_type from tables t join columns c on c.table_schema = t.table_schema and c.table_name = t.table_name where t.table_schema = 'user' and c.table_schema = 'user' order by t.table_schema,t.table_name,c.column_name", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select t.table_schema,t.table_name,c.column_name,c.column_type from tables t join columns c on c.table_schema = t.table_schema and c.table_name = t.table_name where t.table_schema = 'user' and c.table_schema = 'user' order by t.table_schema,t.table_name,c.column_name", "Instructions": { @@ -45,6 +47,7 @@ "comment": "system schema query as a subquery", "query": "SELECT (SELECT 1 FROM information_schema.schemata WHERE schema_name='MyDatabase' LIMIT 1);", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT (SELECT 1 FROM information_schema.schemata WHERE schema_name='MyDatabase' LIMIT 1);", "Instructions": { @@ -68,6 +71,7 @@ "comment": "system schema query as a derived table", "query": "SELECT * from (SELECT 1 FROM information_schema.schemata WHERE schema_name='MyDatabase' LIMIT 1) x", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT * from (SELECT 1 FROM information_schema.schemata WHERE schema_name='MyDatabase' LIMIT 1) x", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/tpcc_cases.json b/go/vt/vtgate/planbuilder/testdata/tpcc_cases.json index f6072bcd9a5..8f0a565967e 100644 --- a/go/vt/vtgate/planbuilder/testdata/tpcc_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/tpcc_cases.json @@ -3,6 +3,7 @@ "comment": "TPC-C select join customer1 and warehouse1", "query": "SELECT c_discount, c_last, c_credit, w_tax FROM customer1 AS c JOIN warehouse1 AS w ON c_w_id=w_id WHERE w_id = 1 AND c_d_id = 15 AND c_id = 10", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT c_discount, c_last, c_credit, w_tax FROM customer1 AS c JOIN warehouse1 AS w ON c_w_id=w_id WHERE w_id = 1 AND c_d_id = 15 AND c_id = 10", "Instructions": { @@ -30,6 +31,7 @@ "comment": "TPC-C select district1 for update", "query": "SELECT d_next_o_id, d_tax FROM district1 WHERE d_w_id = 15 AND d_id = 95 FOR UPDATE", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT d_next_o_id, d_tax FROM district1 WHERE d_w_id = 15 AND d_id = 95 FOR UPDATE", "Instructions": { @@ -56,6 +58,7 @@ "comment": "TPC-C update district1 unique", "query": "UPDATE district1 SET d_next_o_id = 56 WHERE d_id = 9842 AND d_w_id= 8546", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE district1 SET d_next_o_id = 56 WHERE d_id = 9842 AND d_w_id= 8546", "Instructions": { @@ -82,6 +85,7 @@ "comment": "TPC-C insert into orders1", "query": "INSERT INTO orders1 (o_id, o_d_id, o_w_id, o_c_id, o_entry_d, o_ol_cnt, o_all_local) VALUES (334983,59896,99,156,NOW(),781038,'hello')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO orders1 (o_id, o_d_id, o_w_id, o_c_id, o_entry_d, o_ol_cnt, o_all_local) VALUES (334983,59896,99,156,NOW(),781038,'hello')", "Instructions": { @@ -107,6 +111,7 @@ "comment": "TPC-C insert into new_orders1", "query": "INSERT INTO new_orders1 (no_o_id, no_d_id, no_w_id) VALUES (8,9,48)", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO new_orders1 (no_o_id, no_d_id, no_w_id) VALUES (8,9,48)", "Instructions": { @@ -132,6 +137,7 @@ "comment": "TPC-C select unique item1", "query": "SELECT i_price, i_name, i_data FROM item1 WHERE i_id = 9654", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT i_price, i_name, i_data FROM item1 WHERE i_id = 9654", "Instructions": { @@ -158,6 +164,7 @@ "comment": "TPC-C select stock1 for update", "query": "SELECT s_quantity, s_data, s_dist_01 s_dist FROM stock1 WHERE s_i_id = 2198 AND s_w_id = 89 FOR UPDATE", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT s_quantity, s_data, s_dist_01 s_dist FROM stock1 WHERE s_i_id = 2198 AND s_w_id = 89 FOR UPDATE", "Instructions": { @@ -184,6 +191,7 @@ "comment": "TPC-C update stock1", "query": "UPDATE stock1 SET s_quantity = 894 WHERE s_i_id = 156 AND s_w_id= 6", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE stock1 SET s_quantity = 894 WHERE s_i_id = 156 AND s_w_id= 6", "Instructions": { @@ -210,6 +218,7 @@ "comment": "TPC-C insert into order_line1", "query": "INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (648,36812,3201,4946378,3,7,89,1,'info')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO order_line1 (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) VALUES (648,36812,3201,4946378,3,7,89,1,'info')", "Instructions": { @@ -235,6 +244,7 @@ "comment": "TPC-C update warehouse1 unique", "query": "UPDATE warehouse1 SET w_ytd = w_ytd + 946879 WHERE w_id = 3", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE warehouse1 SET w_ytd = w_ytd + 946879 WHERE w_id = 3", "Instructions": { @@ -261,6 +271,7 @@ "comment": "TPC-C select warehouse1 unique", "query": "SELECT w_street_1, w_street_2, w_city, w_state, w_zip, w_name FROM warehouse1 WHERE w_id = 998", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT w_street_1, w_street_2, w_city, w_state, w_zip, w_name FROM warehouse1 WHERE w_id = 998", "Instructions": { @@ -287,6 +298,7 @@ "comment": "TPC-C update district1 unique", "query": "UPDATE district1 SET d_ytd = d_ytd + 2 WHERE d_w_id = 89 AND d_id= 9", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE district1 SET d_ytd = d_ytd + 2 WHERE d_w_id = 89 AND d_id= 9", "Instructions": { @@ -313,6 +325,7 @@ "comment": "TPC-C select district1 unique", "query": "SELECT d_street_1, d_street_2, d_city, d_state, d_zip, d_name FROM district1 WHERE d_w_id = 896 AND d_id = 9", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT d_street_1, d_street_2, d_city, d_state, d_zip, d_name FROM district1 WHERE d_w_id = 896 AND d_id = 9", "Instructions": { @@ -339,6 +352,7 @@ "comment": "TPC-C select aggr from customer1", "query": "SELECT count(c_id) namecnt FROM customer1 WHERE c_w_id = 5 AND c_d_id= 1 AND c_last='last'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT count(c_id) namecnt FROM customer1 WHERE c_w_id = 5 AND c_d_id= 1 AND c_last='last'", "Instructions": { @@ -365,6 +379,7 @@ "comment": "TPC-C select customer1 order by", "query": "SELECT c_id FROM customer1 WHERE c_w_id = 8 AND c_d_id = 5 AND c_last='item_last' ORDER BY c_first", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT c_id FROM customer1 WHERE c_w_id = 8 AND c_d_id = 5 AND c_last='item_last' ORDER BY c_first", "Instructions": { @@ -391,6 +406,7 @@ "comment": "TPC-C select for update customer1 unique", "query": "SELECT c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since FROM customer1 WHERE c_w_id = 8965 AND c_d_id = 1 AND c_id = 9 FOR UPDATE", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since FROM customer1 WHERE c_w_id = 8965 AND c_d_id = 1 AND c_id = 9 FOR UPDATE", "Instructions": { @@ -417,6 +433,7 @@ "comment": "TPC-C select customer1 unique", "query": "SELECT c_data FROM customer1 WHERE c_w_id = 32 AND c_d_id=68 AND c_id = 5", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT c_data FROM customer1 WHERE c_w_id = 32 AND c_d_id=68 AND c_id = 5", "Instructions": { @@ -443,6 +460,7 @@ "comment": "TPC-C update customer1 unique and float value", "query": "UPDATE customer1 SET c_balance=508.98, c_ytd_payment=48941.980301, c_data='i am data' WHERE c_w_id = 20 AND c_d_id=387 AND c_id=98", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE customer1 SET c_balance=508.98, c_ytd_payment=48941.980301, c_data='i am data' WHERE c_w_id = 20 AND c_d_id=387 AND c_id=98", "Instructions": { @@ -469,6 +487,7 @@ "comment": "TPC-C update customer1 unique and float value", "query": "UPDATE customer1 SET c_balance=508.98, c_ytd_payment=48941.980301 WHERE c_w_id = 20 AND c_d_id=387 AND c_id=98", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE customer1 SET c_balance=508.98, c_ytd_payment=48941.980301 WHERE c_w_id = 20 AND c_d_id=387 AND c_id=98", "Instructions": { @@ -495,6 +514,7 @@ "comment": "TPC-C insert into history1", "query": "INSERT INTO history1 (h_c_d_id, h_c_w_id, h_c_id, h_d_id, h_w_id, h_date, h_amount, h_data) VALUES (6809887,38748,8746,210,8,NOW(),8907,'data')", "plan": { + "Type": "Unknown", "QueryType": "INSERT", "Original": "INSERT INTO history1 (h_c_d_id, h_c_w_id, h_c_id, h_d_id, h_w_id, h_date, h_amount, h_data) VALUES (6809887,38748,8746,210,8,NOW(),8907,'data')", "Instructions": { @@ -520,6 +540,7 @@ "comment": "TPC-C select aggr customer1", "query": "SELECT count(c_id) namecnt FROM customer1 WHERE c_w_id = 870 AND c_d_id= 780 AND c_last='last'", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT count(c_id) namecnt FROM customer1 WHERE c_w_id = 870 AND c_d_id= 780 AND c_last='last'", "Instructions": { @@ -546,6 +567,7 @@ "comment": "TPC-C select order by customer1", "query": "SELECT c_balance, c_first, c_middle, c_id FROM customer1 WHERE c_w_id = 840 AND c_d_id= 1 AND c_last='test' ORDER BY c_first", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT c_balance, c_first, c_middle, c_id FROM customer1 WHERE c_w_id = 840 AND c_d_id= 1 AND c_last='test' ORDER BY c_first", "Instructions": { @@ -572,6 +594,7 @@ "comment": "TPC-C select unique customer1", "query": "SELECT c_balance, c_first, c_middle, c_last FROM customer1 WHERE c_w_id = 15 AND c_d_id=5169 AND c_id=1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT c_balance, c_first, c_middle, c_last FROM customer1 WHERE c_w_id = 15 AND c_d_id=5169 AND c_id=1", "Instructions": { @@ -598,6 +621,7 @@ "comment": "TPC-C select order by orders1", "query": "SELECT o_id, o_carrier_id, o_entry_d FROM orders1 WHERE o_w_id = 9894 AND o_d_id = 3 AND o_c_id = 159 ORDER BY o_id DESC", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT o_id, o_carrier_id, o_entry_d FROM orders1 WHERE o_w_id = 9894 AND o_d_id = 3 AND o_c_id = 159 ORDER BY o_id DESC", "Instructions": { @@ -624,6 +648,7 @@ "comment": "TPC-C select order_line1", "query": "SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d FROM order_line1 WHERE ol_w_id = 92 AND ol_d_id = 5 AND ol_o_id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d FROM order_line1 WHERE ol_w_id = 92 AND ol_d_id = 5 AND ol_o_id = 1", "Instructions": { @@ -650,6 +675,7 @@ "comment": "TPC-C select for update new_orders1", "query": "SELECT no_o_id FROM new_orders1 WHERE no_d_id = 689 AND no_w_id = 15 ORDER BY no_o_id ASC LIMIT 1 FOR UPDATE", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT no_o_id FROM new_orders1 WHERE no_d_id = 689 AND no_w_id = 15 ORDER BY no_o_id ASC LIMIT 1 FOR UPDATE", "Instructions": { @@ -676,6 +702,7 @@ "comment": "TPC-C delete new_orders1", "query": "DELETE FROM new_orders1 WHERE no_o_id = 2218 AND no_d_id = 358 AND no_w_id = 98465", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "DELETE FROM new_orders1 WHERE no_o_id = 2218 AND no_d_id = 358 AND no_w_id = 98465", "Instructions": { @@ -702,6 +729,7 @@ "comment": "TPC-C select unique orders1", "query": "SELECT o_c_id FROM orders1 WHERE o_id = 6 AND o_d_id = 1983 AND o_w_id = 894605", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT o_c_id FROM orders1 WHERE o_id = 6 AND o_d_id = 1983 AND o_w_id = 894605", "Instructions": { @@ -728,6 +756,7 @@ "comment": "TPC-C update orders1 unique", "query": "UPDATE orders1 SET o_carrier_id = 9 WHERE o_id = 56 AND o_d_id = 98 AND o_w_id = 897", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE orders1 SET o_carrier_id = 9 WHERE o_id = 56 AND o_d_id = 98 AND o_w_id = 897", "Instructions": { @@ -754,6 +783,7 @@ "comment": "TPC-C update order_line1", "query": "UPDATE order_line1 SET ol_delivery_d = NOW() WHERE ol_o_id = 235 AND ol_d_id = 315 AND ol_w_id = 8", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE order_line1 SET ol_delivery_d = NOW() WHERE ol_o_id = 235 AND ol_d_id = 315 AND ol_w_id = 8", "Instructions": { @@ -780,6 +810,7 @@ "comment": "TPC-C select sum order_line1", "query": "SELECT SUM(ol_amount) sm FROM order_line1 WHERE ol_o_id = 680 AND ol_d_id = 201 AND ol_w_id = 87", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT SUM(ol_amount) sm FROM order_line1 WHERE ol_o_id = 680 AND ol_d_id = 201 AND ol_w_id = 87", "Instructions": { @@ -806,6 +837,7 @@ "comment": "TPC-C update customer1", "query": "UPDATE customer1 SET c_balance = c_balance + 988.01, c_delivery_cnt = c_delivery_cnt + 1 WHERE c_id = 6 AND c_d_id = 5 AND c_w_id = 160", "plan": { + "Type": "Passthrough", "QueryType": "UPDATE", "Original": "UPDATE customer1 SET c_balance = c_balance + 988.01, c_delivery_cnt = c_delivery_cnt + 1 WHERE c_id = 6 AND c_d_id = 5 AND c_w_id = 160", "Instructions": { @@ -832,6 +864,7 @@ "comment": "TPC-C select unique district1", "query": "SELECT d_next_o_id FROM district1 WHERE d_id = 6 AND d_w_id= 21", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT d_next_o_id FROM district1 WHERE d_id = 6 AND d_w_id= 21", "Instructions": { @@ -858,6 +891,7 @@ "comment": "TPC-C select count distinct stock1 join order_line1", "query": "SELECT COUNT(DISTINCT(s.s_i_id)) FROM stock1 AS s JOIN order_line1 AS ol ON ol.ol_w_id=s.s_w_id AND ol.ol_i_id=s.s_i_id WHERE ol.ol_w_id = 12 AND ol.ol_d_id = 1908 AND ol.ol_o_id < 30 AND ol.ol_o_id >= 15 AND s.s_w_id= 12 AND s.s_quantity < 10", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT COUNT(DISTINCT(s.s_i_id)) FROM stock1 AS s JOIN order_line1 AS ol ON ol.ol_w_id=s.s_w_id AND ol.ol_i_id=s.s_i_id WHERE ol.ol_w_id = 12 AND ol.ol_d_id = 1908 AND ol.ol_o_id < 30 AND ol.ol_o_id >= 15 AND s.s_w_id= 12 AND s.s_quantity < 10", "Instructions": { @@ -885,6 +919,7 @@ "comment": "TPC-C select distinct order_line1", "query": "SELECT DISTINCT ol_i_id FROM order_line1 WHERE ol_w_id = 1 AND ol_d_id = 156 AND ol_o_id < 500 AND ol_o_id >= 56", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT DISTINCT ol_i_id FROM order_line1 WHERE ol_w_id = 1 AND ol_d_id = 156 AND ol_o_id < 500 AND ol_o_id >= 56", "Instructions": { @@ -911,6 +946,7 @@ "comment": "TPC-C", "query": "SELECT count(*) FROM stock1 WHERE s_w_id = 1 AND s_i_id = 8 AND s_quantity < 1000", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "SELECT count(*) FROM stock1 WHERE s_w_id = 1 AND s_i_id = 8 AND s_quantity < 1000", "Instructions": { @@ -937,6 +973,7 @@ "comment": "TPC-C select with subquery,aggr,distinct,having,limit", "query": "select o.o_id,o.o_d_id from orders1 o, (select o_c_id,o_w_id,o_d_id,count(distinct o_w_id),o_id from orders1 where o_w_id=1 and o_id > 2100 and o_id < 11153 group by o_c_id,o_d_id,o_w_id having count( distinct o_id) > 1 limit 1) t where t.o_w_id=o.o_w_id and t.o_d_id=o.o_d_id and t.o_c_id=o.o_c_id limit 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select o.o_id,o.o_d_id from orders1 o, (select o_c_id,o_w_id,o_d_id,count(distinct o_w_id),o_id from orders1 where o_w_id=1 and o_id > 2100 and o_id < 11153 group by o_c_id,o_d_id,o_w_id having count( distinct o_id) > 1 limit 1) t where t.o_w_id=o.o_w_id and t.o_d_id=o.o_d_id and t.o_c_id=o.o_c_id limit 1", "Instructions": { @@ -963,6 +1000,7 @@ "comment": "TPC-C delete order_line1", "query": "DELETE FROM order_line1 where ol_w_id=178 AND ol_d_id=1 AND ol_o_id=84", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "DELETE FROM order_line1 where ol_w_id=178 AND ol_d_id=1 AND ol_o_id=84", "Instructions": { @@ -989,6 +1027,7 @@ "comment": "TPC-C delete orders1", "query": "DELETE FROM orders1 where o_w_id=1 AND o_d_id=3 and o_id=384", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "DELETE FROM orders1 where o_w_id=1 AND o_d_id=3 and o_id=384", "Instructions": { @@ -1015,6 +1054,7 @@ "comment": "TPC-C delete history1", "query": "DELETE FROM history1 where h_w_id=75 AND h_d_id=102 LIMIT 10", "plan": { + "Type": "Passthrough", "QueryType": "DELETE", "Original": "DELETE FROM history1 where h_w_id=75 AND h_d_id=102 LIMIT 10", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/tpch_cases.json b/go/vt/vtgate/planbuilder/testdata/tpch_cases.json index 6b3f84d01d6..60e6857d53d 100644 --- a/go/vt/vtgate/planbuilder/testdata/tpch_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/tpch_cases.json @@ -3,6 +3,7 @@ "comment": "TPC-H query 1", "query": "select l_returnflag, l_linestatus, sum(l_quantity) as sum_qty, sum(l_extendedprice) as sum_base_price, sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, avg(l_quantity) as avg_qty, avg(l_extendedprice) as avg_price, avg(l_discount) as avg_disc, count(*) as count_order from lineitem where l_shipdate <= '1998-12-01' - interval '108' day group by l_returnflag, l_linestatus order by l_returnflag, l_linestatus", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select l_returnflag, l_linestatus, sum(l_quantity) as sum_qty, sum(l_extendedprice) as sum_base_price, sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, avg(l_quantity) as avg_qty, avg(l_extendedprice) as avg_price, avg(l_discount) as avg_disc, count(*) as count_order from lineitem where l_shipdate <= '1998-12-01' - interval '108' day group by l_returnflag, l_linestatus order by l_returnflag, l_linestatus", "Instructions": { @@ -56,6 +57,7 @@ "comment": "TPC-H query 3", "query": "select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date('1995-03-15') and l_shipdate > date('1995-03-15') group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date('1995-03-15') and l_shipdate > date('1995-03-15') group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10", "Instructions": { @@ -187,6 +189,7 @@ "comment": "TPC-H query 4", "query": "select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date('1993-07-01') and o_orderdate < date('1993-07-01') + interval '3' month and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date('1993-07-01') and o_orderdate < date('1993-07-01') + interval '3' month and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority", "Instructions": { @@ -271,6 +274,7 @@ "comment": "TPC-H query 5", "query": "select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey and l_suppkey = s_suppkey and c_nationkey = s_nationkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'ASIA' and o_orderdate >= date('1994-01-01') and o_orderdate < date('1994-01-01') + interval '1' year group by n_name order by revenue desc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey and l_suppkey = s_suppkey and c_nationkey = s_nationkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'ASIA' and o_orderdate >= date('1994-01-01') and o_orderdate < date('1994-01-01') + interval '1' year group by n_name order by revenue desc", "Instructions": { @@ -525,6 +529,7 @@ "comment": "TPC-H query 6", "query": "select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24", "Instructions": { @@ -554,6 +559,7 @@ "comment": "TPC-H query 7", "query": "select supp_nation, cust_nation, l_year, sum(volume) as revenue from (select n1.n_name as supp_nation, n2.n_name as cust_nation, extract(year from l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume from supplier, lineitem, orders, customer, nation n1, nation n2 where s_suppkey = l_suppkey and o_orderkey = l_orderkey and c_custkey = o_custkey and s_nationkey = n1.n_nationkey and c_nationkey = n2.n_nationkey and ((n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')) and l_shipdate between date('1995-01-01') and date('1996-12-31')) as shipping group by supp_nation, cust_nation, l_year order by supp_nation, cust_nation, l_year", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select supp_nation, cust_nation, l_year, sum(volume) as revenue from (select n1.n_name as supp_nation, n2.n_name as cust_nation, extract(year from l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume from supplier, lineitem, orders, customer, nation n1, nation n2 where s_suppkey = l_suppkey and o_orderkey = l_orderkey and c_custkey = o_custkey and s_nationkey = n1.n_nationkey and c_nationkey = n2.n_nationkey and ((n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')) and l_shipdate between date('1995-01-01') and date('1996-12-31')) as shipping group by supp_nation, cust_nation, l_year order by supp_nation, cust_nation, l_year", "Instructions": { @@ -786,6 +792,7 @@ "comment": "TPC-H query 8", "query": "select o_year, sum(case when nation = 'BRAZIL' then volume else 0 end) / sum(volume) as mkt_share from ( select extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) as volume, n2.n_name as nation from part, supplier, lineitem, orders, customer, nation n1, nation n2, region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey and o_orderdate between date '1995-01-01' and date('1996-12-31') and p_type = 'ECONOMY ANODIZED STEEL' ) as all_nations group by o_year order by o_year", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select o_year, sum(case when nation = 'BRAZIL' then volume else 0 end) / sum(volume) as mkt_share from ( select extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) as volume, n2.n_name as nation from part, supplier, lineitem, orders, customer, nation n1, nation n2, region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey and o_orderdate between date '1995-01-01' and date('1996-12-31') and p_type = 'ECONOMY ANODIZED STEEL' ) as all_nations group by o_year order by o_year", "Instructions": { @@ -1070,6 +1077,7 @@ "comment": "TPC-H query 9", "query": "select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey = l_suppkey and ps_suppkey = l_suppkey and ps_partkey = l_partkey and p_partkey = l_partkey and o_orderkey = l_orderkey and s_nationkey = n_nationkey and p_name like '%green%' ) as profit group by nation, o_year order by nation, o_year desc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey = l_suppkey and ps_suppkey = l_suppkey and ps_partkey = l_partkey and p_partkey = l_partkey and o_orderkey = l_orderkey and s_nationkey = n_nationkey and p_name like '%green%' ) as profit group by nation, o_year order by nation, o_year desc", "Instructions": { @@ -1334,6 +1342,7 @@ "comment": "TPC-H query 10", "query": "select c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue, c_acctbal, n_name, c_address, c_phone, c_comment from customer, orders, lineitem, nation where c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate >= date('1993-10-01') and o_orderdate < date('1993-10-01') + interval '3' month and l_returnflag = 'R' and c_nationkey = n_nationkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc limit 20", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue, c_acctbal, n_name, c_address, c_phone, c_comment from customer, orders, lineitem, nation where c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate >= date('1993-10-01') and o_orderdate < date('1993-10-01') + interval '3' month and l_returnflag = 'R' and c_nationkey = n_nationkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc limit 20", "Instructions": { @@ -1544,6 +1553,7 @@ "comment": "TPC-H query 11", "query": "select ps_partkey, sum(ps_supplycost * ps_availqty) as value from partsupp, supplier, nation where ps_suppkey = s_suppkey and s_nationkey = n_nationkey and n_name = 'GERMANY' group by ps_partkey having sum(ps_supplycost * ps_availqty) > ( select sum(ps_supplycost * ps_availqty) * 0.00001000000 from partsupp, supplier, nation where ps_suppkey = s_suppkey and s_nationkey = n_nationkey and n_name = 'GERMANY' ) order by value desc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select ps_partkey, sum(ps_supplycost * ps_availqty) as value from partsupp, supplier, nation where ps_suppkey = s_suppkey and s_nationkey = n_nationkey and n_name = 'GERMANY' group by ps_partkey having sum(ps_supplycost * ps_availqty) > ( select sum(ps_supplycost * ps_availqty) * 0.00001000000 from partsupp, supplier, nation where ps_suppkey = s_suppkey and s_nationkey = n_nationkey and n_name = 'GERMANY' ) order by value desc", "Instructions": { @@ -1772,6 +1782,7 @@ "comment": "TPC-H query 12", "query": "select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in ('MAIL', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date('1994-01-01') and l_receiptdate < date('1994-01-01') + interval '1' year group by l_shipmode order by l_shipmode", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in ('MAIL', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date('1994-01-01') and l_receiptdate < date('1994-01-01') + interval '1' year group by l_shipmode order by l_shipmode", "Instructions": { @@ -1873,6 +1884,7 @@ "comment": "TPC-H query 13", "query": "select c_count, count(*) as custdist from ( select c_custkey, count(o_orderkey) from customer left outer join orders on c_custkey = o_custkey and o_comment not like '%special%requests%' group by c_custkey ) as c_orders(c_custkey, c_count) group by c_count order by custdist desc, c_count desc", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select c_count, count(*) as custdist from ( select c_custkey, count(o_orderkey) from customer left outer join orders on c_custkey = o_custkey and o_comment not like '%special%requests%' group by c_custkey ) as c_orders(c_custkey, c_count) group by c_count order by custdist desc, c_count desc", "Instructions": { @@ -1968,6 +1980,7 @@ "comment": "TPC-H query 14", "query": "select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= date('1995-09-01') and l_shipdate < date('1995-09-01') + interval '1' month", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= date('1995-09-01') and l_shipdate < date('1995-09-01') + interval '1' month", "Instructions": { @@ -2044,6 +2057,7 @@ "comment": "TPC-H query 15", "query": "select s_suppkey, s_name, s_address, s_phone, total_revenue from supplier, revenue0 where s_suppkey = supplier_no and total_revenue = ( select max(total_revenue) from revenue0 ) order by s_suppkey", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select s_suppkey, s_name, s_address, s_phone, total_revenue from supplier, revenue0 where s_suppkey = supplier_no and total_revenue = ( select max(total_revenue) from revenue0 ) order by s_suppkey", "Instructions": { @@ -2098,6 +2112,7 @@ "comment": "TPC-H query 16", "query": "select p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt from partsupp, part where p_partkey = ps_partkey and p_brand <> 'Brand#45' and p_type not like 'MEDIUM POLISHED%' and p_size in (49, 14, 23, 45, 19, 3, 36, 9) and ps_suppkey not in ( select s_suppkey from supplier where s_comment like '%Customer%Complaints%' ) group by p_brand, p_type, p_size order by supplier_cnt desc, p_brand, p_type, p_size", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt from partsupp, part where p_partkey = ps_partkey and p_brand <> 'Brand#45' and p_type not like 'MEDIUM POLISHED%' and p_size in (49, 14, 23, 45, 19, 3, 36, 9) and ps_suppkey not in ( select s_suppkey from supplier where s_comment like '%Customer%Complaints%' ) group by p_brand, p_type, p_size order by supplier_cnt desc, p_brand, p_type, p_size", "Instructions": { @@ -2200,6 +2215,7 @@ "comment": "TPC-H query 18", "query": "select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 300 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate limit 100", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 300 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate limit 100", "Instructions": { @@ -2363,6 +2379,7 @@ "comment": "TPC-H query 19", "query": "select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey = l_partkey and p_brand = 'Brand#12' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 1 and l_quantity <= 1 + 10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#23' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 10 and l_quantity <= 10 + 10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#34' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 20 and l_quantity <= 20 + 10 and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' )", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey = l_partkey and p_brand = 'Brand#12' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 1 and l_quantity <= 1 + 10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#23' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 10 and l_quantity <= 10 + 10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#34' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 20 and l_quantity <= 20 + 10 and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' )", "Instructions": { @@ -2431,6 +2448,7 @@ "comment": "TPC-H query 21", "query": "select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where s_suppkey = l1.l_suppkey and o_orderkey = l1.l_orderkey and o_orderstatus = 'F' and l1.l_receiptdate > l1.l_commitdate and exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) and not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey <> l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate ) and s_nationkey = n_nationkey and n_name = 'SAUDI ARABIA' group by s_name order by numwait desc, s_name limit 100", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where s_suppkey = l1.l_suppkey and o_orderkey = l1.l_orderkey and o_orderstatus = 'F' and l1.l_receiptdate > l1.l_commitdate and exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) and not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey <> l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate ) and s_nationkey = n_nationkey and n_name = 'SAUDI ARABIA' group by s_name order by numwait desc, s_name limit 100", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/transaction_cases.json b/go/vt/vtgate/planbuilder/testdata/transaction_cases.json index eb27ad51b43..63144d421b8 100644 --- a/go/vt/vtgate/planbuilder/testdata/transaction_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/transaction_cases.json @@ -3,6 +3,7 @@ "comment": "Begin", "query": "begin", "plan": { + "Type": "Complex", "QueryType": "BEGIN", "Original": "begin" } @@ -11,6 +12,7 @@ "comment": "Start Transaction", "query": "start transaction", "plan": { + "Type": "Complex", "QueryType": "BEGIN", "Original": "start transaction" } @@ -19,6 +21,7 @@ "comment": "Commit", "query": "commit", "plan": { + "Type": "Complex", "QueryType": "COMMIT", "Original": "commit" } @@ -27,6 +30,7 @@ "comment": "Rollback", "query": "rollback", "plan": { + "Type": "Complex", "QueryType": "ROLLBACK", "Original": "rollback" } @@ -35,6 +39,7 @@ "comment": "Savepoint", "query": "savepoint a", "plan": { + "Type": "Complex", "QueryType": "SAVEPOINT", "Original": "savepoint a" } @@ -43,6 +48,7 @@ "comment": "Savepoint rollback", "query": "rollback work to savepoint a", "plan": { + "Type": "Complex", "QueryType": "SAVEPOINT_ROLLBACK", "Original": "rollback work to savepoint a" } @@ -51,6 +57,7 @@ "comment": "Savepoint release", "query": "release savepoint a", "plan": { + "Type": "Complex", "QueryType": "RELEASE", "Original": "release savepoint a" } diff --git a/go/vt/vtgate/planbuilder/testdata/union_cases.json b/go/vt/vtgate/planbuilder/testdata/union_cases.json index 2927c1c6093..ff64194333c 100644 --- a/go/vt/vtgate/planbuilder/testdata/union_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/union_cases.json @@ -3,6 +3,7 @@ "comment": "union all between two scatter selects", "query": "select id from user union all select id from music", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user union all select id from music", "Instructions": { @@ -26,6 +27,7 @@ "comment": "union distinct between two scatter selects", "query": "select id from user union select id from music", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user union select id from music", "Instructions": { @@ -58,6 +60,7 @@ "comment": "union all between two SelectEqualUnique", "query": "select id from user where id = 1 union all select id from user where id = 5", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user where id = 1 union all select id from user where id = 5", "Instructions": { @@ -104,6 +107,7 @@ "comment": "almost dereks query - two queries with order by and limit being scattered to two different sets of tablets", "query": "(SELECT id FROM user ORDER BY id DESC LIMIT 1) UNION ALL (SELECT id FROM music ORDER BY id DESC LIMIT 1)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(SELECT id FROM user ORDER BY id DESC LIMIT 1) UNION ALL (SELECT id FROM music ORDER BY id DESC LIMIT 1)", "Instructions": { @@ -166,6 +170,7 @@ "comment": "Union all", "query": "select col1, col2 from user union all select col1, col2 from user_extra", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col1, col2 from user union all select col1, col2 from user_extra", "Instructions": { @@ -189,6 +194,7 @@ "comment": "union operations in subqueries (FROM)", "query": "select * from (select * from user union all select * from user_extra) as t", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select * from (select * from user union all select * from user_extra) as t", "Instructions": { @@ -212,6 +218,7 @@ "comment": "union operations in derived table, without star expression (FROM)ยก", "query": "select col1,col2 from (select col1, col2 from user union all select col1, col2 from user_extra) as t", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select col1,col2 from (select col1, col2 from user union all select col1, col2 from user_extra) as t", "Instructions": { @@ -235,6 +242,7 @@ "comment": "union all between two scatter selects, with order by", "query": "(select id from user order by id limit 5) union all (select id from music order by id desc limit 5)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(select id from user order by id limit 5) union all (select id from music order by id desc limit 5)", "Instructions": { @@ -297,6 +305,7 @@ "comment": "union all on scatter and single route", "query": "select id from user where id = 1 union select id from user where id = 1 union all select id from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select id from user where id = 1 union select id from user where id = 1 union all select id from user", "Instructions": { @@ -319,6 +328,7 @@ "comment": "union of information_schema with normal table", "query": "select CHARACTER_SET_NAME from information_schema.CHARACTER_SETS union select user_name from unsharded", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select CHARACTER_SET_NAME from information_schema.CHARACTER_SETS union select user_name from unsharded", "Instructions": { @@ -371,6 +381,7 @@ "comment": "multi-shard union", "query": "(select id from user union select id from music) union select 1 from dual", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(select id from user union select id from music) union select 1 from dual", "Instructions": { @@ -403,6 +414,7 @@ "comment": "union with the same target shard because of vindex", "query": "select * from music where user_id = 1 union select * from user where id = 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from music where user_id = 1 union select * from user where id = 1", "Instructions": { @@ -435,6 +447,7 @@ "comment": "union with different target shards", "query": "select 1 from music where id = 1 union select 1 from music where id = 2", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from music where id = 1 union select 1 from music where id = 2", "Instructions": { @@ -539,6 +552,7 @@ "comment": "multiple select statement have inner order by with union - TODO (systay) no need to send down ORDER BY if we are going to loose it with UNION DISTINCT", "query": "(select id from user order by 1 desc) union (select id from user order by 1 asc)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(select id from user order by 1 desc) union (select id from user order by 1 asc)", "Instructions": { @@ -570,6 +584,7 @@ "comment": "multiple unions", "query": "select 1 union select null union select 1.0 union select '1' union select 2 union select 2.0 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 union select null union select 1.0 union select '1' union select 2 union select 2.0 from user", "Instructions": { @@ -601,6 +616,7 @@ "comment": "union distinct between a scatter query and a join (other side)", "query": "(select user.id, user.name from user join user_extra where user_extra.extra = 'asdf') union select 'b','c' from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(select user.id, user.name from user join user_extra where user_extra.extra = 'asdf') union select 'b','c' from user", "Instructions": { @@ -669,6 +685,7 @@ "comment": "union distinct between a scatter query and a join (other side)", "query": "select 'b','c' from user union (select user.id, user.name from user join user_extra where user_extra.extra = 'asdf')", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 'b','c' from user union (select user.id, user.name from user join user_extra where user_extra.extra = 'asdf')", "Instructions": { @@ -737,6 +754,7 @@ "comment": "unmergable because we are using aggregation", "query": "select count(*) as s from user union select count(*) as s from music", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select count(*) as s from user union select count(*) as s from music", "Instructions": { @@ -798,6 +816,7 @@ "comment": "Union in derived table with first SELECT being an UNION", "query": "select * from ((select id from user union select id+1 from user) union select user_id from user_extra) as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from ((select id from user union select id+1 from user) union select user_id from user_extra) as t", "Instructions": { @@ -830,6 +849,7 @@ "comment": "gen4 optimises away ORDER BY when it's safe to do", "query": "(select id from user union select id from music order by id) union select 1 from unsharded", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "(select id from user union select id from music order by id) union select 1 from unsharded", "Instructions": { @@ -879,6 +899,7 @@ "comment": "push down the ::upper_limit to the sources, since we are doing DISTINCT on them, it's safe", "query": "select id from user union select 3 limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user union select 3 limit 10", "Instructions": { @@ -916,6 +937,7 @@ "comment": "silly query that should be collapsed into a single unsharded UNION route", "query": "(select 1 from unsharded union select 1 from unsharded union all select 1 from unsharded order by 1) union select 1 from unsharded union all select 1 from unsharded order by 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "(select 1 from unsharded union select 1 from unsharded union all select 1 from unsharded order by 1) union select 1 from unsharded union all select 1 from unsharded order by 1", "Instructions": { @@ -938,6 +960,7 @@ "comment": "test handling of TEXT column type handling", "query": "select table_comment from information_schema.tables union select table_comment from information_schema.tables", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select table_comment from information_schema.tables union select table_comment from information_schema.tables", "Instructions": { @@ -981,6 +1004,7 @@ "comment": "UNION that needs to be reordered to be merged more aggressively. Gen4 is able to get it down to 2 routes", "query": "select col from unsharded union select id from user union select col2 from unsharded union select col from user_extra", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col from unsharded union select id from user union select col2 from unsharded union select col from user_extra", "Instructions": { @@ -1030,6 +1054,7 @@ "comment": "derived table with union", "query": "select tbl2.id FROM ((select id from user order by id limit 5) union all (select id from user order by id desc limit 5)) as tbl1 INNER JOIN user as tbl2 ON tbl1.id = tbl2.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select tbl2.id FROM ((select id from user order by id limit 5) union all (select id from user order by id desc limit 5)) as tbl1 INNER JOIN user as tbl2 ON tbl1.id = tbl2.id", "Instructions": { @@ -1128,6 +1153,7 @@ "comment": "union with invalid order by clause with table qualifier", "query": "select id from user union select 3 order by id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id from user union select 3 order by id", "Instructions": { @@ -1168,6 +1194,7 @@ "comment": "Conflicting column names in union", "query": "select id, id from user union select id, bar from user_extra order by 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, id from user union select id, bar from user_extra order by 1", "Instructions": { @@ -1209,6 +1236,7 @@ "comment": "select 1 from (select id+42 as foo from user union select 1+id as foo from unsharded) as t", "query": "select 1 from (select id+42 as foo from user union select 1+id as foo from unsharded) as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from (select id+42 as foo from user union select 1+id as foo from unsharded) as t", "Instructions": { @@ -1264,6 +1292,7 @@ "comment": "systable union query in derived table with constraint on outside (without star projection)", "query": "select * from (select kcu.`COLUMN_NAME` from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select kcu.`COLUMN_NAME` from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `COLUMN_NAME` = 'primary'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from (select kcu.`COLUMN_NAME` from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select kcu.`COLUMN_NAME` from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `COLUMN_NAME` = 'primary'", "Instructions": { @@ -1317,6 +1346,7 @@ "comment": "pushes predicate on both sides of UNION", "query": "select * from (select name, id as foo from user union select 'extra', user_id from user_extra) X where X.foo = 3", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "select * from (select name, id as foo from user union select 'extra', user_id from user_extra) X where X.foo = 3", "Instructions": { @@ -1344,6 +1374,7 @@ "comment": "systable union query in derived table with constraint on outside (star projection)", "query": "select * from (select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `constraint_name` = 'primary'", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from (select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `constraint_name` = 'primary'", "Instructions": { @@ -1408,6 +1439,7 @@ "comment": "unknown columns are OK as long as the whole query is unsharded", "query": "(SELECT * FROM (SELECT * FROM unsharded WHERE branchId = 203622 AND buildNumber <= 113893 AND state = 'FAILED' ORDER BY buildNumber DESC LIMIT 1) AS last_failed) UNION ALL (SELECT * FROM (SELECT * FROM unsharded WHERE branchId = 203622 AND buildNumber <= 113893 AND state = 'SUCCEEDED' ORDER BY buildNumber DESC LIMIT 1) AS last_succeeded) ORDER BY buildNumber DESC LIMIT 1", "plan": { + "Type": "Passthrough", "QueryType": "SELECT", "Original": "(SELECT * FROM (SELECT * FROM unsharded WHERE branchId = 203622 AND buildNumber <= 113893 AND state = 'FAILED' ORDER BY buildNumber DESC LIMIT 1) AS last_failed) UNION ALL (SELECT * FROM (SELECT * FROM unsharded WHERE branchId = 203622 AND buildNumber <= 113893 AND state = 'SUCCEEDED' ORDER BY buildNumber DESC LIMIT 1) AS last_succeeded) ORDER BY buildNumber DESC LIMIT 1", "Instructions": { @@ -1430,6 +1462,7 @@ "comment": "union of unsharded route with sharded join with involvement of weight string", "query": "select id, foo, bar from unsharded union select user.intcol, user.textcol2, authoritative.col2 from user join authoritative", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, foo, bar from unsharded union select user.intcol, user.textcol2, authoritative.col2 from user join authoritative", "Instructions": { @@ -1500,6 +1533,7 @@ "comment": "UNION ALL with repeating column on the LHS", "query": "select foo, foo, foo from user union all select bar, baz, toto from music", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select foo, foo, foo from user union all select bar, baz, toto from music", "Instructions": { @@ -1523,6 +1557,7 @@ "comment": "UNION ALL with repeating column on the RHS", "query": "select bar, baz, toto from music union all select foo, foo, foo from user", "plan": { + "Type": "Scatter", "QueryType": "SELECT", "Original": "select bar, baz, toto from music union all select foo, foo, foo from user", "Instructions": { @@ -1546,6 +1581,7 @@ "comment": "UNION with repeating column on the RHS", "query": "select bar, baz, toto from music union select foo, foo, foo from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select bar, baz, toto from music union select foo, foo, foo from user", "Instructions": { @@ -1580,6 +1616,7 @@ "comment": "UNION with repeating column on the LHS", "query": "select foo, foo, foo from user union select bar, baz, toto from music", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select foo, foo, foo from user union select bar, baz, toto from music", "Instructions": { @@ -1614,6 +1651,7 @@ "comment": "join between two derived tables containing UNION", "query": "select * from (select foo from user where bar = 12 union select foo from user where bar = 134) as t1 join (select bar from music where foo = 12 union select bar from music where foo = 1234) as t2 on t1.foo = t2.bar", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select * from (select foo from user where bar = 12 union select foo from user where bar = 134) as t1 join (select bar from music where foo = 12 union select bar from music where foo = 1234) as t2 on t1.foo = t2.bar", "Instructions": { @@ -1675,6 +1713,7 @@ "comment": "Select literals from table union Select literals from table", "query": "SELECT 1 from user UNION SELECT 2 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "SELECT 1 from user UNION SELECT 2 from user", "Instructions": { @@ -1705,6 +1744,7 @@ "comment": "Select column from table union Select literals from table", "query": "select col1 from user union select 3 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select col1 from user union select 3 from user", "Instructions": { @@ -1735,6 +1775,7 @@ "comment": "Select literals from table union Select column from table", "query": "select 3 from user union select col1 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 3 from user union select col1 from user", "Instructions": { @@ -1765,6 +1806,7 @@ "comment": "Select literals from table union Select now() from table", "query": "select 3 from user union select now() from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 3 from user union select now() from user", "Instructions": { @@ -1795,6 +1837,7 @@ "comment": "Select now() from table union Select literals from table", "query": "select now() from user union select 3 from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select now() from user union select 3 from user", "Instructions": { @@ -1825,6 +1868,7 @@ "comment": "Select now() from table union Select column from table", "query": "select now() from user union select id from user", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select now() from user union select id from user", "Instructions": { @@ -1855,6 +1899,7 @@ "comment": "Literals in UNION can be problematic", "query": "select 'a' as type, 0 as id from user group by 2 union all select 'c' as type, 0 as id from user_extra as t", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 'a' as type, 0 as id from user group by 2 union all select 'c' as type, 0 as id from user_extra as t", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/use_cases.json b/go/vt/vtgate/planbuilder/testdata/use_cases.json index 0995c4792ea..62b85326630 100644 --- a/go/vt/vtgate/planbuilder/testdata/use_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/use_cases.json @@ -3,6 +3,7 @@ "comment": "use db", "query": "use ks", "plan": { + "Type": "Complex", "QueryType": "USE", "Original": "use ks", "Instructions": { @@ -15,6 +16,7 @@ "comment": "use db tablet", "query": "use ks@replica", "plan": { + "Type": "Complex", "QueryType": "USE", "Original": "use ks@replica", "Instructions": { @@ -27,6 +29,7 @@ "comment": "use db target with :", "query": "use `ks:-80@replica`", "plan": { + "Type": "Complex", "QueryType": "USE", "Original": "use `ks:-80@replica`", "Instructions": { @@ -39,6 +42,7 @@ "comment": "use db target with /", "query": "use `ks/80-@replica`", "plan": { + "Type": "Complex", "QueryType": "USE", "Original": "use `ks/80-@replica`", "Instructions": { @@ -51,6 +55,7 @@ "comment": "reset db", "query": "use", "plan": { + "Type": "Complex", "QueryType": "USE", "Original": "use", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/vexplain_cases.json b/go/vt/vtgate/planbuilder/testdata/vexplain_cases.json index cafdc2851af..0d8da046cca 100644 --- a/go/vt/vtgate/planbuilder/testdata/vexplain_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/vexplain_cases.json @@ -3,6 +3,7 @@ "comment": "vexplain json", "query": "vexplain plan select * from user", "plan": { + "Type": "Complex", "QueryType": "EXPLAIN", "Original": "vexplain plan select * from user", "Instructions": { @@ -18,6 +19,7 @@ "comment": "vexplain queries", "query": "vexplain QUERIES select * from user", "plan": { + "Type": "Complex", "QueryType": "EXPLAIN", "Original": "vexplain QUERIES select * from user", "Instructions": { @@ -46,6 +48,7 @@ "comment": "vexplain table", "query": "vexplain ALL select * from user", "plan": { + "Type": "Complex", "QueryType": "EXPLAIN", "Original": "vexplain ALL select * from user", "Instructions": { @@ -74,6 +77,7 @@ "comment": "vexplain keys", "query": "vexplain keys select * from user", "plan": { + "Type": "Complex", "QueryType": "EXPLAIN", "Original": "vexplain keys select * from user", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/view_cases.json b/go/vt/vtgate/planbuilder/testdata/view_cases.json index 5d5dcd81a33..e545699278f 100644 --- a/go/vt/vtgate/planbuilder/testdata/view_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/view_cases.json @@ -3,6 +3,7 @@ "comment": "Alter View", "query": "alter view user.user_extra as select * from user.user", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "alter view user.user_extra as select * from user.user", "Instructions": { @@ -27,6 +28,7 @@ "comment": "create view with authoritative columns", "query": "create view user.view_ac as select * from authoritative", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "create view user.view_ac as select * from authoritative", "Instructions": { @@ -46,6 +48,7 @@ "comment": "Drop view", "query": "drop view main.a", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "drop view main.a", "Instructions": { @@ -65,6 +68,7 @@ "comment": "Drop multiple view", "query": "drop view main.a, main.b, main.c", "plan": { + "Type": "Unknown", "QueryType": "DDL", "Original": "drop view main.a, main.b, main.c", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.json b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.json index 3ac35761051..8f171b421e4 100644 --- a/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/vindex_func_cases.json @@ -3,6 +3,7 @@ "comment": "vindex func read all cols", "query": "select id, keyspace_id, range_start, range_end, hex_keyspace_id, shard from user_index where id = :id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, keyspace_id, range_start, range_end, hex_keyspace_id, shard from user_index where id = :id", "Instructions": { @@ -36,6 +37,7 @@ "comment": "vindex func select *", "query": "select * from user_index where id = :id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select * from user_index where id = :id", "Instructions": { @@ -69,6 +71,7 @@ "comment": "vindex func read with id repeated", "query": "select id, keyspace_id, id from user_index where id = :id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, keyspace_id, id from user_index where id = :id", "Instructions": { @@ -110,6 +113,7 @@ "comment": "disambiguated vindex reference", "query": "select id, keyspace_id, id from second_user.hash_dup where id = :id", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select id, keyspace_id, id from second_user.hash_dup where id = :id", "Instructions": { @@ -146,6 +150,7 @@ "comment": "You can even join with a vindexFunc primitive", "query": "select user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id", "Instructions": { @@ -189,6 +194,7 @@ "comment": "Join vindexFunc on RHS", "query": "select user_index.keyspace_id, unsharded.id from unsharded join user_index where user_index.id = :id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_index.keyspace_id, unsharded.id from unsharded join user_index where user_index.id = :id", "Instructions": { @@ -232,6 +238,7 @@ "comment": "Join with vindexFunc on a column of it, already present in select list", "query": "select user_index.id, user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_index.id, user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "Instructions": { @@ -280,6 +287,7 @@ "comment": "Join with vindexFunc on a column of it, already present at the end of the select list", "query": "select user_index.keyspace_id, user_index.id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_index.keyspace_id, user_index.id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "Instructions": { @@ -328,6 +336,7 @@ "comment": "Join with vindexFunc on a column of it, not present in select list", "query": "select user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select user_index.keyspace_id, unsharded.id from user_index join unsharded where user_index.id = :id and unsharded.id = user_index.id", "Instructions": { @@ -376,6 +385,7 @@ "comment": "Join with aliased table name", "query": "select ui.keyspace_id, unsharded.id from user_index ui join unsharded where ui.id = :id and unsharded.id = ui.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select ui.keyspace_id, unsharded.id from user_index ui join unsharded where ui.id = :id and unsharded.id = ui.id", "Instructions": { diff --git a/go/vt/vtgate/planbuilder/testdata/wireup_cases.json b/go/vt/vtgate/planbuilder/testdata/wireup_cases.json index 62a3e65a35f..2848da4fb21 100644 --- a/go/vt/vtgate/planbuilder/testdata/wireup_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/wireup_cases.json @@ -3,6 +3,7 @@ "comment": "join on having clause", "query": "select e.col, u.id uid, e.id eid from user u join user_extra e having uid = eid", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select e.col, u.id uid, e.id eid from user u join user_extra e having uid = eid", "Instructions": { @@ -52,6 +53,7 @@ "comment": "bind var already in use", "query": "select e.col, u.id uid, e.id eid from user u join user_extra e having uid = eid and e.col = :uid", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select e.col, u.id uid, e.id eid from user u join user_extra e having uid = eid and e.col = :uid", "Instructions": { @@ -101,6 +103,7 @@ "comment": "wire-up join with join, going left", "query": "select u1.id from user u1 join user u2 join user u3 where u3.col = u1.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u1.id from user u1 join user u2 join user u3 where u3.col = u1.col", "Instructions": { @@ -164,6 +167,7 @@ "comment": "wire-up join with join, going left, then right", "query": "select u1.id from user u1 join user u2 join user u3 where u3.col = u2.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u1.id from user u1 join user u2 join user u3 where u3.col = u2.col", "Instructions": { @@ -226,6 +230,7 @@ "comment": "wire-up join with join, reuse existing result from a lower join", "query": "select u1.id from user u1 join user u2 on u2.col = u1.col join user u3 where u3.col = u1.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u1.id from user u1 join user u2 on u2.col = u1.col join user u3 where u3.col = u1.col", "Instructions": { @@ -292,6 +297,7 @@ "comment": "wire-up join with join, reuse existing result from a lower join.\n# You need two levels of join nesting to test this: when u3 requests\n# col from u1, the u1-u2 joins exports the column to u2-u3. When\n# u4 requests it, it should be reused from the u1-u2 join.", "query": "select u1.id from user u1 join user u2 join user u3 on u3.id = u1.col join user u4 where u4.col = u1.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u1.id from user u1 join user u2 join user u3 on u3.id = u1.col join user u4 where u4.col = u1.col", "Instructions": { @@ -381,6 +387,7 @@ "comment": "Test reuse of join var already being supplied to the right of a node.", "query": "select u1.id from user u1 join (user u2 join user u3) where u2.id = u1.col and u3.id = u1.col", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u1.id from user u1 join (user u2 join user u3) where u2.id = u1.col and u3.id = u1.col", "Instructions": { @@ -455,6 +462,7 @@ "comment": "Join on weird columns.", "query": "select `weird``name`.a, unsharded.b from `weird``name` join unsharded on `weird``name`.`a``b*c` = unsharded.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select `weird``name`.a, unsharded.b from `weird``name` join unsharded on `weird``name`.`a``b*c` = unsharded.id", "Instructions": { @@ -504,6 +512,7 @@ "comment": "Join on weird column (col is not in select)", "query": "select unsharded.b from `weird``name` join unsharded on `weird``name`.`a``b*c` = unsharded.id", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select unsharded.b from `weird``name` join unsharded on `weird``name`.`a``b*c` = unsharded.id", "Instructions": { @@ -553,6 +562,7 @@ "comment": "wire-up with limit primitive", "query": "select u.id, e.id from user u join user_extra e where e.id = u.col limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.id, e.id from user u join user_extra e where e.id = u.col limit 10", "Instructions": { @@ -610,6 +620,7 @@ "comment": "Wire-up in subquery", "query": "select 1 from user where id in (select u.id+e.id from user u join user_extra e where e.id = u.col limit 10)", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select 1 from user where id in (select u.id+e.id from user u join user_extra e where e.id = u.col limit 10)", "Instructions": { @@ -695,6 +706,7 @@ "comment": "Wire-up in underlying primitive after pullout", "query": "select u.id, e.id, (select col from user) from user u join user_extra e where e.id = u.col limit 10", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.id, e.id, (select col from user) from user u join user_extra e where e.id = u.col limit 10", "Instructions": { @@ -768,6 +780,7 @@ "comment": "Invalid value in IN clause", "query": "select id from user where id in (18446744073709551616, 1)", "plan": { + "Type": "MultiShard", "QueryType": "SELECT", "Original": "select id from user where id in (18446744073709551616, 1)", "Instructions": { @@ -794,6 +807,7 @@ "comment": "Invalid value in IN clause from LHS of join", "query": "select u1.id from user u1 join user u2 where u1.id = 18446744073709551616", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u1.id from user u1 join user u2 where u1.id = 18446744073709551616", "Instructions": { @@ -839,6 +853,7 @@ "comment": "Invalid value in IN clause from RHS of join", "query": "select u1.id from user u1 join user u2 where u2.id = 18446744073709551616", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select u1.id from user u1 join user u2 where u2.id = 18446744073709551616", "Instructions": { @@ -884,6 +899,7 @@ "comment": "derived table with column aliases", "query": "select u.a from (select id as b, name from user) u(a, n) where u.n = 1", "plan": { + "Type": "Complex", "QueryType": "SELECT", "Original": "select u.a from (select id as b, name from user) u(a, n) where u.n = 1", "Instructions": { @@ -935,6 +951,7 @@ "comment": "Three-way join using the left2right. The normal gen4 planner would merge m1 and m2 first, but the left to right doesnt", "query": "select /*vt+ PLANNER=left2right */ user.col from user join unsharded as m1 join unsharded as m2", "plan": { + "Type": "Unknown", "QueryType": "SELECT", "Original": "select /*vt+ PLANNER=left2right */ user.col from user join unsharded as m1 join unsharded as m2", "Instructions": {