Re: Optimizing >= and <= for numbers and dates

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: "Dimitri Nagiev" <dnagiev(at)gmx(dot)de>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Optimizing >= and <= for numbers and dates
Date: 2003-10-01 19:06:17
Message-ID: gs8mnv4nfi6g1mqhntia6dq409dl4ov60d@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, 1 Oct 2003 19:45:29 +0200 (MEST), "Dimitri Nagiev"
<dnagiev(at)gmx(dot)de> wrote:
>template1=# explain analyze select * from mytable where
>mydate>='2003-09-01';
> Seq Scan on mytable (cost=0.00..2209.11 rows=22274 width=562) (actual time=0.06..267.30 rows=22677 loops=1)
> Filter: (mydate >= '2003-09-01'::date)
> Total runtime: 307.71 msec

Didn't you say that there are 25000 rows in the table? I can't
believe that for selecting 90% of all rows an index scan would be
faster. Try

SET enable_seqscan = 0;
explain analyze
select * from mytable where mydate>='2003-09-01';

If you find the index scan to be faster, there might be lots of dead
tuples in which case you should

VACUUM FULL mytable;

Servus
Manfred

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Oleg Lebedev 2003-10-01 21:02:43 Re: TPC-R benchmarks
Previous Message scott.marlowe 2003-10-01 19:04:56 Re: Optimizing >= and <= for numbers and dates