File: desc_index_min_max.result

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (177 lines) | stat: -rw-r--r-- 6,749 bytes parent folder | download | duplicates (2)
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
#
# MDEV-27576 Use DESC indexes for MIN/MAX optimization
#
create or replace table t1 (a int, key(a desc)) engine=innodb;
insert into t1 select seq * 2 from seq_1_to_100 order by rand(1);
explain select max(a) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1;
max(a)
200
explain select min(a) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1;
min(a)
2
explain select max(a) from t1 where a < 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1 where a < 100;
max(a)
98
explain select min(a) from t1 where a > 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1 where a > 100;
min(a)
102
explain select max(a) from t1 where a <= 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1 where a <= 100;
max(a)
100
explain select min(a) from t1 where a >= 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1 where a >= 100;
min(a)
100
explain select max(a) from t1 where a <= 99;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1 where a <= 99;
max(a)
98
explain select min(a) from t1 where a >= 99;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1 where a >= 99;
min(a)
100
explain select max(a) from t1 where a > 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1 where a > 100;
max(a)
200
explain select max(a) from t1 where a > 1000;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No matching min/max row
select max(a) from t1 where a > 1000;
max(a)
NULL
explain select min(a) from t1 where a < 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1 where a < 100;
min(a)
2
explain select min(a) from t1 where a < 0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No matching min/max row
select min(a) from t1 where a < 0;
min(a)
NULL
explain select max(a) from t1 where a >= 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1 where a >= 100;
max(a)
200
explain select max(a) from t1 where a >= 1000;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No matching min/max row
select max(a) from t1 where a >= 1000;
max(a)
NULL
explain select min(a) from t1 where a <= 100;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1 where a <= 100;
min(a)
2
explain select min(a) from t1 where a <= 0;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No matching min/max row
select min(a) from t1 where a <= 0;
min(a)
NULL
explain select max(a) from t1 where a >= 99;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1 where a >= 99;
max(a)
200
explain select min(a) from t1 where a <= 99;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1 where a <= 99;
min(a)
2
explain select max(200 - a) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	index	NULL	a	5	NULL	#	Using index
select max(200 - a) from t1;
max(200 - a)
198
explain select min(200 - a) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	index	NULL	a	5	NULL	#	Using index
select min(200 - a) from t1;
min(200 - a)
0
create or replace table t1 (a int, b int, key(a desc, b asc)) engine=innodb;
insert into t1 select seq * 2, seq * 2 from seq_1_to_100 order by rand(1);
explain select max(a) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(a) from t1;
max(a)
200
explain select min(a) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(a) from t1;
min(a)
2
create or replace table t1 (a int, b int, key(a asc), key (b desc)) engine=innodb;
insert into t1 select seq * 2, seq * 2 from seq_1_to_100 order by rand(1);
explain select max(b) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(b) from t1;
max(b)
200
explain select min(b) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(b) from t1;
min(b)
2
create or replace table t1 (a int, b int, key (b desc)) engine=innodb;
insert into t1 select seq * 2, seq * 2 from seq_1_to_100 order by rand(1);
explain select max(b) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select max(b) from t1;
max(b)
200
explain select min(b) from t1;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
select min(b) from t1;
min(b)
2
CREATE OR REPLACE TABLE t1 (a FLOAT, KEY (a DESC));
INSERT INTO t1 VALUES (0.1234),(0.6789);
explain SELECT MAX(a) FROM t1 WHERE a <= 0.6789;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Select tables optimized away
SELECT MAX(a) FROM t1 WHERE a <= 0.6789;
MAX(a)
0.6789
drop table t1;
# end of test 11.4