pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Rajesh Kumar Mallah. <mallah@trade-india.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Index usage on date feild , differences in '>' and '>='
Date: Wed, 18 Sep 2002 23:37:39 -0700 (PDT)
Message-ID: <20020918233621.A23870-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <200209191208.46626.mallah@trade-india.com>

On Thu, 19 Sep 2002, Rajesh Kumar Mallah. wrote:

> I am trying to improve a  query to use  existing indexes but facing diffculty.
>
>
> Looks like 'between' amd '>=' are not using indexes althoug > and < does.
> all my application code uses between and i am sure it use to work fine
> at one point of time.
>
>
> regds
> mallah.
>
> SQL TRANSCRIPT:
> ======================================================================================
>
> tradein_clients=> explain  select   list_id from eyp_rfi a where  generated >  '2002-08-13' and generated <  '2002-09-19'   ;
> NOTICE:  QUERY PLAN:
>
> Index Scan using eyp_rfi_date on eyp_rfi a  (cost=0.00..15796.97 rows=4150 width=4)
>
> EXPLAIN
> tradein_clients=> explain  select   list_id from eyp_rfi a where  generated >=  '2002-08-13' and generated <  '2002-09-19'   ;
> NOTICE:  QUERY PLAN:
>
> Seq Scan on eyp_rfi a  (cost=0.00..17923.81 rows=5061 width=4)

Given how close the two results are (and the fact that they differ by 900
rows), have you tried using set enable_seqscan=off and seeing what
explain gives you for the second query?  My guess is that it'll have
an estimated cost greater than the 17923.81 it's estimating from the
sequence scan.




view thread (4+ messages)  latest in thread

Message-ID: <20020918233621.A23870-100000@megazone23.bigpanda.com>
Permalink:  ../20020918233621.A23870-100000@megazone23.bigpanda.com/
Also on:    postgresql.org/message-id/20020918233621.A23870-100000@megazone23.bigpanda.com

 · 

reply

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-sql@postgresql.org
  Cc: sszabo@megazone23.bigpanda.com, mallah@trade-india.com
  Subject: Re: Index usage on date feild , differences in '>' and '>='
  In-Reply-To: <20020918233621.A23870-100000@megazone23.bigpanda.com>
  References: <200209191208.46626.mallah@trade-india.com> <20020918233621.A23870-100000@megazone23.bigpanda.com>

* 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