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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
set @is_enable_default = @@global.ndb_index_stat_enable;
set @is_enable = 0;
set @is_enable = NULL;
# is_enable_on=0 is_enable_off=0
# ndb_index_stat_enable - before
show global variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF
show local variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF
# ndb_index_stat_enable - after
show global variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF
show local variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF
drop table if exists t1, t2, t3, t4;
CREATE TABLE t10(
K INT NOT NULL AUTO_INCREMENT,
I INT, J INT,
PRIMARY KEY(K),
KEY(I,J),
UNIQUE KEY(J,K)
) ENGINE=ndbcluster
partition by key (K) partitions 1;
INSERT INTO t10(I,J) VALUES (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(0,0);
CREATE TABLE t100 LIKE t10;
INSERT INTO t100(I,J)
SELECT X.J, X.J+(10*Y.J) FROM t10 AS X,t10 AS Y;
CREATE TABLE t10000 LIKE t10;
INSERT INTO t10000(I,J)
SELECT X.J, X.J+(100*Y.J) FROM t100 AS X,t100 AS Y
WHERE X.J<50;
INSERT INTO t10000(I,J)
SELECT X.J, X.J+(100*Y.J) FROM t100 AS X,t100 AS Y
WHERE X.J>=50;
ANALYZE TABLE t10,t100,t10000;
Table Op Msg_type Msg_text
test.t10 analyze status OK
test.t100 analyze status OK
test.t10000 analyze status OK
SELECT COUNT(*) FROM t10;
COUNT(*)
10
SELECT COUNT(*) FROM t100;
COUNT(*)
100
SELECT COUNT(*) FROM t10000;
COUNT(*)
10000
EXPLAIN
SELECT * FROM t10000 WHERE k = 42;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 const PRIMARY PRIMARY 4 const 1
EXPLAIN
SELECT * FROM t10000 WHERE k >= 42 and k < 10000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 500 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE k BETWEEN 42 AND 10000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 500 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE k < 42;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 1000 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE k > 42;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 1000 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 AS X JOIN t10000 AS Y
ON Y.I=X.I AND Y.J = X.I;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE X ALL I NULL NULL NULL 10000 Parent of 2 pushed join@1; Using where with pushed condition
1 SIMPLE Y ref J,I I 10 test.X.I,test.X.I 11 Child of 'X' in pushed join@1
EXPLAIN
SELECT * FROM t100 WHERE k < 42;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t100 range PRIMARY PRIMARY 4 NULL 10 Using where with pushed condition
EXPLAIN
SELECT * FROM t100 WHERE k > 42;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t100 range PRIMARY PRIMARY 4 NULL 10 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE k < 42;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 1000 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE k > 42;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 1000 Using where with pushed condition
EXPLAIN
SELECT * FROM t100 WHERE k BETWEEN 42 AND 10000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t100 range PRIMARY PRIMARY 4 NULL 5 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE k BETWEEN 42 AND 10000;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY PRIMARY 4 NULL 500 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE I = 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref I I 5 const 200
EXPLAIN
SELECT * FROM t10000 WHERE J = 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref J J 5 const 166
EXPLAIN
SELECT * FROM t10000 WHERE I = 0 AND J = 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref J,I I 10 const,const 21
EXPLAIN
SELECT * FROM t10000 WHERE I = 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref I I 5 const 200
EXPLAIN
SELECT * FROM t10000 WHERE I = 0 AND J > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range J,I I 10 NULL 100 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE I = 0 AND J < 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range J,I I 10 NULL 50 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE I = 0 AND J BETWEEN 1 AND 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range J,I I 10 NULL 50 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE I = 0 AND J = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref J,I I 10 const,const 21
EXPLAIN
SELECT * FROM t10000 WHERE J = 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref J J 5 const 166
EXPLAIN
SELECT * FROM t10000 WHERE J = 0 AND K > 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY,J J 9 NULL 83 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J = 0 AND K < 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY,J J 9 NULL 83 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J = 0 AND K BETWEEN 1 AND 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range PRIMARY,J J 9 NULL 41 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J = 0 AND K = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 const PRIMARY,J PRIMARY 4 const 1 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE I = 0 AND J <> 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range J,I I 10 NULL 150 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE I <> 0 AND J = 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref J,I J 5 const 166 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE I <> 0 AND J <> 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range J,I J 5 NULL 1500 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J <> 1 AND I = 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range J,I I 10 NULL 150 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J = 1 AND I <> 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 ref J,I J 5 const 166 Using where with pushed condition
EXPLAIN
SELECT * FROM t10000 WHERE J <> 1 AND I <> 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t10000 range J,I J 5 NULL 1500 Using where with pushed condition
DROP TABLE t10,t100,t10000;
End of 5.1 tests
set @is_enable = @is_enable_default;
set @is_enable = NULL;
# is_enable_on=0 is_enable_off=0
# ndb_index_stat_enable - before
show global variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF
show local variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF
# ndb_index_stat_enable - after
show global variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF
show local variables like 'ndb_index_stat_enable';
Variable_name Value
ndb_index_stat_enable OFF