database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 8793 게시물 읽기
No. 8793
쿼리문좀 봐주세요
작성자
이기자(k3i2)
작성일
2011-03-17 10:48ⓒ
2011-03-17 10:48ⓜ
조회수
8,036

8.1 -> 8.4버전으로 업하면서 dump받았던 데이타를 Restore시켰더니 똑같은 쿼리인데 엄청 느려졌습니다.

   Select t_in.mcode, t_in.serial
   From t_in left join t_out on t_in.mcode=t_out.mcode and
    t_in.serial=t_out.serial and t_out.jobday <= '2011-03-17'::date
      left join t_bi on t_in.mcode=t_bi.mcode and t_in.serial=t_bi.serial and t_bi.jobday <= '2011-03-17'::date
      left join t_sale on t_in.mcode=t_sale.mcode and t_in.serial=t_sale.serial and t_sale.status<>'C' and t_sale.status<>'CA' and t_sale.saledate <= '2011-03-17'::date
      left join t_sale_ucard on (select status
     from t_sale
     where t_sale.idx=t_sale_ucard.idx_sub)<>'C' and
           (select status
              from t_sale
              where t_sale.idx=t_sale_ucard.idx_sub)<>'CA' and
            t_in.mcode=t_sale_ucard.umcode and t_in.serial=t_sale_ucard.userial and
            t_sale_ucard.saledate <= '2011-03-17'::date
       left join t_gong on t_in.mcode=t_gong.mcode and t_in.serial=t_gong.serial and t_gong.jobday <= '2011-03-17'::date
       left join t_bp on t_in.mcode=t_bp.mcode and t_in.serial=t_bp.serial and t_bp.jobday <= '2011-03-17'::date and
    (t_in.jobday < t_bp.jobday or (t_in.jobday = t_bp.jobday and t_in.settime < t_bp.settime))
       left join t_gp on t_in.mcode=t_gp.mcode and t_in.serial=t_gp.serial and t_gp.jobday <= '2011-03-17'::date
   where coalesce(t_in.debenture_debt, '') <> 'M' and t_in.jobday <= '2011-03-17'::date and
         ( t_sale.idx is null and t_sale_ucard.idx_sub is null and t_gong.idx is null and t_bp.idx is null )
   group by t_in.mcode, t_in.serial

위 쿼리에서 밑에서 두번째,
 ( t_sale.idx is null and t_sale_ucard.idx_sub is null and t_gong.idx is null and t_bp.idx is null )
이것만 없으면 빠릅니다.
근데, 이전 버전땐 안없애도 빨랐거든요. 왜 이러죠?
인덱스도 그대로 살아있는데...
 

이 글에 대한 댓글이 총 1건 있습니다.

 vacuum analyze 명령으로 테이블의 통계자료를 갱신한 상태인지요?

김상기(ioseph)님이 2011-03-25 10:00에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
8797table dump 시 질문이요 [3]
소상무
2011-03-25
8955
8795COPY 질문입니다.
이성필
2011-03-21
8678
8794ODBC 관련 질문입니다.
유닉스
2011-03-17
8750
8793쿼리문좀 봐주세요 [1]
이기자
2011-03-17
8036
8792질의문 질문 드립니다. [1]
권기혁
2011-03-14
7797
8791Win용 PostgreSQL 복구문제...
이기자
2011-03-10
8187
8790embedded sql from Oracle to PostgreSQL
이상필
2011-03-09
9919
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.029초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다