Re: Planner question - "bit" data types

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bruce Momjian wrote:
Karl Denninger wrote:
  
Yes.  In addition, functions that are part of _expression_ indexes do get
their own optimizer statistics, so it does allow you to get optimizer
stats for your test without having to use booleans.

I see this documented in the 8.0 release notes:

     * "ANALYZE" now collects statistics for _expression_ indexes (Tom)
       _expression_ indexes (also called functional indexes) allow users
       to index not just columns but the results of expressions and
       function calls. With this release, the optimizer can gather and
       use statistics about the contents of _expression_ indexes. This will
       greatly improve the quality of planning for queries in which an
       _expression_ index is relevant.

Is this in our main documentation somewhere?

  
      
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
It does not appear I can create an index on that (not that it appears to be necessary for decent performance)

create index forum_ispermitted on forum using btree(ispermitted(name, permission));
ERROR:  functions in index _expression_ must be marked IMMUTABLE
ticker=#

The function is of course of class STATIC.

-- Karl


begin:vcard
fn:Karl Denninger
n:Denninger;Karl
email;internet:karl@xxxxxxxxxxxxx
x-mozilla-html:TRUE
version:2.1
end:vcard

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux