Re: Most efficient way of selecting by date?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Simon Willison <cs1spw(at)bath(dot)ac(dot)uk>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Most efficient way of selecting by date?
Date: 2003-09-09 21:01:52
Message-ID: 20030909210152.GA16181@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, Sep 09, 2003 at 21:30:31 +0100,
Simon Willison <cs1spw(at)bath(dot)ac(dot)uk> wrote:
>
> I have a table which includes a field for the date and time an item was
> added to it. What's the most efficient way of selecting all of the items
> added on a specific date (this is a really basic question but I'm new to
> Postgres)? Also, would it be worth putting an index on the date column
> as most of my selects will be using it?

Probably by using a range. Something like:
select whatever from wherever
where added < '2003-01-03' and added >= '2003-01-02';

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Juan Francisco Diaz 2003-09-09 21:05:54 How to opimize the insertion of data
Previous Message Oliver Fromme 2003-09-09 20:48:11 Re: Modifying pg_shadow?