Background Image

FORUM

조회 수 13270 추천 수 0 댓글 6
?

단축키

Prev이전 문서

Next다음 문서

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

* 질문 등록 시 다음의 내용을 꼭 기입하여 주세요.
OS
Linux 64bit CentOS release 6.3
CUBRID Ver.
CUBRID 2008 R4.3 (8.4.3.1005) 
CUBRID TOOL Ver.
2013 빌드 0238  (64bit)
응용 환경(API)
java

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


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


select count(a.fileid)

from ( select a.fileid from tbl_agent_files_keyword a

where a.caseid = '6f47822c-2f8b-4f28-be3e-897b75e9abae' and a.cnt >= 1) a,

  ( select b.fileid from tbl_agent_files b

where b.caseid = '6f47822c-2f8b-4f28-be3e-897b75e9abae'

and (accesstime > '1981-01-01 00:00:00' AND modifiedtime > '1981-01-01 00:00:00' AND createtime  > '1981-01-01 00:00:00') ) b

where a.fileid = b.fileid  ;


첫 번째 인라인 뷰 : 42만건

첫 번째 인라인 뷰 : 28만건


-> 응답속도 : 2.56초


위 건수 대비 응답속도가  많이 느리다는 생각이 드는데 개선 방법이 없을까요 ?






  • ?
    이용미 2013.12.10 22:19

    안녕하세요.

    위 질의에서 사용되는 테이블의 스키마, 질의 수행 계획(level  514)등 상세 내역을 알려주시면 도움이 될 것같습니다.

    질의 수행 계획은 매뉴얼( http://www.cubrid.org/manual/ko/8.4.4/sql/tuning.html#show-query-plan )을 참고하여 알려주세요.

    감사합니다.

  • ?
    knight 2013.12.11 00:24 Files첨부 (1)

    1) tbl_agent_files_keyword 테이블

    CREATE TABLE tbl_agent_files_keyword(

    caseid character varying(50) NOT NULL,

    fileid character varying(50) NOT NULL,

    keywordname character varying(2000) NOT NULL,

    firstposition integer,

    cnt integer,

    resulttype integer,

    agentid character varying(50) NOT NULL,

    CONSTRAINT pk_tbl_agent_files_keyword PRIMARY KEY(caseid,agentid,fileid,keywordname)

    );

    CREATE INDEX tbl_agent_files_keyword_case ON tbl_agent_files_keyword(caseid,agentid);

    CREATE INDEX tbl_agent_files_keyword_fid ON tbl_agent_files_keyword(fileid);


    2) tbl_agent_files 테이블

    CREATE TABLE tbl_agent_files(

    agentid character varying(50) NOT NULL,

    caseid character varying(50) NOT NULL,

    fileid character varying(50) NOT NULL,

    filepath character varying(4000),

    filename character varying(4000),

    fileextension character varying(200),

    filesize bigint,

    isencrypt integer,

    [md5] character varying(100),

    sha256 character varying(100),

    createtime datetime,

    modifiedtime datetime,

    accesstime datetime,

    contenthash character varying(200),

    filehash character varying(200),

    title character varying(1000),

    subject character varying(1000),

    author character varying(100),

    keywords character varying(1000),

    comments character varying(1000),

    lastauthor character varying(100),

    [format] character varying(200),

    programname character varying(200),

    regexprcheck integer,

    isregexprexists integer,

    iscontentsaved integer,

    keywordcheck integer,

    iskeywordexists integer,

    isfilesaved integer,

    startsector integer,

    isdeleted integer,

    CONSTRAINT pk_tbl_agent_files PRIMARY KEY(caseid,agentid,fileid)

    );

    CREATE INDEX tbl_agent_file_atime ON tbl_agent_files(caseid,agentid,accesstime);

    CREATE INDEX tbl_agent_files_fileext ON tbl_agent_files(agentid,caseid,fileextension);

    CREATE INDEX tbl_agent_files_fileid ON tbl_agent_files(fileid);


    3) 실행 계획

    첨부파일 참조


    이상입니다~~

  • ?
    이용미 2013.12.11 01:53

    첨부해 주신 질의 수행 계획은 내용이 많이 잘려있습니다.

    [트리 출력(2)] 외에 [원본 출력(1)] 텍스트 형식으로 올려주세요.

    감사합니다.

  • ?
    knight 2013.12.11 01:55

    원본출력[1] 형태 입니다


    Join graph segments (f indicates final):

    seg[0]: [0]

    seg[1]: fileid[0] (f)

    seg[2]: cnt[0]

    seg[3]: caseid[0]

    Join graph nodes:

    node[0]: tbl_agent_files_keyword a(549992/5110) (sargs 0 1)

    Join graph terms:

    term[0]: (a.cnt range (1 ge_inf max)) (sel 0.1) (rank 2) (sarg term) (not-join eligible) (loc 0)

    term[1]: a.caseid='6f47822c-2f8b-4f28-be3e-897b75e9abae' (sel 0.0294118) (sarg term) (not-join eligible) (indexable caseid[0]) (loc 0)


    Query plan:


    iscan

        class: a node[0]

        index: tbl_agent_files_keyword_case term[1]

        sargs: term[0]

        cost:  fixed 10(0.0/10.0) var 155(48.5/106.0) card 1618


    Query stmt:


    (select a.fileid from tbl_agent_files_keyword a where ((a.cnt>= ?:0 ) and a.caseid= ?:1 ))


    Join graph segments (f indicates final):

    seg[0]: [0]

    seg[1]: fileid[0] (f)

    seg[2]: accesstime[0]

    seg[3]: modifiedtime[0]

    seg[4]: createtime[0]

    seg[5]: caseid[0]

    Join graph nodes:

    node[0]: tbl_agent_files b(4897995/152212) (sargs 0 1 2 3)

    Join graph terms:

    term[0]: b.modifiedtime range (datetime '12:00:00.000 AM 01/01/1981' gt_inf max) (sel 0.1) (rank 2) (sarg term) (not-join eligible) (loc 0)

    term[1]: b.createtime range (datetime '12:00:00.000 AM 01/01/1981' gt_inf max) (sel 0.1) (rank 2) (sarg term) (not-join eligible) (loc 0)

    term[2]: (b.accesstime range (datetime '12:00:00.000 AM 01/01/1981' gt_inf max)) (sel 0.1) (rank 2) (sarg term) (not-join eligible) (indexable accesstime[0]) (loc 0)

    term[3]: b.caseid='6f47822c-2f8b-4f28-be3e-897b75e9abae' (sel 0.02) (sarg term) (not-join eligible) (indexable caseid[0]) (loc 0)


    Query plan:


    iscan

        class: b node[0]

        index: tbl_agent_file_atime term[3]

        filtr: term[2]

        sargs: term[0] AND term[1]

        cost:  fixed 121(0.0/121.0) var 2425(293.9/2131.0) card 98


    Query stmt:


    (select b.fileid from tbl_agent_files b where ((b.accesstime> ?:2 ) and (b.modifiedtime> ?:3 ) and (b.createtime> ?:4 ) and b.caseid= ?:5 ))


    Join graph segments (f indicates final):

    seg[0]: fileid[0] (f)

    seg[1]: fileid[1]

    Join graph nodes:

    node[0]: a(1617/1)

    node[1]: b(97/1)

    Join graph equivalence classes:

    eqclass[0]: fileid[0] fileid[1]

    Join graph edges:

    term[0]: (a.fileid=b.fileid) (sel 0.001) (join term) (mergeable) (inner-join) (loc 0)


    Query plan:


    temp

        order: fileid[0]

        subplan: m-join (inner join)

                     edge:  term[0]

                     outer: temp

                                order: fileid[0]

                                subplan: sscan

                                             class: a node[0]

                                             cost:  fixed 0(0.0/0.0) var 5(4.0/1.0) card 1617

                                cost:  fixed 53(9.0/44.1) var 6(4.0/1.6) card 1617

                     inner: temp

                                order: fileid[1]

                                subplan: sscan

                                             class: b node[1]

                                             cost:  fixed 0(0.0/0.0) var 1(0.2/1.0) card 97

                                cost:  fixed 8(5.2/2.6) var 1(0.2/1.0) card 97

                     cost:  fixed 61(14.3/46.7) var 105(102.3/2.6) card 157

        cost:  fixed 171(121.6/49.3) var 1(0.4/1.0) card 157


    Query stmt:


    select count(a.fileid) from (select a.fileid from tbl_agent_files_keyword a where ((a.cnt>= ?:0 ) and a.caseid= ?:1 )) a (fileid), (select b.fileid from tbl_agent_files b where ((b.accesstime> ?:2 ) and (b.modifiedtime> ?:3 ) and (b.createtime> ?:4 ) and b.caseid= ?:5 )) b (fileid) where (a.fileid=b.fileid)


  • ?
    이용미 2013.12.11 03:05

    이렇게 변경해 보시고, 질의 수행 계획을 다시 한번 확인 부탁 드립니다.


    select count(a.fileid)

    from tbl_agent_files_keyword a inner join tbl_agent_files b 

            on a.fileid = b.fileid and a.caseid = '6f47822c-2f8b-4f28-be3e-897b75e9abae'

    where  

           a.cnt >=1 and 

           b.accesstime > '1981-01-01 00:00:00' AND 

           b.modifiedtime > '1981-01-01 00:00:00' AND 

           b.createtime  > '1981-01-01 00:00:00';

  • ?
    knight 2013.12.17 02:25

    use_merge Hint로 속도 증가를 어느정도 효과를 내었으나


    1. 5만건 짜리 하나, 42만건 짜리 하나 , 이렇게 2개의 인라인 뷰를 use_merge 했는데 여타 my-sql, oracle 등과 비교해서 성능이 많이 떨어지네요


    2. 위 lym 님이 답변하신 SQL은 동일 조건하에서 무쟈게 더 느려짐



List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 SQLGate for CUBRID 영구 무료 라이선스 제공 file admin 2020.04.09 4443
1287 큐브리드 매니저 접속 안되고 있습니다. 5 file 한걸음 2014.05.23 9716
1286 매니저에서 내려받기 할 경우 out of memory 에러가 납니다. 1 노랑배 2010.09.03 9720
1285 auto_increment 가 7.1 에서는 사용이 되지 않나요? 4 메이커스 2009.08.03 9727
1284 cubrid.jdbc.driver.CUBRIDException: The size of data received from server is different from the expected 오류 확인 부탁드립니다. 3 개발자84 2014.07.18 9727
1283 매니저 실행 오류 질문. 1 신데렐라 2013.01.29 9731
1282 테이블 생성이 안되네요..;; 1 미야프 2009.09.14 9731
1281 PHP 커넥션 실패 문의 1 무리링 2011.03.02 9739
1280 databases 폴더 이동. 2 철이 2016.05.31 9741
1279 [초보문의] 질의편집기 접속 오류 6 삽질중 2009.07.29 9742
1278 Operation would have caused one or more unique constraint violations. 1 곰팅팅이 2016.03.30 9742
1277 cubrid 2008 r4.3.1008.jar 란 파일이 있나요? 1 rex 2013.11.29 9743
1276 loaddb질문입니다 2 삽질쟁이 2009.06.09 9743
1275 응답없음 현상 2 까망이 2011.01.24 9749
1274 영문 대소문자 구분 1 헛개수 2014.07.24 9749
1273 큐브리드 매니저에 데이타베이스 복구가 비활성화 되어있습니다 2 초보 2010.02.08 9752
1272 QUBRID 매니저에서 실행계획을 볼려면.. 2 파란토끼 2013.10.02 9761
1271 리눅스에 큐브리드 2.1설치오류 3 SoMa 2010.09.13 9763
1270 큐브리드를 사용해 윈도환경에서 사용할 프로그램을 개발코자 합니다 1 혜승아빠 2010.01.08 9763
1269 인덱스가 실행이 안되는 것 같아서 요청 드려 봅니다. 3 취우다 2017.04.15 9764
1268 데이터베이스 클래스수와 성능과의 관계에 대한 질문 1 김현성 2011.06.01 9765
Board Pagination Prev 1 ... 131 132 133 134 135 136 137 138 139 140 ... 200 Next
/ 200

Contact Cubrid

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