테스트 케이스 :H2 최적화 SELECT 문/종료 조각 모음
drop table master;
create table master(id int primary key, fk1 int, fk2 int, fk3 int, dataS varchar(255), data1 int, data2 int, data3 int, data4 int,data5 int,data6 int,data7 int,data8 int,data9 int,b1 boolean,b2 boolean,b3 boolean,b4 boolean,b5 boolean,b6 boolean,b7 boolean,b8 boolean,b9 boolean,b10 boolean,b11 boolean,b12 boolean,b13 boolean,b14 boolean,b15 boolean,b16 boolean,b17 boolean,b18 boolean,b19 boolean,b20 boolean,b21 boolean,b22 boolean,b23 boolean,b24 boolean,b25 boolean,b26 boolean,b27 boolean,b28 boolean,b29 boolean,b30 boolean,b31 boolean,b32 boolean,b33 boolean,b34 boolean,b35 boolean,b36 boolean,b37 boolean,b38 boolean,b39 boolean,b40 boolean,b41 boolean,b42 boolean,b43 boolean,b44 boolean,b45 boolean,b46 boolean,b47 boolean,b48 boolean,b49 boolean,b50 boolean);
create index idx_comp on master(fk1,fk2,fk3);
@loop 5000000 insert into master values(?, mod(?,100), mod(?,5), ?,'Hello World Hello World Hello World',?, ?, ?,?, ?, ?, ?, ?, ?,true,true,true,true,true,true,false,false,false,true,true,true,true,true,true,true,false,false,false,true,true,true,true,true,true,true,false,false,false,true,true,true,true,true,true,true,false,false,false,true,true,true,true,true,true,true,false,false,false,true);
1. select 문 다음은 30초이 소요됩니다. 응답 시간을 최적화하는 방법이 있습니까?
SELECT count(*), SUM(CONVERT(b1,INT)) ,SUM(CONVERT(b2,INT)),SUM(CONVERT(b3,INT)),SUM(CONVERT(b4,INT)),SUM(CONVERT(b5,INT)),SUM(CONVERT(b6,INT)),SUM(CONVERT(b7,INT)),SUM(CONVERT(b8,INT)),SUM(CONVERT(b9,INT)),SUM(CONVERT(b10,INT)),SUM(CONVERT(b11,INT)),SUM(CONVERT(b12,INT)),SUM(CONVERT(b13,INT)),SUM(CONVERT(b14,INT)),SUM(CONVERT(b15,INT)),SUM(CONVERT(b16,INT))
FROM master
WHERE fk1=53 AND fk2=3
2. 종료 조각 모음을 시도했습니다. 그러나이 성명서는 내 시험 경우에 약 40 분이 걸렸다. 셧다운 종료 후 선택에는 최대 15 초가 소요됩니다. 문을 다시 실행하면 1 초 이내에 완료됩니다. 서버를 중지하고 시작하더라도 명령문은 약 1 초가 걸립니다. H2에 지속적인 캐시가 있습니까?
인프라 : 웹 브라우저 < -> H2 콘솔 서버 < -> H2 DB : 1.3.158
쿼리가 몇 행입니까? 50000 (확실하지 않음) 인 것 같습니다. COUNT (*) SUM을 선택 –
(CONVERT (B1, INTEGER)) SUM ((B16을 CONVERT, INTEGER)) PUBLIC.MASTER FROM /* PUBLIC.IDX_COMP : FK1 = 53 AND FK2 = 3 */ /* scanCount : 50,001 */ (FK1 = 53) AND (FK2가 = 3) /* 총 : 55,199 MASTER.IDX_COMP 읽기 : 481 (0 %) 하는 판독 MASTER.MASTER_DATA : 54718 (99 %) */ (1 Datensatz, 27368 ms) – Peter