--
-- ### Query Cache Check
-- 
--

drop if exists table t1;
create table t1 ( a int, b string(100));


insert into t1 values ( 1, 'XXX');
insert into t1 values ( 2, 'YYY');
insert into t1 values ( 3, 'ZZZ');
insert into t1 values ( 4, 'ZZZ');
insert into t1 values ( 5, 'ZZZ');
insert into t1 values ( 6, 'ZZZ');
insert into t1 values ( 7, 'ZZZ');
insert into t1 values ( 8, 'ZZZ');
insert into t1 values ( 9, 'ZZZ');
insert into t1 values ( 10, 'ZZZ');
insert into t1 values (190773,'UZQIBWY');
insert into t1 values (358030,'TSW');
insert into t1 values (32424,'TBTU');
insert into t1 values (316868,'WGI');
insert into t1 values (345470,'DSHYMBSV');
insert into t1 values (70436,'BBNIUP');
insert into t1 values (182914,'ANQBHE');
insert into t1 values (358901,'K');
insert into t1 values (82351,'IQSPKDLS');
insert into t1 values (214721,'RML');
insert into t1 values (97126,'MECZ');
insert into t1 values (394230,'PJSFAA');
insert into t1 values (153524,'MRPR');
insert into t1 values (283014,'ZUQ');
insert into t1 values (37316,'RQP');
insert into t1 values (218216,'CRQJBN');
insert into t1 values (143261,'ZHZC');
insert into t1 values (326928,'KTUVS');
insert into t1 values (5891,'RMV');
insert into t1 values (14774,'JGOPI');
insert into t1 values (22074,'AHCSY');
insert into t1 values (30679,'PDI');
insert into t1 values (158551,'GBO');
insert into t1 values (317487,'P');
insert into t1 values (330055,'JOMWOJRY');
insert into t1 values (28131,'S');
insert into t1 values (173747,'OHEPVWPW');
insert into t1 values (162364,'H');
insert into t1 values (75771,'MJDXI');
insert into t1 values (204932,'CEXDXUCX');
insert into t1 values (169575,'NXFTJKHU');
insert into t1 values (278739,'UDHRO');
insert into t1 values (76981,'QOJNHY');
insert into t1 values (28493,'UIJADFA');
insert into t1 values (389455,'EQCSNQH');
insert into t1 values (223541,'YCYD');
insert into t1 values (308819,'RFFODGN');
insert into t1 values (98663,'UF');
insert into t1 values (168611,'VIBZS');
insert into t1 values (238903,'RHJ');
insert into t1 values (364000,'H');
insert into t1 values (383902,'IUOLEM');
insert into t1 values (149604,'URRPXF');
insert into t1 values (285526,'DAQQL');
insert into t1 values (28923,'CTAVLVA');
insert into t1 values (49718,'OKFELB');
insert into t1 values (268812,'DTR');
insert into t1 values (355784,'MAIQVT');
insert into t1 values (172795,'HVAU');
insert into t1 values (174899,'TDGJLC');
insert into t1 values (199864,'D');
insert into t1 values (26310,'DFXFTTO');
insert into t1 values (257221,'XDZDR');
insert into t1 values (347490,'EJRBEZ');
insert into t1 values (168687,'SDEZJMN');
insert into t1 values (358922,'U');
insert into t1 values (95551,'WAL');
insert into t1 values (343250,'JG');
insert into t1 values (143695,'JBKUVAJ');
insert into t1 values (26127,'ANKDYO');
insert into t1 values (131072,'XDPRT');
insert into t1 values (80924,'TLKIJV');
insert into t1 values (90961,'WENPXW');
insert into t1 values (375777,'HHRNW');
insert into t1 values (348471,'QNHMPU');
insert into t1 values (146417,'TQRLT');
insert into t1 values (108921,'DYKZUQ');
insert into t1 values (109544,'QOSWG');
insert into t1 values (394080,'NOTW');
insert into t1 values (94356,'BUEAAF');
insert into t1 values (197823,'LB');
insert into t1 values (19623,'SFY');
insert into t1 values (164361,'ENH');
insert into t1 values (359596,'B');
insert into t1 values (75439,'FWVA');
insert into t1 values (264542,'AMMPCPBA');
insert into t1 values (124437,'BVJDGSCK');
insert into t1 values (296218,'GWMLT');
insert into t1 values (317320,'MLL');
insert into t1 values (376945,'EQV');
insert into t1 values (327519,'WQR');
insert into t1 values (164417,'WRMYO');
insert into t1 values (338255,'VDF');
insert into t1 values (172125,'RMHWOFG');
insert into t1 values (252681,'ZPTDAXQU');
insert into t1 values (228486,'RLKRT');
insert into t1 values (290008,'LXVEVG');
insert into t1 values (126305,'ZJSAPWGO');
insert into t1 values (214946,'PAHMYC');
insert into t1 values (82515,'N');
insert into t1 values (272697,'WUFMUY');
insert into t1 values (362439,'E');
insert into t1 values (352003,'CJP');
insert into t1 values (92453,'CG');
insert into t1 values (30349,'S');
insert into t1 values (210510,'QGKDSI');
insert into t1 values (186878,'G');
insert into t1 values (310920,'BUJ');
insert into t1 values (174260,'BQBVMGSK');
insert into t1 values (346353,'QGFBD');
insert into t1 values (280011,'SDHD');
insert into t1 values (110501,'HTX');
insert into t1 values (348572,'KIME');
insert into t1 values (108397,'BXPH');
insert into t1 values (9188,'IXG');
insert into t1 values (23937,'XANA');
insert into t1 values (289046,'ZD');
insert into t1 values (300156,'HX');
insert into t1 values (129775,'FGKXO');
insert into t1 values (243793,'JN');
insert into t1 values (324080,'THNARUM');
insert into t1 values (389584,'MNVJ');
insert into t1 values (156300,'DDRQYY');
insert into t1 values (40806,'USUUCW');
insert into t1 values (166037,'K');
insert into t1 values (145862,'IQ');
insert into t1 values (198775,'CKNXXZV');
insert into t1 values (200324,'NYDW');
insert into t1 values (108755,'FU');
insert into t1 values (74916,'BZKSIWT');
insert into t1 values (265105,'DRGTRBA');
insert into t1 values (88946,'ZMYNYLIV');
insert into t1 values (246336,'DZXIZUFW');
insert into t1 values (125613,'ISLVTF');
insert into t1 values (345243,'CMJ');
insert into t1 values (10058,'IMJQ');
insert into t1 values (303403,'LIHD');
insert into t1 values (153518,'T');
insert into t1 values (395513,'YPQQY');
insert into t1 values (204178,'EZSVFG');
insert into t1 values (27716,'URQTCSK');
insert into t1 values (184346,'ZBOUTJK');
insert into t1 values (108051,'R');
insert into t1 values (48499,'ZHSRVF');
insert into t1 values (145302,'K');
insert into t1 values (143837,'M');
insert into t1 values (216519,'LRMEAJ');
insert into t1 values (141780,'HOYIAURZ');
insert into t1 values (136238,'GTGXY');
insert into t1 values (227111,'GKQWZDP');
insert into t1 values (353814,'CZMJVYBA');
insert into t1 values (301239,'JSUKT');
insert into t1 values (111865,'ROXNGXBX');
insert into t1 values (252411,'RVHJF');
insert into t1 values (389534,'DOBDOH');
insert into t1 values (30272,'H');
insert into t1 values (204484,'XMKJ');
insert into t1 values (174945,'VR');
insert into t1 values (267967,'UTDVN');
insert into t1 values (154075,'ITTDGGFE');
insert into t1 values (394273,'QOZY');
insert into t1 values (209038,'RQVDHON');
insert into t1 values (364816,'SYOGM');
insert into t1 values (230646,'V');
insert into t1 values (368905,'LDDAY');
insert into t1 values (111791,'BHTM');
insert into t1 values (61885,'GIWLMU');
insert into t1 values (286532,'QS');
insert into t1 values (1185,'WEZEBGVU');
insert into t1 values (3312,'JEALWVHU');
insert into t1 values (211540,'RRQIX');
insert into t1 values (137184,'MEFXHZHZ');
insert into t1 values (269462,'JCQ');
insert into t1 values (192061,'CSW');
insert into t1 values (147276,'KUNOO');
insert into t1 values (160521,'JEXKAJCC');
insert into t1 values (182587,'AXSQJS');
insert into t1 values (34595,'LISJCME');
insert into t1 values (387462,'AXOV');
insert into t1 values (253625,'SMD');
insert into t1 values (70657,'SLBXAMK');
insert into t1 values (394433,'SWQG');
insert into t1 values (154967,'NN');
insert into t1 values (206058,'CNZTDKM');
insert into t1 values (109644,'FYKNSA');
insert into t1 values (90161,'NNHYYD');
insert into t1 values (267485,'ARDAZCP');
insert into t1 values (67047,'L');
insert into t1 values (76806,'RZ');
insert into t1 values (199563,'KXQSQSNV');
insert into t1 values (341104,'PQHVCX');
insert into t1 values (17467,'AQKA');
insert into t1 values (352315,'WTYEQDA');
insert into t1 values (119230,'B');
insert into t1 values (179109,'NJN');
insert into t1 values (40905,'GSF');
insert into t1 values (318649,'UA');
insert into t1 values (352308,'S');
insert into t1 values (9617,'PQZ');
insert into t1 values (235874,'YWQUDSF');
insert into t1 values (329914,'M');
insert into t1 values (189418,'ITS');
insert into t1 values (136401,'QHGXCSS');
insert into t1 values (85766,'EZROC');
insert into t1 values (383011,'BSJC');
insert into t1 values (273960,'K');
insert into t1 values (276814,'VBEEA');
insert into t1 values (71893,'HIQ');
insert into t1 values (218569,'NAOKGMV');
insert into t1 values (50263,'UVWB');
insert into t1 values (179314,'EWNCS');
insert into t1 values (322960,'GSSGS');
insert into t1 values (33274,'XXNALSN');
insert into t1 values (96895,'ZSVNO');
insert into t1 values (377818,'EHT');
insert into t1 values (4539,'RIPN');
insert into t1 values (278121,'VCV');
insert into t1 values (319933,'ACRJAX');
insert into t1 values (130702,'Y');
insert into t1 values (22354,'LV');
insert into t1 values (55786,'VDFUVE');
insert into t1 values (241930,'OQH');
insert into t1 values (293875,'F');
insert into t1 values (245647,'XWYFNFHP');
insert into t1 values (345832,'MQN');
insert into t1 values (134272,'TXJA');
insert into t1 values (176271,'DYNGF');
insert into t1 values (362513,'QCI');
insert into t1 values (66543,'BRBBHUD');
insert into t1 values (388918,'DOVU');
insert into t1 values (220137,'BSFJ');
insert into t1 values (340880,'MZAR');
insert into t1 values (364056,'EUQHWXI');
insert into t1 values (126097,'FVW');
insert into t1 values (1063,'CM');
insert into t1 values (39498,'SXPWMHPJ');
insert into t1 values (225799,'SPBMTUS');
insert into t1 values (169099,'JKFHIAB');
insert into t1 values (252051,'MTBTNO');
insert into t1 values (168709,'BCAKPPE');
insert into t1 values (127362,'EWDUIHQS');
insert into t1 values (271929,'KKR');
insert into t1 values (354802,'TOOV');

drop if exists table t2;
create table t2 ( a int, b string(100));


insert into t2 values ( 1, 'XXX');
insert into t2 values ( 2, 'YYY');
insert into t2 values ( 3, 'ZZZ');
insert into t2 values (190773,'UZQIBWY');
insert into t2 values (358030,'TSW');
insert into t2 values (32424,'TBTU');
insert into t2 values (316868,'WGI');
insert into t2 values (345470,'DSHYMBSV');
insert into t2 values (70436,'BBNIUP');
insert into t2 values (182914,'ANQBHE');
insert into t2 values (358901,'K');
insert into t2 values (82351,'IQSPKDLS');
insert into t2 values (214721,'RML');
insert into t2 values (97126,'MECZ');
insert into t2 values (394230,'PJSFAA');
insert into t2 values (153524,'MRPR');
insert into t2 values (283014,'ZUQ');
insert into t2 values (37316,'RQP');
insert into t2 values (218216,'CRQJBN');
insert into t2 values (143261,'ZHZC');
insert into t2 values (326928,'KTUVS');
insert into t2 values (5891,'RMV');
insert into t2 values (14774,'JGOPI');
insert into t2 values (22074,'AHCSY');
insert into t2 values (30679,'PDI');
insert into t2 values (158551,'GBO');
insert into t2 values (317487,'P');
insert into t2 values (330055,'JOMWOJRY');
insert into t2 values (28131,'S');
insert into t2 values (173747,'OHEPVWPW');
insert into t2 values (162364,'H');
insert into t2 values (75771,'MJDXI');
insert into t2 values (204932,'CEXDXUCX');
insert into t2 values (169575,'NXFTJKHU');
insert into t2 values (278739,'UDHRO');
insert into t2 values (76981,'QOJNHY');
insert into t2 values (28493,'UIJADFA');
insert into t2 values (389455,'EQCSNQH');
insert into t2 values (223541,'YCYD');
insert into t2 values (308819,'RFFODGN');
insert into t2 values (98663,'UF');
insert into t2 values (168611,'VIBZS');
insert into t2 values (238903,'RHJ');
insert into t2 values (364000,'H');
insert into t2 values (383902,'IUOLEM');
insert into t2 values (149604,'URRPXF');
insert into t2 values (285526,'DAQQL');
insert into t2 values (28923,'CTAVLVA');
insert into t2 values (49718,'OKFELB');
insert into t2 values (268812,'DTR');
insert into t2 values (355784,'MAIQVT');
insert into t2 values (172795,'HVAU');
insert into t2 values (174899,'TDGJLC');
insert into t2 values (199864,'D');
insert into t2 values (26310,'DFXFTTO');
insert into t2 values (257221,'XDZDR');
insert into t2 values (347490,'EJRBEZ');
insert into t2 values (168687,'SDEZJMN');
insert into t2 values (358922,'U');
insert into t2 values (95551,'WAL');
insert into t2 values (343250,'JG');
insert into t2 values (143695,'JBKUVAJ');
insert into t2 values (26127,'ANKDYO');
insert into t2 values (131072,'XDPRT');
insert into t2 values (80924,'TLKIJV');
insert into t2 values (90961,'WENPXW');
insert into t2 values (375777,'HHRNW');
insert into t2 values (348471,'QNHMPU');
insert into t2 values (146417,'TQRLT');
insert into t2 values (108921,'DYKZUQ');
insert into t2 values (109544,'QOSWG');
insert into t2 values (394080,'NOTW');
insert into t2 values (94356,'BUEAAF');
insert into t2 values (197823,'LB');
insert into t2 values (19623,'SFY');
insert into t2 values (164361,'ENH');
insert into t2 values (359596,'B');
insert into t2 values (75439,'FWVA');
insert into t2 values (264542,'AMMPCPBA');
insert into t2 values (124437,'BVJDGSCK');
insert into t2 values (296218,'GWMLT');
insert into t2 values (317320,'MLL');
insert into t2 values (376945,'EQV');
insert into t2 values (327519,'WQR');
insert into t2 values (164417,'WRMYO');
insert into t2 values (338255,'VDF');
insert into t2 values (172125,'RMHWOFG');
insert into t2 values (252681,'ZPTDAXQU');
insert into t2 values (228486,'RLKRT');
insert into t2 values (290008,'LXVEVG');
insert into t2 values (126305,'ZJSAPWGO');
insert into t2 values (214946,'PAHMYC');
insert into t2 values (82515,'N');
insert into t2 values (272697,'WUFMUY');
insert into t2 values (362439,'E');
insert into t2 values (352003,'CJP');
insert into t2 values (92453,'CG');
insert into t2 values (30349,'S');
insert into t2 values (210510,'QGKDSI');
insert into t2 values (186878,'G');
insert into t2 values (310920,'BUJ');
insert into t2 values (174260,'BQBVMGSK');
insert into t2 values (346353,'QGFBD');
insert into t2 values (280011,'SDHD');
insert into t2 values (110501,'HTX');
insert into t2 values (348572,'KIME');
insert into t2 values (108397,'BXPH');
insert into t2 values (9188,'IXG');
insert into t2 values (23937,'XANA');
insert into t2 values (289046,'ZD');
insert into t2 values (300156,'HX');
insert into t2 values (129775,'FGKXO');
insert into t2 values (243793,'JN');
insert into t2 values (324080,'THNARUM');
insert into t2 values (389584,'MNVJ');
insert into t2 values (156300,'DDRQYY');
insert into t2 values (40806,'USUUCW');
insert into t2 values (166037,'K');
insert into t2 values (145862,'IQ');
insert into t2 values (198775,'CKNXXZV');
insert into t2 values (200324,'NYDW');
insert into t2 values (108755,'FU');
insert into t2 values (74916,'BZKSIWT');
insert into t2 values (265105,'DRGTRBA');
insert into t2 values (88946,'ZMYNYLIV');
insert into t2 values (246336,'DZXIZUFW');
insert into t2 values (125613,'ISLVTF');
insert into t2 values (345243,'CMJ');
insert into t2 values (10058,'IMJQ');
insert into t2 values (303403,'LIHD');
insert into t2 values (153518,'T');
insert into t2 values (395513,'YPQQY');
insert into t2 values (204178,'EZSVFG');
insert into t2 values (27716,'URQTCSK');
insert into t2 values (184346,'ZBOUTJK');
insert into t2 values (108051,'R');
insert into t2 values (48499,'ZHSRVF');
insert into t2 values (145302,'K');
insert into t2 values (143837,'M');
insert into t2 values (216519,'LRMEAJ');
insert into t2 values (141780,'HOYIAURZ');
insert into t2 values (136238,'GTGXY');
insert into t2 values (227111,'GKQWZDP');
insert into t2 values (353814,'CZMJVYBA');
insert into t2 values (301239,'JSUKT');
insert into t2 values (111865,'ROXNGXBX');
insert into t2 values (252411,'RVHJF');
insert into t2 values (389534,'DOBDOH');
insert into t2 values (30272,'H');
insert into t2 values (204484,'XMKJ');
insert into t2 values (174945,'VR');
insert into t2 values (267967,'UTDVN');
insert into t2 values (154075,'ITTDGGFE');
insert into t2 values (394273,'QOZY');
insert into t2 values (209038,'RQVDHON');
insert into t2 values (364816,'SYOGM');
insert into t2 values (230646,'V');
insert into t2 values (368905,'LDDAY');
insert into t2 values (111791,'BHTM');
insert into t2 values (61885,'GIWLMU');
insert into t2 values (286532,'QS');
insert into t2 values (1185,'WEZEBGVU');
insert into t2 values (3312,'JEALWVHU');
insert into t2 values (211540,'RRQIX');
insert into t2 values (137184,'MEFXHZHZ');
insert into t2 values (269462,'JCQ');
insert into t2 values (192061,'CSW');
insert into t2 values (147276,'KUNOO');
insert into t2 values (160521,'JEXKAJCC');
insert into t2 values (182587,'AXSQJS');
insert into t2 values (34595,'LISJCME');
insert into t2 values (387462,'AXOV');
insert into t2 values (253625,'SMD');
insert into t2 values (70657,'SLBXAMK');
insert into t2 values (394433,'SWQG');
insert into t2 values (154967,'NN');
insert into t2 values (206058,'CNZTDKM');
insert into t2 values (109644,'FYKNSA');
insert into t2 values (90161,'NNHYYD');
insert into t2 values (267485,'ARDAZCP');
insert into t2 values (67047,'L');
insert into t2 values (76806,'RZ');
insert into t2 values (199563,'KXQSQSNV');
insert into t2 values (341104,'PQHVCX');
insert into t2 values (17467,'AQKA');
insert into t2 values (352315,'WTYEQDA');
insert into t2 values (119230,'B');
insert into t2 values (179109,'NJN');
insert into t2 values (40905,'GSF');
insert into t2 values (318649,'UA');
insert into t2 values (352308,'S');
insert into t2 values (9617,'PQZ');
insert into t2 values (235874,'YWQUDSF');
insert into t2 values (329914,'M');
insert into t2 values (189418,'ITS');
insert into t2 values (136401,'QHGXCSS');
insert into t2 values (85766,'EZROC');
insert into t2 values (383011,'BSJC');
insert into t2 values (273960,'K');
insert into t2 values (276814,'VBEEA');
insert into t2 values (71893,'HIQ');
insert into t2 values (218569,'NAOKGMV');
insert into t2 values (50263,'UVWB');
insert into t2 values (179314,'EWNCS');
insert into t2 values (322960,'GSSGS');
insert into t2 values (33274,'XXNALSN');
insert into t2 values (96895,'ZSVNO');
insert into t2 values (377818,'EHT');
insert into t2 values (4539,'RIPN');
insert into t2 values (278121,'VCV');
insert into t2 values (319933,'ACRJAX');
insert into t2 values (130702,'Y');
insert into t2 values (130702,'YXXX');
insert into t2 values (22354,'LV');
insert into t2 values (55786,'VDFUVE');
insert into t2 values (241930,'OQH');
insert into t2 values (293875,'F');
insert into t2 values (245647,'XWYFNFHP');
insert into t2 values (345832,'MQN');
insert into t2 values (134272,'TXJA');
insert into t2 values (176271,'DYNGF');
insert into t2 values (362513,'QCI');
insert into t2 values (66543,'BRBBHUD');
insert into t2 values (388918,'DOVU');
insert into t2 values (220137,'BSFJ');
insert into t2 values (340880,'MZAR');
insert into t2 values (364056,'EUQHWXI');
insert into t2 values (126097,'FVW');
insert into t2 values (1063,'CM');
insert into t2 values (39498,'SXPWMHPJ');
insert into t2 values (225799,'SPBMTUS');
insert into t2 values (169099,'JKFHIAB');
insert into t2 values (252051,'MTBTNO');
insert into t2 values (168709,'BCAKPPE');
insert into t2 values (127362,'EWDUIHQS');
insert into t2 values (271929,'KKR');
insert into t2 values (354802,'TOOV');

-- select count(*) from t1;
-- select count(*) from t2;
select count(*) from t2 where a in ( select a from t1 );
select count(*) from t2 where a in ( select a from t1 );

drop if exists procedure checkQueryCache;
@
create procedure checkQueryCache(a in int) return int
begin
   var c int;
   :c = ( select count(*) from t2 where a = :a );

   return :c;
end;
@

:c = call checkQueryCache(50263);
print :c;
:c = call checkQueryCache(130702);
print :c;


