pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Boes <jboes@nexcerpt.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Timestamp indexes aren't used for ">="
Date: Fri, 09 Nov 2001 19:09:20 -0500
Message-ID: <29137.1005350960@sss.pgh.pa.us> (raw)
In-Reply-To: <9shhnf$23ks$1@news.tht.net>
References: <9shhnf$23ks$1@news.tht.net>

"Jeff Boes" <jboes@nexcerpt.com> writes:
> This leads me to the conclusion that either postgres has a
> bug that is preventing it from actually using the operator
> that is defined on the index (thus falling back to the non-
> indexed comparison), or explain is broken, or my understanding
> of indexes is broken.

The latter.  You are neglecting the fact that an indexscan on an
'=' condition (scan only those values '=' to something) is normally
a lot more selective than an indexscan on a '>=' condition (scan
from that value to the end).

In your example, the '=' condition is estimated to select only
one row, whereas the '>=' condition is estimated to select
39884 rows, or about 10% of the table.  If that estimate is
accurate then very probably the planner made the right choice
--- indexscans that touch more than a couple percent of the table
are normally losers in Postgres, compared to a simple sequential
scan (mainly because Unix kernels like to read ahead on sequential
reads, so seqscan cooperates with the kernel instead of fighting it).

Since you didn't tell us how many rows are really involved, nor
what the actual runtimes were with and without the enable_seqscan
change, we can't tell how close the planner's estimates are to
reality.  But there's no a-priori evidence of brokenness here.

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <29137.1005350960@sss.pgh.pa.us>
Permalink:  ../29137.1005350960@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29137.1005350960@sss.pgh.pa.us

 · 

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-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jboes@nexcerpt.com
  Subject: Re: Timestamp indexes aren't used for ">="
  In-Reply-To: <29137.1005350960@sss.pgh.pa.us>
  References: <9shhnf$23ks$1@news.tht.net> <29137.1005350960@sss.pgh.pa.us>

* 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