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. [도서 소개] 이클립스 PDT

    Date2011.05.11 By정병주 Views25920
    Read More
  2. [도서 소개] 김태용의 JSP 웹 프로그래밍 입문

    Date2011.01.21 Bycubrid Views22641
    Read More
  3. [기사] 공개SW 유지보수 가이드라인 만들어진다.

    Date2006.08.08 By정병주 Views18964
    Read More
  4. [5월 정기교육] 2일차 개발자교육

    Date2023.05.25 By김아리 Views1542
    Read More
  5. Windows 2003 + CUBRID 2008 R 1.4 + ZBXE 1.2.0 + Autoset 4.3.2 설치 후기

    Date2009.03.20 By윤희서 Views26949
    Read More
  6. Visual-SQL에서 데이타베이스명까지 저장과 ...

    Date2006.06.21 By채광수 Views20289
    Read More
  7. Talk Box는 개발자용 자유게시판입니다.

    Date2006.06.16 By관리자 Views24064
    Read More
  8. Sphinx 라는 검색엔진을 지원했으면 합니다.

    Date2009.09.18 By정순영 Views19656
    Read More
  9. SPRING+IBATIS+DWR 포팅 후기

    Date2009.04.23 By장비맨 Views20672
    Read More
  10. SDEC (Seoul Data Engineering Camp) 2011 - 개발자 중심의 기술 컨퍼런스

    Date2011.05.13 By정병주 Views28020
    Read More
  11. R3.0질문입니다.

    Date2010.10.07 By겜기능되거든 Views12271
    Read More
  12. Query Browser 미흡한 점

    Date2011.04.04 ByGGG특별대원 Views23597
    Read More
  13. Q&A 신속한 답변 부탁 드립니다.

    Date2010.09.27 By스마트 Views11692
    Read More
  14. Q&A 글이 안써지네...

    Date2013.01.28 Byㅇㅇ Views13231
    Read More
  15. Q&A 게시판에 글이 안써지네요. 저만 그런가요?

    Date2013.01.14 Bynimbus89 Views12621
    Read More
  16. Q&A 게시판 글 쓰기/댓글 쓰기 시 오류 발생하네요.

    Date2016.11.18 By사랑천사 Views7308
    Read More
  17. Pentaho Data Integration(Kettle) 에서 Cubrid DBMS 지원 추가

    Date2010.06.17 By김영우 Views18618
    Read More
  18. PHP 로컬 검색 엔진 Orca Search을 큐브리드가 지원되었으면...

    Date2009.09.16 By정순영 Views15538
    Read More
  19. PHP Setup for IIS에서 큐브리드도 지원하도록 해 주시면 안될까요 ?

    Date2008.02.14 By최흥배 Views17240
    Read More
  20. Open Source Software Week 2010 행사

    Date2010.10.28 Bycubrid Views21299
    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