public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Teodor Sigaev <[email protected]>
Cc: Rob Imig <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Performant queries on table with many boolean columns
Date: Thu, 21 Apr 2016 09:12:49 -0700
Message-ID: <CAKFQuwbij6yfxixc-LSq6dtt9a=6cTZyHNJwJnrG0-PGAmGHCA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CANcrS5pR1P1Tj=e-RQQ=FF3WPAy_fyruS0YJer-+iJHxR1JAiA@mail.gmail.com>
	<[email protected]>
	<CAKFQuwY3z7oGwriDie4guGPudy_k8S4wWJKrTRy7zPKjTUm=wQ@mail.gmail.com>
	<[email protected]>
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgsql-performance>

On Thu, Apr 21, 2016 at 3:04 AM, Teodor Sigaev <[email protected]> wrote:

>     looks like a deal for contrib/bloom index in upcoming 9.6 release
>> ​Curious, it doesn't look like it will work with booleans out of the box.
>> http://www.postgresql.org/docs/devel/static/bloom.html
>>
>
> There is no rocket science here:
> # create table x (v bool);
> # create index i on x using bloom ((v::int4));
> # set enable_seqscan=off; --because of empty table
> # explain select * from x where v::int4 = 1;
>                             QUERY PLAN
> ------------------------------------------------------------------
>  Bitmap Heap Scan on x  (cost=25.08..35.67 rows=14 width=1)
>    Recheck Cond: ((v)::integer = 1)
>    ->  Bitmap Index Scan on i  (cost=0.00..25.07 rows=14 width=0)
>          Index Cond: ((v)::integer = 1)
>
> Or cast it to "char" type (with quoting!)
>
>
​At that point you should just forget bool exists and define the columns as
int4.

I'll give you points for making it work but its not a solution I'd be proud
to offer up.

David J.
​


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Performant queries on table with many boolean columns
  In-Reply-To: <CAKFQuwbij6yfxixc-LSq6dtt9a=6cTZyHNJwJnrG0-PGAmGHCA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox