Re: Planner question - "bit" data types

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Karl Denninger <karl(at)denninger(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Planner question - "bit" data types
Date: 2009-09-18 03:19:34
Message-ID: 200909180319.n8I3JYo13347@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Karl Denninger 2009-09-18 03:49:28 Re: Planner question - "bit" data types
Previous Message Bruce Momjian 2009-09-18 03:13:32 Re: Planner question - "bit" data types