X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 83B42D1B503 for ; Wed, 1 Oct 2003 18:36:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 96354-02 for ; Wed, 1 Oct 2003 15:35:57 -0300 (ADT) Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) by svr1.postgresql.org (Postfix) with ESMTP id 677B4D1B500 for ; Wed, 1 Oct 2003 15:35:56 -0300 (ADT) Received: from 6-allhosts (d226-85-166.home.cgocable.net [24.226.85.166]) by bob.samurai.com (Postfix) with ESMTP id 84BBF1D65; Wed, 1 Oct 2003 14:35:56 -0400 (EDT) Subject: Re: Optimizing >= and <= for numbers and dates From: Neil Conway To: Dimitri Nagiev Cc: PostgreSQL Performance In-Reply-To: <3603.1065030329@www60.gmx.net> References: <1065029881.85344.138.camel@jester> <3603.1065030329@www60.gmx.net> Content-Type: text/plain Message-Id: <1065033355.381.97.camel@tokyo> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 01 Oct 2003 14:35:55 -0400 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/34 X-Sequence-Number: 3782 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