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
번호 제목 글쓴이 날짜 조회 수
공지 CUBRID 사용자를 위한 DBeaver 도구 출시 안내 admin 2024.04.23 49
공지 SQLGate for CUBRID 영구 무료 라이선스 제공 file admin 2020.04.09 4458
3994 tomcat7 + cubrid 1 깽즈야 2012.07.27 91064
3993 원격접속이 안되네요????????? 2 Chris 2013.07.23 89530
3992 현재 연결은 원격 호스트에 의해 강제로 끊겼습니다 1 바람바람 2013.05.29 84897
3991 CUBRID 7.3 + zeroboard XE 관리자 로그인 에러 1 윤희서 2009.01.17 83642
3990 cub_master: Cannot bind local address... aborting.... Address already in use 4 박상현 2008.11.28 83565
3989 큐브리드 다운로더 오류 발생 5 file 차오이 2008.11.22 78497
3988 zeroboard XE 설치시 'database connect fail' error 4 윤희서 2009.01.16 78164
3987 Image 데이터타입 사용방법 3 AD 2008.11.25 73850
3986 clob 문의 1 김해영 2012.11.29 73008
3985 linux server 환경에서 php 버전은 어떤걸로 선택해야하는지. 1 거기 2008.11.30 66366
3984 델파이에서는 어떻게 사용할수 있을까요? 2 이상원 2008.11.29 65568
3983 if exists 조건 처리문? 2 콩이아부지 2013.03.06 63611
3982 update 쿼리를 이용한 시리얼 수정에 관하여 1 인경수 2008.11.27 63454
3981 큐브리드 2008 설치시 윈도우 서비스에 등록되지 않습니다. 3 file 진이 2008.11.22 63170
3980 CUBRID 7.3 + zeroboard XE 관리자 로그인 에러 1 윤희서 2009.01.17 62130
3979 큐브리드 maven repository 관련 문의 3 StoneHouse 2013.04.30 61468
3978 메니저에서 접속 안되는 오류 2 유나인 2013.08.16 61068
3977 .NET DB 제어를 위한 방법. 2 우페 2008.11.23 60878
3976 JDK가 두개 설치된 경우 선택적으로 JDK를 설정 할 수 있는 방법은 없는지요 1 GoFly 2008.11.28 60615
3975 데이터 이관시 소유자 변경 가능한가요??? 1 델몬트 2013.08.08 60067
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 200 Next
/ 200

Contact Cubrid

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