pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Glaesmann <grzm@myrealbox.com>
Cc: pgsql-novice@postgresql.org
Subject: Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)
Date: Wed, 22 Oct 2003 13:44:50 -0400
Message-ID: <17556.1066844690@sss.pgh.pa.us> (raw)
In-Reply-To: <461424BA-04B2-11D8-81AE-0005029FC1A7@myrealbox.com>
References: <461424BA-04B2-11D8-81AE-0005029FC1A7@myrealbox.com>

Michael Glaesmann <grzm@myrealbox.com> 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



view thread (9+ messages)  latest in thread

Message-ID: <17556.1066844690@sss.pgh.pa.us>
Permalink:  ../17556.1066844690@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17556.1066844690@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, grzm@myrealbox.com, pgsql-novice@postgresql.org
  Subject: Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)
  In-Reply-To: <17556.1066844690@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox