Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atBUy-00018v-Cm for pgsql-performance@arkaria.postgresql.org; Thu, 21 Apr 2016 10:06:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1atBUx-0002Pw-EB for pgsql-performance@arkaria.postgresql.org; Thu, 21 Apr 2016 10:06:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1atBTH-0000HM-GU for pgsql-performance@postgresql.org; Thu, 21 Apr 2016 10:04:27 +0000 Received: from hook.sigaev.ru ([93.180.27.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1atBT5-000092-6c for pgsql-performance@postgresql.org; Thu, 21 Apr 2016 10:04:27 +0000 Received: from xor.sai.msu.ru (newmail.postgrespro.ru [93.174.131.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: teodor) by hook.sigaev.ru (Postfix) with ESMTPSA id 054EBB191A0; Thu, 21 Apr 2016 13:04:14 +0300 (MSK) Subject: Re: Performant queries on table with many boolean columns To: "David G. Johnston" Cc: Rob Imig , "pgsql-performance@postgresql.org" References: <5717D07E.3070802@sigaev.ru> From: Teodor Sigaev Message-ID: <5718A59D.4090706@sigaev.ru> Date: Thu, 21 Apr 2016 13:04:13 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org > 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!) -- Teodor Sigaev E-mail: teodor@sigaev.ru WWW: http://www.sigaev.ru/ -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance