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 5C51DD1B4FB for ; Wed, 22 Oct 2003 17:45:42 +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 58475-01 for ; Wed, 22 Oct 2003 14:45:11 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F034ED1B4EF for ; Wed, 22 Oct 2003 14:45:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id h9MHioit017557; Wed, 22 Oct 2003 13:44:50 -0400 (EDT) To: Michael Glaesmann Cc: pgsql-novice@postgresql.org Subject: Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W) In-reply-to: <461424BA-04B2-11D8-81AE-0005029FC1A7@myrealbox.com> References: <461424BA-04B2-11D8-81AE-0005029FC1A7@myrealbox.com> Comments: In-reply-to Michael Glaesmann message dated "Thu, 23 Oct 2003 02:07:53 +0900" Date: Wed, 22 Oct 2003 13:44:50 -0400 Message-ID: <17556.1066844690@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/184 X-Sequence-Number: 8621 Michael Glaesmann writes: > Searching for ways to improve performance, I tried to create a index on > the extract function, but for some reason I couldn't get it to work. > Following the documentation for CREATE INDEX and EXTRACT, I tried > CREATE INDEX dborders_extract_month_idx ON dborders (EXTRACT(MONTH from > date)); > ERROR: parser: parse error at or near "(" at character 61 You can't do that in pre-7.4 releases; the syntax of a functional index can only be "ON table (func(col1,col2,...))" --- that is, a simple, standard-notation function applied to one or more columns of the table. So to do this, you'd need to create an intermediate function along the lines of "month_trunc(date)"; and you'd have to use it in your queries as well as in the index definition. 7.4 is more flexible though --- it will take the above as long as you put an extra set of parentheses in there... regards, tom lane