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

From: Neil Conway <neilc(at)samurai(dot)com>
To: Dimitri Nagiev <dnagiev(at)gmx(dot)de>
Cc: PostgreSQL Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Optimizing >= and <= for numbers and dates
Date: 2003-10-01 18:35:55
Message-ID: 1065033355.381.97.camel@tokyo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, 2003-10-01 at 13:45, Dimitri Nagiev wrote:
> template1=# explain analyze select * from mytable where
> mydate>='2003-09-01';
> QUERY PLAN
>
>
> ---------------------------------------------------------------------------------------------------------------
> 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
> (3 rows)

It may well be the case that a seqscan is faster than an index scan for
this query. Try disabling sequential scans (SET enable_seqscan = false)
and re-running EXPLAIN ANALYZE: see if the total runtime is smaller or
larger.

-Neil

In response to

Browse pgsql-performance by date

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