~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/subselect_sj2.result

  • Committer: Monty Taylor
  • Date: 2009-09-30 07:01:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090930070132-b1ol1xu1rpajdddy
Small namespace cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
9       5
32
32
explain select * from t2 where b in (select a from t1);
33
33
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
34
 
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       Start temporary
35
 
1       PRIMARY t2      ref     b       b       5       test.t1.a       2       End temporary
 
34
1       PRIMARY t2      ALL     NULL    NULL    NULL    NULL    10      Using where
 
35
2       SUBQUERY        t1      ALL     NULL    NULL    NULL    NULL    3       
36
36
select * from t2 where b in (select a from t1);
37
37
a       b
38
38
1       1
43
43
a int, 
44
44
b int,
45
45
key(b),
46
 
pk1 char(200), pk2 char(200), pk3 char(200),
 
46
pk1 char(100), pk2 char(100), pk3 char(100),
47
47
primary key(pk1, pk2, pk3)
48
48
) engine=innodb;
49
49
insert into t3 select a,a, a,a,a from t0;
50
50
explain select * from t3 where b in (select a from t1);
51
51
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
52
 
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       Start temporary
53
 
1       PRIMARY t3      ref     b       b       5       test.t1.a       1       End temporary
 
52
1       PRIMARY t3      ALL     NULL    NULL    NULL    NULL    10      Using where
 
53
2       SUBQUERY        t1      ALL     NULL    NULL    NULL    NULL    3       
54
54
select * from t3 where b in (select a from t1);
55
55
a       b       pk1     pk2     pk3
56
56
1       1       1       1       1
58
58
set @save_max_heap_table_size= @@max_heap_table_size;
59
59
set max_heap_table_size=16384;
60
60
set @save_join_buffer_size = @@join_buffer_size;
61
 
set join_buffer_size= 8000;
62
 
Warnings:
63
 
Warning 1292    Truncated incorrect join_buffer_size value: '8000'
64
61
drop table t3;
65
62
create table t3 (
66
63
a int, 
67
64
b int,
68
65
key(b),
69
 
pk1 char(200), pk2 char(200),
 
66
pk1 char(100), pk2 char(100),
70
67
primary key(pk1, pk2)
71
68
) engine=innodb;
72
69
insert into t3 select 
74
71
from t0 A, t0 B where B.a <5;
75
72
explain select * from t3 where b in (select a from t0);
76
73
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
77
 
1       PRIMARY t0      ALL     NULL    NULL    NULL    NULL    10      Start temporary
78
 
1       PRIMARY t3      ref     b       b       5       test.t0.a       1       End temporary
 
74
1       PRIMARY t3      ALL     NULL    NULL    NULL    NULL    50      Using where
 
75
2       SUBQUERY        t0      ALL     NULL    NULL    NULL    NULL    10      
79
76
select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5);
80
77
a       b       pk1     pk2
81
78
0       0       0       0
82
79
1       1       1       1
 
80
10      10      10      10
 
81
11      11      11      11
 
82
12      12      12      12
 
83
13      13      13      13
83
84
2       2       2       2
84
85
3       3       3       3
85
86
4       4       4       4
88
89
7       7       7       7
89
90
8       8       8       8
90
91
9       9       9       9
91
 
10      10      10      10
92
 
11      11      11      11
93
 
12      12      12      12
94
 
13      13      13      13
95
92
set join_buffer_size= @save_join_buffer_size;
96
93
set max_heap_table_size= @save_max_heap_table_size;
97
94
explain select * from t1 where a in (select b from t2);
98
95
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
99
 
1       PRIMARY t2      index   b       b       5       NULL    10      Using index; LooseScan
100
 
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       Using where; Using join buffer
 
96
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    3       Using where
 
97
2       SUBQUERY        t2      index   NULL    b       5       NULL    10      Using index
101
98
select * from t1;
102
99
a       b
103
100
1       1
110
107
2       2
111
108
drop table t1, t2, t3;
112
109
set @save_join_buffer_size = @@join_buffer_size;
113
 
set join_buffer_size= 8000;
 
110
set join_buffer_size=8000;
114
111
Warnings:
115
 
Warning 1292    Truncated incorrect join_buffer_size value: '8000'
116
 
create table t1 (a int, filler1 binary(200), filler2 binary(200));
 
112
Error   1292    Truncated incorrect join_buffer_size value: '8000'
 
113
create table t1 (a int, filler1 varbinary(20), filler2 varbinary(20));
117
114
insert into t1 select a, 'filler123456', 'filler123456' from t0;
118
115
insert into t1 select a+10, 'filler123456', 'filler123456' from t0;
119
116
create table t2 as select * from t1;
124
121
insert into t2 values (19, 'duplicate ok', 'duplicate ok');
125
122
explain select 
126
123
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 
127
 
from t1 ot where a in (select a from t2 it);
 
124
from t1 t0 where a in (select a from t2 it);
128
125
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
129
 
1       PRIMARY it      ALL     NULL    NULL    NULL    NULL    22      Start temporary
130
 
1       PRIMARY ot      ALL     NULL    NULL    NULL    NULL    32      Using where; End temporary; Using join buffer
 
126
1       PRIMARY t0      ALL     NULL    NULL    NULL    NULL    32      Using where
 
127
2       SUBQUERY        it      ALL     NULL    NULL    NULL    NULL    22      
131
128
select 
132
129
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 
133
 
from t1 ot where a in (select a from t2 it);
 
130
from t1 t0 where a in (select a from t2 it);
134
131
a       mid(filler1, 1,10)      Z
135
132
0       filler1234      1
136
133
1       filler1234      1
156
153
18      duplicate       1
157
154
explain select 
158
155
a, mid(filler1, 1,10), length(filler1)=length(filler2) 
159
 
from t2 ot where a in (select a from t1 it);
 
156
from t2 t0 where a in (select a from t1 it);
160
157
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
161
 
1       PRIMARY ot      ALL     NULL    NULL    NULL    NULL    22      Start temporary
162
 
1       PRIMARY it      ALL     NULL    NULL    NULL    NULL    32      Using where; End temporary; Using join buffer
 
158
1       PRIMARY t0      ALL     NULL    NULL    NULL    NULL    22      Using where
 
159
2       SUBQUERY        it      ALL     NULL    NULL    NULL    NULL    32      
163
160
select 
164
161
a, mid(filler1, 1,10), length(filler1)=length(filler2) 
165
 
from t2 ot where a in (select a from t1 it);
 
162
from t2 t0 where a in (select a from t1 it);
166
163
a       mid(filler1, 1,10)      length(filler1)=length(filler2)
167
164
0       filler1234      1
168
165
1       filler1234      1
183
180
16      filler1234      1
184
181
17      filler1234      1
185
182
18      filler1234      1
 
183
19      filler1234      1
186
184
3       duplicate       1
187
 
19      filler1234      1
188
185
19      duplicate       1
189
186
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
190
187
insert into t1 select a+20, 'filler123456', 'filler123456' from t0;
191
188
explain select 
192
189
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 
193
 
from t1 ot where a in (select a from t2 it);
 
190
from t1 t0 where a in (select a from t2 it);
194
191
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
195
 
1       PRIMARY it      ALL     NULL    NULL    NULL    NULL    22      Start temporary
196
 
1       PRIMARY ot      ALL     NULL    NULL    NULL    NULL    52      Using where; End temporary; Using join buffer
 
192
1       PRIMARY t0      ALL     NULL    NULL    NULL    NULL    52      Using where
 
193
2       SUBQUERY        it      ALL     NULL    NULL    NULL    NULL    22      
197
194
select 
198
195
a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z 
199
 
from t1 ot where a in (select a from t2 it);
 
196
from t1 t0 where a in (select a from t2 it);
200
197
a       mid(filler1, 1,10)      Z
201
198
0       filler1234      1
202
199
1       filler1234      1
222
219
18      duplicate       1
223
220
explain select 
224
221
a, mid(filler1, 1,10), length(filler1)=length(filler2) 
225
 
from t2 ot where a in (select a from t1 it);
 
222
from t2 t0 where a in (select a from t1 it);
226
223
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
227
 
1       PRIMARY ot      ALL     NULL    NULL    NULL    NULL    22      Start temporary
228
 
1       PRIMARY it      ALL     NULL    NULL    NULL    NULL    52      Using where; End temporary; Using join buffer
 
224
1       PRIMARY t0      ALL     NULL    NULL    NULL    NULL    22      Using where
 
225
2       SUBQUERY        it      ALL     NULL    NULL    NULL    NULL    52      
229
226
select 
230
227
a, mid(filler1, 1,10), length(filler1)=length(filler2) 
231
 
from t2 ot where a in (select a from t1 it);
 
228
from t2 t0 where a in (select a from t1 it);
232
229
a       mid(filler1, 1,10)      length(filler1)=length(filler2)
233
230
0       filler1234      1
234
231
1       filler1234      1
249
246
16      filler1234      1
250
247
17      filler1234      1
251
248
18      filler1234      1
 
249
19      filler1234      1
252
250
3       duplicate       1
253
 
19      filler1234      1
254
251
19      duplicate       1
255
252
drop table t1, t2;
256
253
create table t1 (a int, b int, key(a));
264
261
from t0 where a in
265
262
(select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
266
263
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
267
 
1       PRIMARY t0      ALL     NULL    NULL    NULL    NULL    10      Start temporary
268
 
1       PRIMARY t1      index   NULL    a       5       NULL    10      Using index; Using join buffer
269
 
1       PRIMARY t2      ref     a       a       5       test.t1.a       1       Using index
270
 
1       PRIMARY t3      ref     a       a       5       test.t1.a       1       Using where; Using index; End temporary
 
264
1       PRIMARY t0      ALL     NULL    NULL    NULL    NULL    10      Using where
 
265
2       SUBQUERY        t1      index   NULL    a       5       NULL    10      Using index
 
266
2       SUBQUERY        t2      ref     a       a       5       test.t1.a       1       Using index
 
267
2       SUBQUERY        t3      ref     a       a       5       test.t1.a       1       Using index
271
268
drop table t0, t1,t2,t3;
272
269
CREATE TABLE t1 (
273
 
ID int(11) NOT NULL auto_increment,
 
270
ID int NOT NULL auto_increment,
274
271
Name char(35) NOT NULL default '',
275
272
Country char(3) NOT NULL default '',
276
 
Population int(11) NOT NULL default '0',
 
273
Population int NOT NULL default '0',
277
274
PRIMARY KEY  (ID),
278
275
INDEX (Population),
279
276
INDEX (Country) 
282
279
Code char(3) NOT NULL default '',
283
280
Name char(52) NOT NULL default '',
284
281
SurfaceArea float(10,2) NOT NULL default '0.00',
285
 
Population int(11) NOT NULL default '0',
286
 
Capital int(11) default NULL,
 
282
Population int NOT NULL default '0',
 
283
Capital int default NULL,
287
284
PRIMARY KEY  (Code),
288
285
UNIQUE INDEX (Name),
289
286
INDEX (Population)
303
300
WHERE Language='English' AND Percentage > 10 AND
304
301
t2.Population > 100000);
305
302
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
306
 
1       PRIMARY t1      ALL     Population,Country      NULL    NULL    NULL    30      Using where; Start temporary
307
 
1       PRIMARY t3      eq_ref  PRIMARY,Percentage      PRIMARY 33      test.t1.Country,const   1       Using index condition; Using where
308
 
1       PRIMARY t2      eq_ref  PRIMARY,Population      PRIMARY 3       test.t3.Country 1       Using index condition; Using where; End temporary
 
303
1       PRIMARY t2      ALL     NULL    NULL    NULL    NULL    16      Using where
 
304
3       DEPENDENT SUBQUERY      t3      unique_subquery PRIMARY,Percentage      PRIMARY 136     func,const      1       Using where
 
305
2       SUBQUERY        t1      range   Population      Population      4       NULL    1       Using where
309
306
DROP TABLE t1,t2,t3;
310
307
CREATE TABLE t1 (
311
308
Code char(3) NOT NULL DEFAULT '',
313
310
Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL DEFAULT 'Asia',
314
311
Region char(26) NOT NULL DEFAULT '',
315
312
SurfaceArea float(10,2) NOT NULL DEFAULT '0.00',
316
 
IndepYear smallint(6) DEFAULT NULL,
317
 
Population int(11) NOT NULL DEFAULT '0',
 
313
IndepYear int DEFAULT NULL,
 
314
Population int NOT NULL DEFAULT '0',
318
315
LifeExpectancy float(3,1) DEFAULT NULL,
319
316
GNP float(10,2) DEFAULT NULL,
320
317
GNPOld float(10,2) DEFAULT NULL,
321
318
LocalName char(45) NOT NULL DEFAULT '',
322
319
GovernmentForm char(45) NOT NULL DEFAULT '',
323
320
HeadOfState char(60) DEFAULT NULL,
324
 
Capital int(11) DEFAULT NULL,
 
321
Capital int DEFAULT NULL,
325
322
Code2 char(2) NOT NULL DEFAULT '',
326
323
PRIMARY KEY (Code)
327
324
);
328
325
CREATE TABLE t2 (
329
 
ID int(11) NOT NULL AUTO_INCREMENT,
 
326
ID int NOT NULL, 
330
327
Name char(35) NOT NULL DEFAULT '',
331
328
CountryCode char(3) NOT NULL DEFAULT '',
332
 
District char(20) NOT NULL DEFAULT '',
333
 
Population int(11) NOT NULL DEFAULT '0',
 
329
Population int NOT NULL DEFAULT '0',
334
330
PRIMARY KEY (ID),
335
331
KEY CountryCode (CountryCode)
336
332
);
340
336
WHERE t1.Code IN (
341
337
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
342
338
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
343
 
1       PRIMARY t2      ALL     CountryCode     NULL    NULL    NULL    545     Using where; Start temporary
344
 
1       PRIMARY t1      eq_ref  PRIMARY PRIMARY 3       test.t2.CountryCode     1       End temporary
 
339
1       PRIMARY t1      ALL     NULL    NULL    NULL    NULL    31      Using where
 
340
2       SUBQUERY        t2      ALL     NULL    NULL    NULL    NULL    125     Using where
345
341
SELECT Name FROM t1 
346
342
WHERE t1.Code IN (
347
343
SELECT t2.CountryCode FROM t2 WHERE Population > 5000000);
348
344
Name
349
 
Austria
350
 
Canada
351
 
China
352
 
Czech Republic
353
345
drop table t1, t2;
354
 
CREATE TABLE t1(a INT);
355
 
CREATE TABLE t2(c INT);
356
 
CREATE PROCEDURE p1(v1 int)
357
 
BEGIN
358
 
SELECT 1 FROM t1 WHERE a = v1 AND a IN (SELECT c FROM t2);
359
 
END
360
 
//
361
 
CREATE PROCEDURE p2(v1 int)
362
 
BEGIN
363
 
SELECT 1 FROM t1 WHERE a IN (SELECT c FROM t2);
364
 
END
365
 
//
366
 
CREATE PROCEDURE p3(v1 int)
367
 
BEGIN
368
 
SELECT 1 
369
 
FROM 
370
 
t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
371
 
t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
372
 
t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
373
 
t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
374
 
t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
375
 
t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
376
 
t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
377
 
t1 t57,t1 t58,t1 t59,t1 t60
378
 
WHERE t01.a IN (SELECT c FROM t2);
379
 
END
380
 
//
381
 
CREATE PROCEDURE p4(v1 int)
382
 
BEGIN
383
 
SELECT 1 
384
 
FROM 
385
 
t1 t01,t1 t02,t1 t03,t1 t04,t1 t05,t1 t06,t1 t07,t1 t08,
386
 
t1 t09,t1 t10,t1 t11,t1 t12,t1 t13,t1 t14,t1 t15,t1 t16,
387
 
t1 t17,t1 t18,t1 t19,t1 t20,t1 t21,t1 t22,t1 t23,t1 t24,
388
 
t1 t25,t1 t26,t1 t27,t1 t28,t1 t29,t1 t30,t1 t31,t1 t32,
389
 
t1 t33,t1 t34,t1 t35,t1 t36,t1 t37,t1 t38,t1 t39,t1 t40,
390
 
t1 t41,t1 t42,t1 t43,t1 t44,t1 t45,t1 t46,t1 t47,t1 t48,
391
 
t1 t49,t1 t50,t1 t51,t1 t52,t1 t53,t1 t54,t1 t55,t1 t56,
392
 
t1 t57,t1 t58,t1 t59,t1 t60
393
 
WHERE t01.a = v1 AND t01.a IN (SELECT c FROM t2);
394
 
END
395
 
//
396
 
CALL p1(1);
397
 
1
398
 
CALL p2(1);
399
 
1
400
 
CALL p3(1);
401
 
1
402
 
CALL p4(1);
403
 
1
404
 
DROP TABLE t1, t2;
405
 
DROP PROCEDURE p1;
406
 
DROP PROCEDURE p2;
407
 
DROP PROCEDURE p3;
408
 
DROP PROCEDURE p4;