Background Image
조회 수 1549 추천 수 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. 안녕하세요~!

    Date2009.03.30 By루키민규 Views18537
    Read More
  2. 어헙... 감사합니다..(꾸벅)

    Date2009.03.12 By갈은양파 Views18047
    Read More
  3. cubrid 홈페이지 글씨체에 대해서

    Date2009.03.10 By프란체스카 Views17735
    Read More
  4. 연락을 받고 답장이 늦기는 했는데..

    Date2009.03.02 By갈은양파 Views18847
    Read More
  5. 큐브리드 매니저 splash 이미지 변경 예정입니다. ^^

    Date2008.12.20 By정병주 Views39266
    Read More
  6. 오늘 처음 큐브리드라는거 알게 되었네욤..

    Date2008.12.18 By레드오리 Views27022
    Read More
  7. NHN DeView 2008 후기 - CUBRID 2008

    Date2008.11.25 By정병주 Views56416
    Read More
  8. 개편된 홈페이지가 너무 멋져요!!

    Date2008.11.22 By진이 Views22443
    Read More
  9. 다운로드방식...

    Date2008.10.27 By김성재 Views17997
    Read More
  10. 축하드립니다.^^

    Date2008.10.02 By세계최고로~!! Views19144
    Read More
  11. phpCubAdmin 에서 실수

    Date2008.09.05 By이경만 Views18728
    Read More
  12. 큐브리드의 철학은?

    Date2008.07.24 By초보대왕 Views29550
    Read More
  13. 오.. 큐브리드, 번창하길 빕니다..

    Date2008.07.04 By이민 Views29604
    Read More
  14. 오라클 제품 가격 22~25% 인상

    Date2008.06.27 Byadmin Views32696
    Read More
  15. 구인: 자바개발자를 구합니다

    Date2008.05.06 By정병주 Views36433
    Read More
  16. 채용 공고 - 큐브리드 사용자 우대

    Date2008.05.03 By정병주 Views17758
    Read More
  17. MySQL 라이선스...

    Date2008.04.30 By새로운시작 Views19126
    Read More
  18. 정부, 오라클과 유지보수율 높은 수준서 합의

    Date2008.04.22 Byadmin Views16876
    Read More
  19. 큐브리드 로고...

    Date2008.03.21 By강현철 Views18307
    Read More
  20. 큐브리드 3월 정기교육 안내

    Date2008.03.10 Byadmin Views14919
    Read More
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 Next
/ 14

Contact Cubrid

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