Re: What is the difference between these?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: matt(at)followers(dot)net
Cc: Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: What is the difference between these?
Date: 2004-11-05 20:32:28
Message-ID: 11491.1099686748@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Matt Nuzum <matt(dot)followers(at)gmail(dot)com> writes:
> To me, these three queries seem identical... why doesn't the first one
> (simplest to understand and write) go the same speed as the third one?

This is the standard problem that the planner has to guess about the
selectivity of inequalities involving non-constants (like now()).
The guesses are set up so that a one-sided inequality will use a
seqscan while a range constraint will use an indexscan.

See the pgsql-performance archives for other ways of persuading it
that an indexscan is a good idea.

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Allen Landsidel 2004-11-05 20:36:28 Re: Strange (?) Index behavior?
Previous Message Tom Lane 2004-11-05 19:57:40 Re: Strange (?) Index behavior?