Hi,
i think i need a little help with a problem with pg_statistic.
Lets say i have a table to collect traffic-data.
The table has a column time_stamp of type timesamptz.
The table has a single-column index on time_stamp.
The table has around 5 million records.
If i delete all statistical data from pg_statistic and do a
explain analyze i got this result.
-------------------------------------------------------------------------
explain analyze select * from tbl_traffic where tbl_traffic.time_stamp >= '2003-05-01' and tbl_traffic.time_stamp <
'2003-06-01';
NOTICE: QUERY PLAN:
Index Scan using idx_ts on tbl_traffic (cost=0.00..97005.57 rows=24586 width=72) (actual time=0.19..7532.63
rows=1231474loops=1)
Total runtime: 8179.08 msec
EXPLAIN
-------------------------------------------------------------------------
after i do a vacuum full verbose analyze i got the following result.
-------------------------------------------------------------------------
explain analyze select * from tbl_traffic where tbl_traffic.time_stamp >= '2003-05-01' and tbl_traffic.time_stamp <
'2003-06-01';
NOTICE: QUERY PLAN:
Seq Scan on tbl_traffic (cost=0.00..127224.24 rows=1197331 width=52) (actual time=0.03..14934.70 rows=1231474 loops=1)
Total runtime: 15548.35 msec
EXPLAIN
-------------------------------------------------------------------------
now i disable seqscans with set enable_seqscan to off
and i got the following.
-------------------------------------------------------------------------
explain analyze select * from tbl_traffic where tbl_traffic.time_stamp >= '2003-05-01' and tbl_traffic.time_stamp <
'2003-06-01';
NOTICE: QUERY PLAN:
Index Scan using idx_ts on tbl_traffic (cost=0.00..3340294.11 rows=1197331 width=52) (actual time=0.21..7646.29
rows=1231474loops=1)
Total runtime: 8285.92 msec
EXPLAIN
-------------------------------------------------------------------------
Could anybody explain or give some hint why the index is not used
although it is faster than a sequence-scan ?
BTW:
version
-----------------------------------------------------------
PostgreSQL 7.2 on i686-pc-linux-gnu, compiled by GCC 2.96
Thanks in advance, as