Background Image
조회 수 1542 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
5월 큐브리드 정기교육 2일차 개발자 쿼리 튜닝 교육 문제입니다.

--준비
drop table if exists t1;
create table t1 (col1 int, col2 int, col3 int, col4 int, col5 varchar(100), col6 date);
insert into t1 select rownum, 1,mod(rownum,5), mod(rownum,1000), rownum, sysdate - mod(rownum,100000)
                  from table({0,1,2,3,4,5,6,7,8,9}) a, table({0,1,2,3,4,5,6,7,8,9}) b, table({0,1,2,3,4,5,6,7,8,9}) c, table({0,1,2,3,4,5,6,7,8,9}) d, table({0,1,2,3,4,5,6,7,8,9}) e, table({0,1,2,3,4,5,6,7,8,9}) f 
                  limit 1000000;

insert into t1 select rownum, 2,mod(rownum,5), mod(rownum,1000), rownum, sysdate - mod(rownum,100000)
                  from table({0,1,2,3,4,5,6,7,8,9}) a, table({0,1,2,3,4,5,6,7,8,9}) b, table({0,1,2,3,4,5,6,7,8,9}) c, table({0,1,2,3,4,5,6,7,8,9}) d, table({0,1,2,3,4,5,6,7,8,9}) e, table({0,1,2,3,4,5,6,7,8,9}) f 
                  limit 1000;

create index idx1 on t1(col1);
create index idx2 on t1(col6);
create index idx3 on t1(col3,col4,col5);
create index idx4 on t1(col2);

--통계정보 갱신
update statistics on t1 with fullscan;

--실행계획 및 통계 정보확인
set trace on;

show trace;

--스키마 확인
;sc t1

-- 다음 질의를 11.2버전에서 튜닝하세요. (사용된 t1 테이블이 모두 다른 테이블이라고 가정. 동일테이블이기 때문에 재작성 가능한 경우는 고려하지 않는다.)
1. (기대 속도 : 1 sec) 
  select col1
         ,col2
         ,col4
         ,2 max_col
         ,(select col6 from t1 where col1 = a.col1 limit 1) col6
         ,decode(col2, 1, 'yes', 'no') yesno
   from t1 a
  where col4 = 1
    and exists (select 1 from t1 where col4 = 1 and col1 = a.col1)
union all
  select 
          col1
         ,col2
         ,col4
         ,(select max(col1) from t1 where col3 = a.col3) max_col
,(select col6 from t1 where col1 = a.col1 limit 1) col6
         ,decode(col2, 1, 'yes', 'no') yesno
   from t1 a
  where col2 = 1
    and exists (select 1 from t1 where col4 = 1 and col1 = a.col1);

  1. MySQL 구문을 어떻게 큐브리드 구문으로 바꿀수 있나요?

    Date2020.08.18 Bywjdrmstn Views472
    Read More
  2. jdbc 질문입니다.

    Date2020.04.01 Byjechoi Views448
    Read More
  3. (+)는 무슨의미인가요??

    Date2018.05.10 By멍멍거리지마라 Views3433
    Read More
  4. 큐브리드 매니저 실행시 오류

    Date2017.11.14 By아아 Views1302
    Read More
  5. CUBRIDManager-10.1.0.002 cub_manager가 죽는 현상

    Date2017.09.01 By시나브로 Views889
    Read More
  6. 문의드립니다.

    Date2017.06.09 By원탱이02 Views909
    Read More
  7. CUBRID 에러 메세지 확인좀 부탁드리겠습니다.

    Date2017.05.25 By삼돌이 Views1503
    Read More
  8. CUBRID Manager 서버가 계속 죽는 현상이 있네요.

    Date2016.11.23 By사랑천사 Views4499
    Read More
  9. Q&A 게시판 글 쓰기/댓글 쓰기 시 오류 발생하네요.

    Date2016.11.18 By사랑천사 Views7308
    Read More
  10. 큐브리드 매니저 클라이언트 구버전 구할수 있을까요?

    Date2016.07.12 By운비 Views5391
    Read More
  11. 게시판 소스 제공 바람

    Date2016.06.24 Bygbnan Views5856
    Read More
  12. 큐브리드 스케줄러?

    Date2016.01.15 By숲속야래 Views7360
    Read More
  13. 안녕하세요 샘플을 구하고 싶은데 어떻게 하면 구할수있을까요

    Date2015.05.21 By조규 Views7335
    Read More
  14. cubrid mysql 하루 체험 소감

    Date2015.03.16 By차가워 Views8997
    Read More
  15. 라즈베리 파이에도 돌아 갈까요?

    Date2014.11.27 By자유해결사 Views10074
    Read More
  16. 우분투 설치 가능 여부 문의 드립니다.

    Date2014.06.18 Bydearksh Views8
    Read More
  17. 홈페이지 이미지 수정하셔야 할 듯...

    Date2014.01.22 By큐르비드 Views10154
    Read More
  18. 큐브리드 2008 R2 는 어디서 다운받을수 있나요 ?

    Date2013.12.02 By오니오니 Views11921
    Read More
  19. 오~~ 큐브리드 잘 쓸게요~

    Date2013.11.22 By카이사르 Views11786
    Read More
  20. 2013 OLC센터 모델 커리큘럼 공개강좌 수강생 모집

    Date2013.06.10 Bycubrid Views15299
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 14 Next
/ 14

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales