Re: Planner question - "bit" data types - Mailing list pgsql-performance

From Bruce Momjian
Subject Re: Planner question - "bit" data types
Date
Msg-id 200909180319.n8I3JYo13347@momjian.us
Whole thread Raw
In response to Re: Planner question - "bit" data types  (Bruce Momjian <bruce@momjian.us>)
List pgsql-performance
Bruce Momjian wrote:
> > Interesting... declaring this:
> >
> > create function ispermitted(text, integer) returns boolean as $$
> > select permission & $2 = permission from forum where forum.name=$1;
> > $$ Language SQL STABLE;
> >
> > then calling it with "ispermitted(post.forum, '4')" as one of the terms
> > causes the query optimizer to treat it as a FILTER instead of a nested
> > loop, and it works as expected.
> >
> > However, I don't think I can index that - right - since there are two
> > variables involved which are not part of the table being indexed.....
>
> That should index fine.  It is an _expression_ index so it can be pretty
> complicated.

Oh, you have to use the exact same syntax in there WHERE clause for the
expression index to be used, then use EXPLAIN to see if the index is
used.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

pgsql-performance by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Planner question - "bit" data types
Next
From: Karl Denninger
Date:
Subject: Re: Planner question - "bit" data types