테이블에서 날짜를 기준으로 데이터를 뽑아오더니 문득 timestamp로 설정해둔 컬럼을 인덱스를 걸면 좀더
빨라지겠구나 라는 생각이 들어서 index를 설정해봤는데 cost 개선이 안되서 문의 드려요.
index before )
db=# explain select count(*) from table where tm_a between '2011-01-01 00:00:00' and '2011-08-01 23:59:59';
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=44.19..44.20 rows=1 width=0)
-> Seq Scan on table (cost=0.00..41.94 rows=900 width=0)
Filter: ((tm_a >= '2011-01-01 00:00:00'::timestamp without time zone) AND (tm_a <= '2011-08-01 23:59:59'::timestamp without time zone))
(3 rows)
index make )
db=# create index idx_tm_a on table(tm_a);
CREATE INDEX
index after )
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=44.19..44.20 rows=1 width=0)
-> Seq Scan on table (cost=0.00..41.94 rows=900 width=0)
Filter: ((tm_a >= '2011-01-01 00:00:00'::timestamp without time zone) AND (tm_a <= '2011-08-01 23:59:59'::timestamp without time zone))
(3 rows)
조언 부탁 드립니다 ^ ^ |