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 6925 게시물 읽기
No. 6925
재고조회시 조회시간이 너무 늦습니다.
작성자
작성일
2006-12-05 10:27
조회수
3,516

각 테이블의 idx:자동증가 인덱스 stime: 저장시간, jdate:작업일자 입니다.

select idx,stime,jdate,물품,물품코드,단가,현재상태

from( select idx,stime,jdate,물품,물품코드,단가,\'I\'as 현재상태 from t_입고 where jdate<=:요청일자

union select idx,stime,jdate,물품,물품코드,단가,\'O\'as 현재상태 from t_출고 where jdate<=:요청일자

union select idx,stime,jdate,물품,물품코드,단가,\'B\'as 현재상태 from t_반입 where jdate<=:요청일자

union select idx,stime,jdate,물품,물품코드,단가,\'P\'as 현재상태 from t_반품 where jdate<=:요청일자

union select idx,stime,jdate,물품,물품코드,단가,\'S\'as 현재상태 from t_판매 where jdate<=:요청일자

)a where a.stime=(select max(stime) from(

select stime from t_입고 where jdate<=:요청일자

union select stime from t_출고 where jdate<=:요청일자

union select stime from t_반입 where jdate<=:요청일자

union select stime from t_반품 where jdate<=:요청일자

union select stime from t_판매 where jdate<=:요청일자)b

where a.물품코드=b.물품코드 and a.현재상태 in (\'I\',\'O\',\'B\')

order by a.물품,a.stime

 

구문은 이런형식인데,

같은구문으로 Ms-SQL과 PostgreSQL으로 테스트한결과,

Ms-SQL은 5초도 안걸리는 반면, PostgreSQL은 2분도 더 걸립니다.

더 이해가 안가는건, 자료양이 같은 매장에서 Ms-SQL은 6개월분, PostgreSQL은 겨우 3일분입니다.

Ms-SQL이 수백배 더 많다는 거죠.

PostgreSQL이 union이 늦어서 그런건가요?

좀 빠른 검색을 할려면 어떻게 해야죠?

[Top]
No.
제목
작성자
작성일
조회
6928재고조회 쿼리인데, ms-sql에 비해 시간이 너무 오래 걸립니다. [5]
이기자
2006-12-05
4531
6927아랫분 아스키... 댓글이 안돼서 새글로... [1]
이기자
2006-12-05
3392
6926조회시 아스키값 가져오기 [2]
초보
2006-12-05
3842
6925재고조회시 조회시간이 너무 늦습니다.
2006-12-05
3516
6924급질문입니다. 고수님들 제발 도와주세요. [1]
김성근
2006-12-04
3962
6923postgreSQL 접속관련 질문드립니다. ㅠ_ㅠ [1]
hir
2006-12-04
6989
6922쿼리의 실행시간 [1]
lws
2006-12-01
3734
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.017초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다