X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 40D6DD1B56D for ; Wed, 22 Oct 2003 17:56:44 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59513-01 for ; Wed, 22 Oct 2003 14:56:14 -0300 (ADT) Received: from davinci.ethosmedia.com (unknown [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 4B7F7D1B560 for ; Wed, 22 Oct 2003 14:56:13 -0300 (ADT) Received: from [66.219.92.2] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 3807019; Wed, 22 Oct 2003 10:56:49 -0700 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Michael Glaesmann , pgsql-novice@postgresql.org Subject: Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W) Date: Wed, 22 Oct 2003 10:53:56 -0700 User-Agent: KMail/1.4.3 References: <461424BA-04B2-11D8-81AE-0005029FC1A7@myrealbox.com> In-Reply-To: <461424BA-04B2-11D8-81AE-0005029FC1A7@myrealbox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200310221053.56665.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/185 X-Sequence-Number: 8622 Michael, > What is that simple thing I'm overlooking? Any ideas what else I should= =20 > check? (I did a search on 'functional index' in the list archives but=20 > kept getting timed out :( Oh, sorry. There's an implementation issue with funcional indexes, where t= hey=20 can't take parameters other than column names. So you need to do: CREATE FUNCTION get_month ( TIMESTAMPTZ ) RETURNS INTEGER AS=20 ' SELECT EXTRACT(MONTH from $1); ' LANGUAGE sql IMMUTABLE STRICT; Then do=20 CREATE INDEX dborders_date_trunc_idx on dborders=20 (get_month(date)); --=20 -Josh Berkus Aglio Database Solutions San Francisco