| From: | "Shridhar Daithankar" <shridhar_daithankar(at)persistent(dot)co(dot)in> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Efficient date range search? |
| Date: | 2002-10-07 13:37:51 |
| Message-ID: | 3DA1DB87.18914.105ABC42@localhost |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 4 Oct 2002 at 23:35, mvh(at)ix(dot)netcom(dot)com wrote:
> CREATE TABLE "pets" (
> name VARCHAR(20);
> "born" timestamp;
> "died" timestamp;
> );
>
> and I have a LOT of pets (let's say millions) and some don't live too
> long (mice, fruitflies, whatever), and some do (parrots, elephants).
>
> I would like to make a query to say
>
> on july 4 of last year, what pets were alive?
>
> and I would like to make this query right to the minute
>
> on july 4 of last year at 7:01 PM what pets were alive?
Create an index on died field. And query like
select * from pets where died < "last year july 4 7:01 PM;
These will be alive pets then.. Should be pretty efficient.
Bye
Shridhar
--
QOTD: Money isn't everything, but at least it keeps the kids in touch.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Shridhar Daithankar | 2002-10-07 13:52:06 | Re: table linking problem |
| Previous Message | Martijn van Oosterhout | 2002-10-07 13:26:10 | Re: Scale, Normalization, and Table Count |