Background Image

FORUM

조회 수 396 추천 수 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. CUBRID 사용자를 위한 DBeaver 도구 출시 안내

    Date2024.04.23 Byadmin Views55
    read more
  2. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4461
    read more
  3. SQL 에러 질문

    Date2010.10.16 By카르마 Views9958
    Read More
  4. SQL 에러 문의드립니다.

    Date2012.08.04 Byk.. Views15535
    Read More
  5. SQL 에러 문의 드립니다.

    Date2011.05.19 By호랑이새끼 Views15399
    Read More
  6. SQL statement violated NOT NULL constraint

    Date2023.03.15 Byyoo Views165
    Read More
  7. SPRING BOOT 2.X 버전연동 시 문제

    Date2019.02.15 By딩구징구 Views1483
    Read More
  8. SET, MULTISET, LIST과 같은 컬렉션 타입 컬럼에 저장된 원소의 갯수를 알고 싶습니다.

    Date2023.01.06 By새옹지마 Views131
    Read More
  9. SET SYSTEM PARAMETERS 질문 입니다.

    Date2013.10.20 Byphil Views7870
    Read More
  10. SELECT 쿼리 실행시 오류문제입니다.

    Date2011.02.24 By니코로빈 Views9708
    Read More
  11. SELECT 전체 갯수에 대해 질문 드리겠습니다.

    Date2020.04.17 By훈입니다. Views263
    Read More
  12. SELECT 실행 버그 보냅니다

    Date2016.06.30 By취우다 Views9351
    Read More
  13. SELECT 시, 필드 값의 대소문자 구분 없이 조건 검색 가능할까요?

    Date2011.04.02 By차오이 Views16381
    Read More
  14. SELECT 시 INDEX 를 타고 안타는 차이점 ?

    Date2020.12.17 ByRega Views396
    Read More
  15. SELECT FETCH 문제

    Date2018.03.07 By초보123 Views550
    Read More
  16. SAP Connection 관련 질문입니다.

    Date2019.01.09 Bychuci Views195
    Read More
  17. Rocky Linux 9에 큐브리드 9.3버전 설치

    Date2023.12.19 By범이 Views100
    Read More
  18. ResulstSet이 닫혔는데... 닫히는 이유가 먼가요?

    Date2011.06.10 By안지민 Views15607
    Read More
  19. Replication, 서버 이중화, HA

    Date2012.01.26 By승준77 Views23263
    Read More
  20. Release upgrade 문의

    Date2017.02.13 Byyscoma Views9138
    Read More
  21. Regexp_count

    Date2024.04.09 BySEO Views66
    Read More
  22. Redmine 의 데이터베이스로 큐브리드를 사용하는 것이 가능할까요?

    Date2018.04.17 By밝은마음 Views257
    Read More
Board Pagination Prev 1 ... 146 147 148 149 150 151 152 153 154 155 ... 200 Next
/ 200

Contact Cubrid

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