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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

쿼리에서 binding하는 구문(? 가 들어가서 이 부분이 place holder로서 작용하는 부분)이 있을 시 범위 질의에서 플랜이 달라지는 경우가 발생한다. 플랜이 하나로 될 수 있음에도 둘로 갈라지면서 성능이 느려질 수 있는 부분이 있다.

위의 경우에 대해서 아래 3가지를 비교하면서 그 차이를 설명한다
.
 
1.Where
절에 조건을 상수로 준 경우 => range plan 1
  String sql = "select nation_code from participant where host_year >= 2004 and host_year <= 2008";

plan : Join graph segments (f indicates final):
seg[0]: [0]
seg[1]: nation_code[0] (f)
seg[2]: host_year[0]
Join graph nodes:
node[0]: participant participant(916/16) (sargs 0)
Join graph terms:
term[0]: participant.host_year range (2004 ge_le 2008) (sel 0.0588235) (rank 2) (sarg term) (not-join eligible) (indexable host_year[0]) (loc 0)


2.Where
절에 조건을 “?+상수로 준 경우 => range plan 2
  String sql = "select nation_code from participant where host_year >= ?+4 and host_year <= ?+8";

plan : Join graph segments (f indicates final):
seg[0]: [0]
seg[1]: nation_code[0] (f)
seg[2]: host_year[0]
Join graph nodes:
node[0]: participant participant(916/16) (sargs 0 1)
Join graph terms:
term[0]: participant.host_year range (min inf_le 2008) (sel 1) (rank 2) (sarg term) (not-join eligible) (indexable host_year[0]) (loc 0)
term[1]: participant.host_year range (2004 ge_inf max) (sel 0.0588235) (rank 2) (sarg term) (not-join eligible) (indexable host_year[0]) (loc 0)


3.Where
조건을 “?”로 준 경우 => range plan 1, 1.의 경우와 같음.
  String sql = "select nation_code from participant where host_year >= ? and host_year <= ?";

plan : Join graph segments (f indicates final):
seg[0]: [0]
seg[1]: nation_code[0] (f)
seg[2]: host_year[0]
Join graph nodes:
node[0]: participant participant(916/16) (sargs 0)
Join graph terms:
term[0]: participant.host_year range (2004 ge_le 2008) (sel 0.0588235) (rank 2) (sarg term) (not-join eligible) (indexable host_year[0]) (loc 0)



1
3의 경우 > < 의 범위질의를 하나로 처리하는 모습이 보인다. participant.host_year range (2004 ge_le 2008)
2
이와 달리participant.host_year range (min inf_le 2008) participant.host_year range (2004 ge_inf max) 의 두 가지로 범위질의를 나누어 처리하게 된다
.

이 결과에 따르면 플랜은 처음 작성된 쿼리 문장 자체를 가지고 작성하게 된다. 따라서, ? 부분이 binding 되기 이전에 플랜을 작성하는 것이므로 이렇게 다르게 플랜이 나오는 것은 그 동작이 자연스러운 결과라 할 수 있다
.

쿼리를 작성할 때 좀더 최적화된 형태를 고려한다면, ? binding 되는 부분이 연산된 결과의 값으로 작성하는 것이 유리하다 하겠다. 요약하면, ?+ 상수 형태로 값을 넘기는 것 보다는 값을 미리 계산한 결과값을 ?에 전달하는 것이 최적화된 쿼리라 하겠다
.

,

select nation_code from participant where host_year >= ?+4 and host_year <= ?+8
보다
select nation_code from participant where host_year >= ? and host_year <= ?
이 더 최적화된 쿼리라 할 수 있다.




  1. 용량이 큰 데이터를 질의로 저장하는 방법

    Date2009.11.26 Category응용개발 By남재우 Views12117
    Read More
  2. 윈도우 환경에서 PHP 모듈 로드를 못 할 경우 해결법

    Date2009.11.26 Category응용개발 ByPrototype Views22489
    Read More
  3. CUBRID에서 제약조건(PK,FK,UNIQUE),index 설정 시 주의 사항

    Date2009.11.26 Category응용개발 Bycubebridge Views18886
    Read More
  4. MySQL의 Blob타입을 CUBRID로 변환하기

    Date2009.11.18 Category응용개발 Bycubebridge Views18858
    Read More
  5. CUBRID에서 데이터가 있는 칼럼의 도메인 변경 시 조치방법

    Date2009.11.16 Category운영관리 Bycubebridge Views12409
    Read More
  6. cubrid.conf파일 적용의 우선 순위와 HOST적용 우선 순위

    Date2009.11.14 Category운영관리 Bycubebridge Views13370
    Read More
  7. CUBRID에서 응용프로그램 쿼리 binding 구문이 있을 경우 plan의 차이

    Date2009.11.06 Category질의작성 Bycubebridge Views15700
    Read More
  8. CUBRID의 Statement pooling기능

    Date2009.11.06 Category응용개발 Bycubebridge Views16944
    Read More
  9. CUBRID Manager에서 character set 변경하기[R2.0]

    Date2009.10.29 CategoryCUBRID 매니저 Byseongjoon Views17962
    Read More
  10. Window서버 cmd창에서 CUBRID 구동 후 cmd창을 닫을 시 DB서비스 중단 조치방법

    Date2009.10.29 Category운영관리 Bycubebridge Views16464
    Read More
  11. CUBRID DB 내의 auto_increment 값을 초기화 하자.

    Date2009.10.28 Category질의작성 By손승일 Views29733
    Read More
  12. CUBRID의OLE DB 드라이버 설치 방법.

    Date2009.08.24 Category기타 Byseongjoon Views16263
    Read More
  13. Java SP사용시 JNI_CreateJavaVM 에러메시지 해결 방법

    Date2009.07.15 CategoryCUBRID 매니저 Byseongjoon Views32043
    Read More
  14. 그루비로 큐브리드 함수(or 프로시저) 만들기 by 행복개발자(cyberuls)

    Date2009.07.14 Category응용개발 By시난 Views18753
    Read More
  15. JDBC 커넥션 스트링에 UTF-8 명시하는법

    Date2009.07.03 Category응용개발 ByPrototype Views19017
    Read More
  16. weblogic 8.1 에 CUBRID Connection Pool, DataSource 설정 방법

    Date2009.07.01 Category응용개발 By웁쓰 Views66306
    Read More
  17. CUBRID JDBC Driver 빌드 방법

    Date2009.07.01 Category기타 By웁쓰 Views16943
    Read More
  18. JDBC 사용시 SQL 로깅 - p6spy 사용

    Date2009.07.01 Category응용개발 By웁쓰 Views36002
    Read More
  19. 임의의 컬럼을 rownum 으로 업데이트 하기

    Date2009.07.01 Category질의작성 ByPrototype Views22536
    Read More
  20. 중복데이터 제거 방법

    Date2009.07.01 Category질의작성 ByPrototype Views25068
    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