Re: Create index on the year of a date column

From: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Create index on the year of a date column
Date: 2003-06-06 10:34:01
Message-ID: 1054895641.18124.46.camel@haggis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2003-06-05 at 11:38, Nick Barr wrote:
> Hi,
>
> I am trying to create an index on the year of a date field, to speed up
> some queries. Table structure is as follows

If, for example, you want all records where item_created_start_date
in calendar year 2001, why not create the index on i_c_s_d and say
WHERE item_created_start_date between '2001-01-01' and '2001-12-31'

--
+-----------------------------------------------------------+
| Ron Johnson, Jr. Home: ron(dot)l(dot)johnson(at)cox(dot)net |
| Jefferson, LA USA http://members.cox.net/ron.l.johnson |
| |
| Regarding war zones: "There's nothing sacrosanct about a |
| hotel with a bunch of journalists in it." |
| Marine Lt. Gen. Bernard E. Trainor (Retired) |
+-----------------------------------------------------------+

In response to

Browse pgsql-general by date

  From Date Subject
Next Message terry 2003-06-06 11:28:29 Re: Nulls get converted to 0 problem
Previous Message Richard Huxton 2003-06-06 10:28:46 Re: EXTERN JOIN with WHEN query