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 4442
1706 쿼리 브라우져 가져오기 오류 질문 1 joke7 2013.12.24 8810
1705 [연결정보]브로커포트설정 관련 문의. 1 file 씨큐 2013.12.20 11550
1704 Invalid buffer position! 오류 12 알칸펠 2013.12.20 12645
1703 큐브리드에서 제공되는 CUBRIDXADataSource 1 jobis 2013.12.18 9139
1702 lockdb 질문입니다. 1 오니오니 2013.12.17 10700
1701 큐브리드 이중화 관련하여 설정 내용 문의드립니다. 1 신나여 2013.12.17 12480
1700 cm_admin 으로 사용자를 추가해도 쿼리 브라우저에서 접속 불가합니다..도와주세요 1 asuraiv 2013.12.10 12046
1699 csql를 사용하여 스크립트를 돌리게 되면 에러가 납니다. 1 secret 애정결핍 2013.12.10 6
1698 쿼리 브라우져 가져오기 오류 질문 4 joke7 2013.12.08 10928
» SQL 인라인뷰 응답속도 개선 문의 6 knight 2013.12.07 13270
1696 다른 질문 드립니다 ~ 3 secret 오니오니 2013.12.06 5
1695 eclipse plugin 설치 에러 1 file 바다~ 2013.12.06 9777
1694 Failed to connect to database server, 'dbname', on the following host(s) 3 뽀다구 2013.12.06 15465
1693 다시 문의 드립니다/.. 6 secret 오니오니 2013.12.06 13
1692 이중환 관련 질문 드립니다. 2 jojosale 2013.12.05 8402
1691 csql -u -p -i DB명 캐릭터 셋 설정 1 쩡저리 2013.12.05 10136
1690 배치 진행시 에러 발생 4 카이사르 2013.12.03 17464
1689 select update 쿼리 문의 드립니다. 4 신나여 2013.11.29 26059
1688 cubrid 2008 r4.3.1008.jar 란 파일이 있나요? 1 rex 2013.11.29 9743
1687 큐브리드 포트 설정 질문 드립니다. 1 secret 지나가는 2013.11.29 6
Board Pagination Prev 1 ... 110 111 112 113 114 115 116 117 118 119 ... 200 Next
/ 200

Contact Cubrid

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