조회 수 2466 추천 수 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. database별 브로커 할당 가능 여부

    Date2025.03.18 Bylsh Views153
    Read More
  2. php에서 odbc 드라이버 사용 후 오류 관련 문의

    Date2024.12.19 By프리맨 Views366
    Read More
  3. 큐브리드 오류 메시지 문의

    Date2024.01.30 By박현우 Views1281
    Read More
  4. 큐브리드매니저 관련 문의

    Date2024.01.05 By12345 Views1218
    Read More
  5. mssql server 2008에서 cuibrid 서버 연결하고 프로시져 만들어서 돌리는 방법 좀....

    Date2023.09.08 ByXstar Views1563
    Read More
  6. Migration Toolkit 실행이 안되고 있습니다

    Date2023.06.01 Bykipo0821 Views1193
    Read More
  7. [5월 정기교육] 2일차 개발자교육

    Date2023.05.25 By김아리 Views2466
    Read More
  8. 우어 벌써 17년이나 되었네요

    Date2023.05.07 By후들짝 Views21098
    Read More
  9. 정기교육 일정 및 신청 문의 드립니다.

    Date2023.04.25 Bygcpark Views1235
    Read More
  10. CLASS_TYPE 에 관련해서..

    Date2023.04.07 By학아 Views1309
    Read More
  11. 큐브리드 매니저 윈도우 다운어디서 받아요?

    Date2023.01.12 By박수진 Views1422
    Read More
  12. 하위버전 다운로드 항몫

    Date2022.11.02 By정정미 Views1360
    Read More
  13. 안녕하세요

    Date2022.11.02 By이현수 Views1578
    Read More
  14. 홈페이지 Cubrid 에서 글씨체 관련이요

    Date2022.05.19 Byhane Views2104
    Read More
  15. 큐브리드 매니저 윈도우버젼은 없네요? 어디서 다운받나요?

    Date2021.08.03 By겸둥이k Views2150
    Read More
  16. 큐브리드 엔진 리눅스용 32비트는

    Date2021.07.29 By김둥둥 Views1294
    Read More
  17. (+)는 무슨의미인가요??

    Date2021.07.23 By이지은 Views8721
    Read More
  18. 콘솔 접속

    Date2021.05.26 Byyonggi Views1981
    Read More
  19. 큐브리드 -> 큐브리드 이관할 때, 데이터 이관하는 방법

    Date2021.05.10 Byots21 Views2029
    Read More
  20. 2021년 큐브리드 정기 교육일정문의

    Date2020.12.23 By나라디 Views1496
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 14 Next
/ 14

Contact Cubrid

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

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

나눔고딕 사이트로 가기

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5