mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
EXISTS(SELECT * ...)
close table before opening in optimize
This commit is contained in:
@@ -328,10 +328,10 @@ patient_uq clinic_uq
|
||||
explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where
|
||||
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1
|
||||
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 Using index
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select test.t6.patient_uq AS `patient_uq`,test.t6.clinic_uq AS `clinic_uq` from test.t6 where exists(select test.t7.uq AS `uq`,test.t7.name AS `name` from test.t7 where (test.t7.uq = test.t6.clinic_uq))
|
||||
Note 1003 select test.t6.patient_uq AS `patient_uq`,test.t6.clinic_uq AS `clinic_uq` from test.t6 where exists(select 1 AS `Not_used` from test.t7 where (test.t7.uq = test.t6.clinic_uq))
|
||||
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
|
||||
ERROR 23000: Column: 'a' in field list is ambiguous
|
||||
drop table t1,t2,t3;
|
||||
@@ -1817,3 +1817,17 @@ a
|
||||
1
|
||||
3
|
||||
DROP TABLE t1;
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,2),(3,4);
|
||||
select * from t1 up where exists (select * from t1 where t1.a=up.a);
|
||||
a b
|
||||
1 2
|
||||
3 4
|
||||
explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY up ALL NULL NULL NULL NULL 2 Using where
|
||||
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
Warnings:
|
||||
Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1
|
||||
Note 1003 select test.up.a AS `a`,test.up.b AS `b` from test.t1 up where exists(select 1 AS `Not_used` from test.t1 where (test.t1.a = test.up.a))
|
||||
drop table t1;
|
||||
|
||||
@@ -1158,3 +1158,12 @@ SELECT a FROM t1 WHERE a >= ALL ( SELECT a FROM t1 WHERE b = 2 );
|
||||
SELECT a FROM t1 WHERE a <= ALL ( SELECT a FROM t1 WHERE b = 2 );
|
||||
SELECT a FROM t1 WHERE a <> ALL ( SELECT a FROM t1 WHERE b = 2 );
|
||||
DROP TABLE t1;
|
||||
|
||||
#
|
||||
# SELECT(EXISTS * ...)optimisation
|
||||
#
|
||||
create table t1 (a int, b int);
|
||||
insert into t1 values (1,2),(3,4);
|
||||
select * from t1 up where exists (select * from t1 where t1.a=up.a);
|
||||
explain extended select * from t1 up where exists (select * from t1 where t1.a=up.a);
|
||||
drop table t1;
|
||||
|
||||
Reference in New Issue
Block a user