Re: Efficient date range search?
От | Jean-Luc Lachance |
---|---|
Тема | Re: Efficient date range search? |
Дата | |
Msg-id | 3DA1C60B.40CDCBF3@nsd.ca обсуждение исходный текст |
Ответ на | Re: Efficient date range search? ("Nigel J. Andrews" <nandrews@investsystems.co.uk>) |
Ответы |
Re: Efficient date range search?
|
Список | 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 по дате отправления: