Re: Efficient date range search?

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: shridhar_daithankar(at)persistent(dot)co(dot)in, pgsql-general(at)postgresql(dot)org
Subject: Re: Efficient date range search?
Date: 2002-10-07 17:36:11
Message-ID: 3DA1C60B.40CDCBF3@nsd.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

And that is supposed to be more efficient then
select * from pets where died > {whatever date};

C'mon...

"Nigel J. Andrews" wrote:
>
> SELECT *
> FROM pets
> WHERE
> born <= '2001-07-04 07:01:00+00'
> AND
> (
> died > '2001-07-04 07:01:00+00'
> OR
> died is NULL
> )
>
> Efficient? Well that depends on data distribution, indexes and the 'goodness'
> of choice by the planner. One presumes given the data set that can be rewritten
> numerous ways to experiment on obtaining the best like spliting each half of
> the died test into two queries combined using UNION.
>
> --
> Nigel J. Andrews
> Director
>
> ---
> Logictree Systems Limited
> Computer Consultants
>
> On Mon, 7 Oct 2002, Jean-Luc Lachance wrote:
>
> > If the pet is still alive today died would be NULL and the where clause
> > would not be true.
> >
> > How about this:
> >
> > On insert to pets, set the date to 9999-12-31.
> > On the deth of a pet update the died field.
> >
> > Create an index on died.
> >
> > select * from pets where died > {whatever date}
> >
> > will return the pets that were alive on that date.
> >
> >
> > JLL

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message scott.marlowe 2002-10-07 17:43:27 Re: reorder columns?
Previous Message Jean-Luc Lachance 2002-10-07 17:32:09 Re: Efficient date range search?