Re: Index on immutable function call

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)googlemail(dot)com>
To: Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch>
Cc: Tore Halvorsen <tore(dot)halvorsen(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Index on immutable function call
Date: 2010-01-19 13:54:15
Message-ID: 8e2dbb701001190554q1d27fd10k71f9e39e5982aa6d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2010/1/19 Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch>:
> That works just fine, but is there maybe a way of creating a slighly
> more "generic" index? If I change the ">" with a "<" in the query, index
> cannot of course be used. According to documentation, answer seems to be
> "no"...
>

You could create an index on the difference:

create index long_transformation_index on indexed_table
((data1-this_is_a_long_transformation(data2)));

then rewrite your queries accordingly:

... WHERE data1-this_is_a_long_transformation(data2) > some const (or
< some const)

HTH,
Dean

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-01-19 14:47:35 Re: Index on immutable function call
Previous Message Philippe Lang 2010-01-19 13:26:30 Re: Index on immutable function call