Re: Timestamp indexes aren't used for ">="

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jeff Boes" <jboes(at)nexcerpt(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Timestamp indexes aren't used for ">="
Date: 2001-11-10 00:09:20
Message-ID: 29137.1005350960@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"Jeff Boes" <jboes(at)nexcerpt(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Dong B Calmada 2001-11-10 02:54:17 ERROR: Index 2905559 does not exist
Previous Message Stephan Szabo 2001-11-09 22:58:42 Re: Timestamp indexes aren't used for ">="