Background Image

FORUM

조회 수 13268 추천 수 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 4256
2156 cubrid broker start fail 2 나쁜천사 2015.08.07 9257
2155 update 명령어가 안먹어요.... 6 file 삼돌이 2015.08.07 6649
2154 CUBRID.Data.dll(9.3.0.3) vs Interop.CUBRIDProvider (1.0.0.0) 차이점 2 초보1 2015.08.06 6037
2153 아랫글 추가 질문입니다. 2 오명일 2015.08.04 4397
2152 큐브리드 1.4 사용중입니다. 2 오명일 2015.08.04 3952
2151 1MB 넘는 데이터 문자열 붙일때 오류 1 빛날구름 2015.08.04 5436
2150 데이타베이스의 생성되는 테이블 가능 갯수 1 시나브로 2015.07.23 5330
2149 unloaddb 문의 4 chocob 2015.07.22 6116
2148 테이블 별 캐릭터셋 확인 1 chocob 2015.07.22 6347
2147 시스템 구조도 문의 드립니다. 1 끌레도르 2015.07.21 5707
2146 ERROR CODE = -51 발생하였습니다. 문의 드립니다. 1 청백-e 2015.07.20 4586
2145 lock cache 문의 드립니다. 1 끌레도르 2015.07.17 3963
2144 검색속도문의 1 아델라이데 2015.07.14 5002
2143 문의 사항 3 Envy 2015.07.13 4130
2142 HA 구성하고 SLAVE 로 넘어갔을 시에 INSERT 1 서윤아빠 2015.07.11 4807
2141 한글 깨짐이 발생하고 있습니다. 2 file 하늘꿈 2015.07.10 9172
2140 성능 측정 문의 드립니다. 1 끌레도르 2015.07.10 3751
2139 HA 운영중 unloaddb 시 주의사항 문의 1 chocob 2015.07.09 4192
2138 DBCP 부분이 잘 않되고 있습니다. 4 file 하늘꿈 2015.07.09 5677
2137 다른서버로 복구 문의 2 chocob 2015.07.09 5238
Board Pagination Prev 1 ... 87 88 89 90 91 92 93 94 95 96 ... 199 Next
/ 199

Contact Cubrid

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