Background Image

FORUM

조회 수 389 추천 수 0 댓글 2
?

단축키

Prev이전 문서

Next다음 문서

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

* 질문 등록 시 다음의 내용을 꼭 기입하여 주세요.
OS
Linux
CUBRID Ver.
10.1.3.7765
CUBRID TOOL Ver.
[도움말]-[버전정보] 확인
응용 환경(API)


* CUBRID 응용 오류, SQL 오류 또는 SQL 튜닝 관련된 문의는 반드시 다음의 내용을 추가해 주세요. 비밀글이나 비밀 댓글도 가능합니다.
* 저희가 상황을 이해하고, 재현이 가능해야 알 수 있는 문제들이 많습니다. 가능한 정보/정황들을 부탁합니다.
에러 내용 및 재현 방법 재현 가능한 Source와 SQL
관련 테이블(인덱스, 키정보 포함) 정보 CUBRID 홈 디렉토리 아래 log 디렉토리 압축


-------------- 아래에 질문 사항을 기입해 주세요. ------------------------------------------------------------------------

데이터가 다른 DB 가 두 개 있습니다. 


CUBRID 버전은 10.1.3 으로 동일합니다. 


Hibernate 4.3.8-Final 사용중입니다. 


-- 실행한 쿼리 


SELECT count(*) as col_0_0_

FROM discharge discharge0_

CROSS JOIN charge charge1_

CROSS JOIN charge_type chargetype2_

WHERE discharge0_.id=charge1_.id

AND charge1_.charge_type_id=chargetype2_.id

AND chargetype2_.is_media_charge=0

AND discharge0_.discharge_date='2020-9-23 0:0:0.000'

AND discharge0_.proc_branch_id=1;




A DB 에서 실행할 시에는 INDEX 를 올바르게 타고 조회가 됩니다. 

Query Plan:

  NESTED LOOPS (inner join)

    NESTED LOOPS (inner join)

      INDEX SCAN (discharge0_.idx_discharge_01) (key range: discharge0_.discharge_date= ?:1 )

      INDEX SCAN (charge1_.pk_charge) (key range: discharge0_.id=charge1_.id)

    INDEX SCAN (chargetype2_.pk_charge_type) (key range: charge1_.charge_type_id=chargetype2_.id)


  rewritten query: select count(*) from discharge discharge0_ cross join charge charge1_ cross join charge_type chargetype2_ where discharge0_.id=charge1_.id and charge1_.charge_type_id=chargetype2_.id and discharge0_.proc_branch_id= ?:0

 and discharge0_.discharge_date= ?:1  and chargetype2_.is_media_charge= ?:2


Trace Statistics:

  SELECT (time: 0, fetch: 29, ioread: 0)

    SCAN (index: discharge.idx_discharge_01), (btree time: 0, fetch: 6, ioread: 0, readkeys: 1, filteredkeys: 0, rows: 4) (lookup time: 0, rows: 4)

      SCAN (index: charge.pk_charge), (btree time: 0, fetch: 12, ioread: 0, readkeys: 4, filteredkeys: 0, rows: 4) (lookup time: 0, rows: 4)

        SCAN (index: charge_type.pk_charge_type), (btree time: 0, fetch: 8, ioread: 0, readkeys: 4, filteredkeys: 0, rows: 4) (lookup time: 0, rows: 4)


1 row selected. (0.006396 sec) Committed.

1 command(s) successfully processed.




그러나 B DB 에서 실행할 시에는 INDEX 를 타지 않고 조회가 됩니다. 


1 row selected. (142.158127 sec) Committed.


1 command(s) successfully processed.


Trace Statistics:

  SELECT (time: 142150, fetch: 172002917, ioread: 0)

    SCAN (table: charge_type), (heap time: 0, fetch: 5, ioread: 0, readrows: 4, rows: 4)

      SCAN (index: charge.fk_charge_6), (btree time: 7, fetch: 5789, ioread: 0, readkeys: 3, filteredkeys: 0, rows: 5776) (lookup time: 6, rows: 5776)

        SCAN (index: discharge.fk_discharge_2), (btree time: 21134, fetch: 26644688, ioread: 0, readkeys: 5776, filteredkeys: 0, rows: 26598480) (lookup time: 18773, rows: 148)





쿼리에서 생성된 Table 및 PK, FK , INDEX 는 모두 동일한 상황입니다. 


해결할 방법이 있을까요 ? 

 


  • ?
    오명환 2020.12.17 16:56
    해당 테이블의 통계를 재 수집한 후에 다시 한번 확인해보시기 바랍니다.

    통계 수집하는 방법은 매뉴얼(https://www.cubrid.org/manual/ko/10.1/sql/tuning.html)을 참조하시면 됩니다.
    수집하실때 sample을 사용하지 마시고, with fullscan을 사용하셔서 하세요.
  • ?
    Rega 2020.12.21 10:49
    답변 감사드립니다. 통계 재수집후 진행토록 해보겠습니다.

  1. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4256
    read more
  2. 특정 값 우선 정렬

    Date2023.10.11 Bydrunkenascii Views54
    Read More
  3. 이기종간 DB Link 문의 드립니다.

    Date2023.09.26 Bykikiki767 Views91
    Read More
  4. jdbc 오류

    Date2023.09.22 By대청댐 Views97
    Read More
  5. javasp start fail이 발생합니다.

    Date2023.09.22 By유수부쟁선 Views57
    Read More
  6. 자연조인문제

    Date2023.09.17 Bydfahwh Views61
    Read More
  7. killtran 관련하여 문의 드립니다.

    Date2023.09.06 By후루숑 Views121
    Read More
  8. Cubrid 물리명 길이 제한 값이 어떻게되나요?

    Date2023.09.05 By엘L Views97
    Read More
  9. 쿼리속도문제

    Date2023.09.01 ByGgyak Views138
    Read More
  10. dbtimezone

    Date2023.08.30 Bysj.han Views77
    Read More
  11. 데이터베이스 삭제시 incorrect or missing password

    Date2023.08.26 Bydfahwh Views102
    Read More
  12. 재귀절을 이용한 뷰 생성

    Date2023.08.24 Bysj.han Views88
    Read More
  13. 데이터타입 조회 문의

    Date2023.08.23 By박혀누 Views74
    Read More
  14. cannot communicate with the broker or received invalid packet

    Date2023.08.23 Byfree Views117
    Read More
  15. Docker

    Date2023.08.23 Bysj.han Views235
    Read More
  16. 비밀번호 변경 오류

    Date2023.08.18 Bydfahwh Views100
    Read More
  17. 큐브리드 DB 복원 관련 문의

    Date2023.08.14 Byfewkgpokp Views71
    Read More
  18. 큐브리드 매니저 테이블 목록 표시 관련해서 질문이 있습니다

    Date2023.08.09 By리에레이 Views78
    Read More
  19. cubrid에 세션확인 방법

    Date2023.08.04 Byredrum Views121
    Read More
  20. 테이블 코멘트 컬럼 코멘트 질문

    Date2023.08.03 By대청댐 Views70
    Read More
  21. 다중 IN(튜플 IN)이 1건인 경우 오류 발생됩니다 큐브리드 자체문제이지 않나 싶어 문의드립니다

    Date2023.08.01 By일개미81호 Views78
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 199 Next
/ 199

Contact Cubrid

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