BUG #4800: constraint_exclusion could be smarter with bool conversion - Mailing list pgsql-bugs

From Alex
Subject BUG #4800: constraint_exclusion could be smarter with bool conversion
Date
Msg-id 200905081036.n48AaITQ052818@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #4800: constraint_exclusion could be smarter with bool conversion
List pgsql-bugs
The following bug has been logged online:

Bug reference:      4800
Logged by:          Alex
Email address:      alex@xdcom.org
PostgreSQL version: 8.3.6
Operating system:   rhel5
Description:        constraint_exclusion could be smarter with bool
conversion
Details:

Table "public.foo1"
Column       |          Type          |     Modifiers
-------------+------------------------+--------------------
 val         | character varying(16)  | not null
 mask        | integer                | default 0
Check constraints:
    "foo_1_mask_check" CHECK (mask = 1)
Inherits: foo

=> EXPLAIN select * from foo1 where mask >1;
                QUERY PLAN
------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0)
   One-Time Filter: false
(2 rows)

=> EXPLAIN select * from foo1 where (mask &2)::bool;
                           QUERY PLAN
-----------------------------------------------------------------
 Seq Scan on foo1  (cost=0.00..100.32 rows=896 width=59)
   Filter: ((mask & 2))::boolean
(2 rows)


There many children of table foo like foo1,..fooN. with different
check(mask=2^N).
I wish constraint_exclusion to be smarter with bool conversion so that
'select * from foo where (mask&5)::bool' can be faster;

pgsql-bugs by date:

Previous
From: "Alex"
Date:
Subject: BUG #4799: BitMapAnd never works with gin
Next
From: "Peter Much"
Date:
Subject: BUG #4801: Performance failure: 600 MB written to each WAL log