Re: Efficient date range search? - Mailing list pgsql-general

From Jean-Luc Lachance
Subject Re: Efficient date range search?
Date
Msg-id 3DA1C60B.40CDCBF3@nsd.ca
Whole thread Raw
In response to Re: Efficient date range search?  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Responses Re: Efficient date range search?  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
List 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

pgsql-general by date:

Previous
From: Jean-Luc Lachance
Date:
Subject: Re: Efficient date range search?
Next
From: "Andy Kriger"
Date:
Subject: reorder columns?