Files
tidb/tests/integrationtest/r/executor/explain.result

303 lines
13 KiB
Plaintext

drop table if exists t;
create table t (v int);
explain format = 'brief' select * from t t1, t t2;
id estRows task access object operator info
HashJoin 100000000.00 root CARTESIAN inner join
├─TableReader(Build) 10000.00 root data:TableFullScan
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
└─TableReader(Probe) 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
explain format = 'brief' select * from t t1 where exists (select 1 from t t2 where t2.v > t1.v);
id estRows task access object operator info
HashJoin 7992.00 root CARTESIAN semi join, other cond:gt(executor__explain.t.v, executor__explain.t.v)
├─TableReader(Build) 9990.00 root data:Selection
│ └─Selection 9990.00 cop[tikv] not(isnull(executor__explain.t.v))
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
└─TableReader(Probe) 9990.00 root data:Selection
└─Selection 9990.00 cop[tikv] not(isnull(executor__explain.t.v))
└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
explain format = 'brief' select * from t t1 where exists (select 1 from t t2 where t2.v in (t1.v+1, t1.v+2));
id estRows task access object operator info
HashJoin 8000.00 root CARTESIAN semi join, other cond:in(executor__explain.t.v, plus(executor__explain.t.v, 1), plus(executor__explain.t.v, 2))
├─TableReader(Build) 10000.00 root data:TableFullScan
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
└─TableReader(Probe) 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
explain format = 'brief' select * from t t1, t t2 where t1.v = t2.v;
id estRows task access object operator info
HashJoin 12487.50 root inner join, equal:[eq(executor__explain.t.v, executor__explain.t.v)]
├─TableReader(Build) 9990.00 root data:Selection
│ └─Selection 9990.00 cop[tikv] not(isnull(executor__explain.t.v))
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
└─TableReader(Probe) 9990.00 root data:Selection
└─Selection 9990.00 cop[tikv] not(isnull(executor__explain.t.v))
└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
drop table if exists t;
create table t (a int);
explain analyze insert into t select 1;
select * from t;
a
1
explain analyze update t set a=2 where a=1;
select * from t;
a
2
explain format = 'brief' insert into t select 1;
select * from t;
a
2
explain analyze insert into t select 1;
explain analyze replace into t values (3);
select * from t order by a;
a
1
2
3
desc format='brief' select * from information_schema.statements_summary;
id estRows task access object operator info
MemTableScan 10000.00 root table:STATEMENTS_SUMMARY
desc format='brief' select * from information_schema.statements_summary where digest is null;
id estRows task access object operator info
Selection 8000.00 root isnull(Column#5)
└─MemTableScan 10000.00 root table:STATEMENTS_SUMMARY
desc format='brief' select * from information_schema.statements_summary where digest = 'abcdefg';
id estRows task access object operator info
MemTableScan 10000.00 root table:STATEMENTS_SUMMARY digests: ["abcdefg"]
desc format='brief' select * from information_schema.statements_summary where digest in ('a','b','c');
id estRows task access object operator info
MemTableScan 10000.00 root table:STATEMENTS_SUMMARY digests: ["a","b","c"]
drop table if exists tt123;
CREATE TABLE tt123 (
id int(11) NOT NULL,
a bigint(20) DEFAULT NULL,
b char(20) DEFAULT NULL,
c datetime DEFAULT NULL,
d double DEFAULT NULL,
e json DEFAULT NULL,
f decimal(40,6) DEFAULT NULL,
PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */,
KEY a (a),
KEY b (b),
KEY c (c),
KEY d (d),
KEY f (f)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
explain format='brief' select /*+ inl_hash_join(t1) */ * from tt123 t1 join tt123 t2 on t1.b=t2.e;
id estRows task access object operator info
Projection 12500.00 root executor__explain.tt123.id, executor__explain.tt123.a, executor__explain.tt123.b, executor__explain.tt123.c, executor__explain.tt123.d, executor__explain.tt123.e, executor__explain.tt123.f, executor__explain.tt123.id, executor__explain.tt123.a, executor__explain.tt123.b, executor__explain.tt123.c, executor__explain.tt123.d, executor__explain.tt123.e, executor__explain.tt123.f
└─HashJoin 12500.00 root inner join, equal:[eq(executor__explain.tt123.e, Column#15)]
├─TableReader(Build) 10000.00 root data:TableFullScan
│ └─TableFullScan 10000.00 cop[tikv] table:t2 keep order:false, stats:pseudo
└─Projection(Probe) 10000.00 root executor__explain.tt123.id, executor__explain.tt123.a, executor__explain.tt123.b, executor__explain.tt123.c, executor__explain.tt123.d, executor__explain.tt123.e, executor__explain.tt123.f, cast(executor__explain.tt123.b, json BINARY)->Column#15
└─TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo
drop table if exists t;
create table t (a int primary key);
insert into t values (2);
set @@tidb_constraint_check_in_place=1;
explain analyze insert into t values (1), (2), (3);
Error 1062 (23000): Duplicate entry '2' for key 't.PRIMARY'
select * from t;
a
2
set @@tidb_constraint_check_in_place=DEFAULT;
drop table if exists t;
create table t(a int);
set @@session.tidb_enable_non_prepared_plan_cache = 1;
select * from t limit 1;
a
select * from t limit 1;
a
explain format = 'plan_cache' select * from (select * from t) t1 limit 1;
id estRows task access object operator info
Limit_8 1.00 root offset:0, count:1
└─TableReader_12 1.00 root data:Limit_11
└─Limit_11 1.00 cop[tikv] offset:0, count:1
└─TableFullScan_10 1.00 cop[tikv] table:t keep order:false, stats:pseudo
show warnings;
Level Code Message
Warning 1105 skip non-prepared plan-cache: queries that have sub-queries are not supported
explain format = 'plan_cache' select * from (select * from t) t1 limit 1;
id estRows task access object operator info
Limit_8 1.00 root offset:0, count:1
└─TableReader_12 1.00 root data:Limit_11
└─Limit_11 1.00 cop[tikv] offset:0, count:1
└─TableFullScan_10 1.00 cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain analyze format = 'plan_cache' select * from (select * from t) t1 limit 1;
show warnings;
Level Code Message
Warning 1105 skip non-prepared plan-cache: queries that have sub-queries are not supported
explain analyze format = 'plan_cache' select * from (select * from t) t1 limit 1;
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'plan_cache' select * from t;
id estRows task access object operator info
TableReader_5 10000.00 root data:TableFullScan_4
└─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
show warnings;
Level Code Message
explain format = 'plan_cache' select * from t;
id estRows task access object operator info
TableReader_5 10000.00 root data:TableFullScan_4
└─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
1
explain analyze format = 'plan_cache' select * from t;
show warnings;
Level Code Message
explain analyze format = 'plan_cache' select * from t;
select @@last_plan_from_cache;
@@last_plan_from_cache
1
explain select * from t;
id estRows task access object operator info
TableReader_5 10000.00 root data:TableFullScan_4
└─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'brief' select * from t;
id estRows task access object operator info
TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'dot' select * from t;
dot contents
digraph TableReader_5 {
subgraph cluster5{
node [style=filled, color=lightgrey]
color=black
label = "root"
"TableReader_5"
}
subgraph cluster4{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"TableFullScan_4"
}
"TableReader_5" -> "TableFullScan_4"
}
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'hint' select * from t;
hint
use_index(@`sel_1` `executor__explain`.`t` )
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'row' select * from t;
id estRows task access object operator info
TableReader_5 10000.00 root data:TableFullScan_4
└─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'verbose' select * from t;
id estRows estCost task access object operator info
TableReader_5 10000.00 177906.67 root data:TableFullScan_4
└─TableFullScan_4 10000.00 2035000.00 cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'traditional' select * from t;
id estRows task access object operator info
TableReader_5 10000.00 root data:TableFullScan_4
└─TableFullScan_4 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'binary' select * from t;
binary plan
zQFYCsoBCg1UYWJsZVJlYWRlcl81EncKD1QBEVBGdWxsU2Nhbl80IQEAAAA4DT9BKQABAfBGiMNAOAJAAkoYChYKEWV4ZWN1dG9yX19leHBsYWluEgF0Uh5rZWVwIG9yZGVyOmZhbHNlLCBzdGF0czpwc2V1ZG9w//////8BAwQBeAEGBQEgASFVVVVVlbcFHWYoAUABUhRkYXRhOlQ2kgAAcAUzAQEsAXj///////////8B
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'tidb_json' select * from t;
TiDB_JSON
[
{
"id": "TableReader_5",
"estRows": "10000.00",
"taskType": "root",
"operatorInfo": "data:TableFullScan_4",
"subOperators": [
{
"id": "TableFullScan_4",
"estRows": "10000.00",
"taskType": "cop[tikv]",
"accessObject": "table:t",
"operatorInfo": "keep order:false, stats:pseudo"
}
]
}
]
select @@last_plan_from_cache;
@@last_plan_from_cache
0
explain format = 'cost_trace' select * from t;
id estRows estCost costFormula task access object operator info
TableReader_5 10000.00 177906.67 ((scan(10000*logrowsize(32)*tikv_scan_factor(40.7))) + (net(10000*rowsize(16)*tidb_kv_net_factor(3.96))))/15.00 root data:TableFullScan_4
└─TableFullScan_4 10000.00 2035000.00 scan(10000*logrowsize(32)*tikv_scan_factor(40.7)) cop[tikv] table:t keep order:false, stats:pseudo
select @@last_plan_from_cache;
@@last_plan_from_cache
0
set @@session.tidb_enable_non_prepared_plan_cache = DEFAULT;
drop table if exists t;
drop view if exists v;
drop user if exists 'explain'@'%';
create table t (id int);
create view v as select * from t;
create user 'explain'@'%';
grant select on executor__explain.v to 'explain'@'%';
show databases;
Database
INFORMATION_SCHEMA
executor__explain
use executor__explain;
select * from v;
id
explain format = 'brief' select * from v;
Error 1345 (HY000): EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
grant show view on executor__explain.v to 'explain'@'%';
explain format = 'brief' select * from v;
id estRows task access object operator info
TableReader 10000.00 root data:TableFullScan
└─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo
revoke select on executor__explain.v from 'explain'@'%';
explain format = 'brief' select * from v;
Error 1142 (42000): SELECT command denied to user 'explain'@'%' for table 'v'
create table t1 (i int);
create table t2 (j int);
create table t3 (k int, secret int);
create view v1 as select * from t1;
create view v2 as select * from v1, t2;
create view v3 as select k from t3;
grant select, show view on executor__explain.v2 to 'explain'@'%';
grant show view on executor__explain.v1 to 'explain'@'%';
grant select, show view on executor__explain.t3 to 'explain'@'%';
grant select, show view on executor__explain.v3 to 'explain'@'%';
explain select * from v1;
Error 1142 (42000): SELECT command denied to user 'explain'@'%' for table 'v1'
explain select * from v2;
Error 1345 (HY000): EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
explain select * from t3;
id estRows task access object operator info
TableReader_5 10000.00 root data:TableFullScan_4
└─TableFullScan_4 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo
explain select * from v3;
id estRows task access object operator info
TableReader_7 10000.00 root data:TableFullScan_6
└─TableFullScan_6 10000.00 cop[tikv] table:t3 keep order:false, stats:pseudo