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 48
공지 SQLGate for CUBRID 영구 무료 라이선스 제공 file admin 2020.04.09 4458
1734 HA 설정 이후 자동시작이 되지 않습니다. 1 김종언 2014.01.27 7179
1733 ADO update관련 문의드립니다. 1 SD2 2014.01.26 7686
1732 JBoss connection pool 설정방법 문의드립니다. 1 secret 땡땡이 2014.01.25 6
1731 쿼리 실행 오류 문의 1 종이 2014.01.25 11624
1730 큐브리드 외부 서버 접속 관련 질문입니다, 1 file 프라우닐 2014.01.23 12590
1729 큐브리드 64bit 설치 후 실행 문제.(2) 1 file 초보개발꾼 2014.01.21 14394
1728 브로커 타임아웃 설정 가능여부 문의 1 장경수 2014.01.20 11130
1727 데이터베이스가 사라집니다2 1 프라우닐 2014.01.20 8059
1726 파티션 테이블에 대해서.. 1 알칸펠 2014.01.17 11067
1725 CLASS 삭제문의 1 키싱유 2014.01.17 9361
1724 MS-Access ODBC 연결테이블 2 무말랭이 2014.01.16 12396
1723 데이터베이스가 사라집니다. 4 프라우닐 2014.01.16 9830
1722 큐브리드 64bit 설치 후 실행 문제. 1 초보개발꾼 2014.01.16 12043
1721 그랜트 권한 문의 드립니다. 1 키싱유 2014.01.14 10716
1720 어떠한 쿼리문을 써야햐는지... 정확이 모르겠습니다. 1 프라우닐 2014.01.13 9534
1719 톰캣 연동시 설정 에러입니다. 1 file 깨똑 2014.01.09 19650
1718 대량데이터 입력시 딜레이 구간에 대해서... 1 file 알칸펠 2014.01.09 10260
1717 큐브리드 매니저 Xe설치후 게시판관리하려면 1 Kai 2014.01.09 12124
1716 TIMEZONE 질문 1 은팔 2014.01.08 12461
1715 c# asp.net HA및 브로커 12 알칸펠 2014.01.07 11923
Board Pagination Prev 1 ... 109 110 111 112 113 114 115 116 117 118 ... 200 Next
/ 200

Contact Cubrid

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