From: Andre Schubert <andre@km3.de>
To: pgsql-performance@postgresql.org
Subject: problem with pg_statistics
Date: Thu, 26 Jun 2003 15:15:15 +0200
Message-ID: <20030626151515.5fd0faf0.andre@km3.de> (raw)
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=1231474 loops=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=1231474 loops=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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: andre@km3.de
Subject: Re: problem with pg_statistics
In-Reply-To: <20030626151515.5fd0faf0.andre@km3.de>
References: <20030626151515.5fd0faf0.andre@km3.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox