Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Michael Glaesmann <grzm(at)myrealbox(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)
Date: 2003-10-22 17:53:56
Message-ID: 200310221053.56665.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

Michael,

> What is that simple thing I'm overlooking? Any ideas what else I should
> check? (I did a search on 'functional index' in the list archives but
> kept getting timed out :(

Oh, sorry. There's an implementation issue with funcional indexes, where they
can't take parameters other than column names. So you need to do:

CREATE FUNCTION get_month (
TIMESTAMPTZ ) RETURNS INTEGER AS
' SELECT EXTRACT(MONTH from $1); '
LANGUAGE sql IMMUTABLE STRICT;

Then do

CREATE INDEX dborders_date_trunc_idx on dborders
(get_month(date));

--
-Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Glaesmann 2003-10-22 18:34:59 Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)
Previous Message Tom Lane 2003-10-22 17:44:50 Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Glaesmann 2003-10-22 18:34:59 Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)
Previous Message Tom Lane 2003-10-22 17:44:50 Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)