summaryrefslogtreecommitdiff
path: root/mysql-test/r/analyze_format_json.result
blob: b496fe5a68e37e92938bc2098ca183e7a5cb64bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
drop table if exists t0,t1,t2,t3;
create table t0 (a int);
INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
# r_filtered=30%, because 3 rows match: 0,1,2
analyze format=json select * from t0 where a<3;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "t0",
      "access_type": "ALL",
      "r_loops": 1,
      "rows": 10,
      "r_rows": 10,
      "filtered": 100,
      "r_filtered": 30,
      "attached_condition": "(t0.a < 3)"
    }
  }
}
create table t1 (a int, b int, c int, key(a));
insert into t1 select A.a*10 + B.a, A.a*10 + B.a, A.a*10 + B.a from t0 A, t0 B;
analyze
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	10	100.00	0.00	Using where
1	SIMPLE	t1	ref	a	a	5	test.t0.a	1	NULL	100.00	NULL	
analyze format=json 
select * from t0, t1 where t1.a=t0.a and t0.a > 9;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "t0",
      "access_type": "ALL",
      "r_loops": 1,
      "rows": 10,
      "r_rows": 10,
      "filtered": 100,
      "r_filtered": 0,
      "attached_condition": "((t0.a > 9) and (t0.a is not null))"
    },
    "table": {
      "table_name": "t1",
      "access_type": "ref",
      "possible_keys": ["a"],
      "key": "a",
      "key_length": "5",
      "used_key_parts": ["a"],
      "ref": ["test.t0.a"],
      "r_loops": 0,
      "rows": 1,
      "r_rows": null,
      "filtered": 100,
      "r_filtered": null
    }
  }
}
analyze
select * from t0, t1 where t1.a=t0.a and t1.b<4;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	10	100.00	100.00	Using where
1	SIMPLE	t1	ref	a	a	5	test.t0.a	1	1	100.00	40.00	Using where
analyze format=json
select * from t0, t1 where t1.a=t0.a and t1.b<4;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "t0",
      "access_type": "ALL",
      "r_loops": 1,
      "rows": 10,
      "r_rows": 10,
      "filtered": 100,
      "r_filtered": 100,
      "attached_condition": "(t0.a is not null)"
    },
    "table": {
      "table_name": "t1",
      "access_type": "ref",
      "possible_keys": ["a"],
      "key": "a",
      "key_length": "5",
      "used_key_parts": ["a"],
      "ref": ["test.t0.a"],
      "r_loops": 10,
      "rows": 1,
      "r_rows": 1,
      "filtered": 100,
      "r_filtered": 40,
      "attached_condition": "(t1.b < 4)"
    }
  }
}
analyze 
select * from t1 tbl1, t1 tbl2 where tbl1.b<2 and tbl2.b>5;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	r_rows	filtered	r_filtered	Extra
1	SIMPLE	tbl1	ALL	NULL	NULL	NULL	NULL	100	100	100.00	2.00	Using where
1	SIMPLE	tbl2	ALL	NULL	NULL	NULL	NULL	100	100	100.00	94.00	Using where; Using join buffer (flat, BNL join)
analyze format=json
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "tbl1",
      "access_type": "ALL",
      "r_loops": 1,
      "rows": 100,
      "r_rows": 100,
      "filtered": 100,
      "r_filtered": 20,
      "attached_condition": "(tbl1.b < 20)"
    },
    "block-nl-join": {
      "table": {
        "table_name": "tbl2",
        "access_type": "ALL",
        "r_loops": 1,
        "rows": 100,
        "r_rows": 100,
        "filtered": 100,
        "r_filtered": 60,
        "attached_condition": "(tbl2.b < 60)"
      },
      "buffer_type": "flat",
      "join_type": "BNL",
      "r_filtered": 100
    }
  }
}
analyze format=json
select * from t1 tbl1, t1 tbl2 where tbl1.b<20 and tbl2.b<60 and tbl1.c > tbl2.c;
EXPLAIN
{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "tbl1",
      "access_type": "ALL",
      "r_loops": 1,
      "rows": 100,
      "r_rows": 100,
      "filtered": 100,
      "r_filtered": 20,
      "attached_condition": "(tbl1.b < 20)"
    },
    "block-nl-join": {
      "table": {
        "table_name": "tbl2",
        "access_type": "ALL",
        "r_loops": 1,
        "rows": 100,
        "r_rows": 100,
        "filtered": 100,
        "r_filtered": 60,
        "attached_condition": "(tbl2.b < 60)"
      },
      "buffer_type": "flat",
      "join_type": "BNL",
      "attached_condition": "(tbl1.c > tbl2.c)",
      "r_filtered": 15.833
    }
  }
}
drop table t1;
drop table t0;