PostgreSQL: how can I create an index for querying variable combinations of booleans
I've found a solution by casting the bools to ints and indexing using a bloom index. The query now executes in 27ms using a bitmap index scan compared to the previous 100ms of the sequential scan.
The index:
CREATE INDEX bloom_idx ON person USING bloom (
    CAST(color_is_red as int), CAST(color_is_green as int), CAST(color_is_blue as int), CAST(color_is_yellow as int), 
    CAST(seeks_red as int), CAST(seeks_green as int), CAST(seeks_blue as int), CAST(seeks_yellow as int)

);

The query:
explain (analyze, buffers, format text) 
SELECT id
FROM person 
WHERE CAST(color_is_red as int) = 0
  AND CAST(color_is_blue as int) = 0
  AND CAST(seeks_red as int) = 1
  AND 
    (
        CAST(seeks_creative as int) = 1
        OR CAST(seeks_technical as int) = 1
    )
limit 200;

The explain output:
https://explain.depesz.com/s/piUf
&quot;Limit  (cost=20348.00..20352.04 rows=1 width=4) (actual time=27.660..27.824 rows=200 loops=1)&quot;
&quot;  Buffers: shared hit=1998&quot;
&quot;  -&gt;  Bitmap Heap Scan on person  (cost=20348.00..20352.04 rows=1 width=4) (actual time=27.658..27.803 rows=200 loops=1)&quot;
&quot;        Recheck Cond: (((color_is_red)::integer = 0) AND ((color_is_blue)::integer = 0) AND ((seeks_red)::integer = 1))&quot;
&quot;        Rows Removed by Index Recheck: 58&quot;
&quot;        Filter: (((seeks_creative)::integer = 1) OR ((seeks_technical)::integer = 1))&quot;
&quot;        Rows Removed by Filter: 72&quot;
&quot;        Heap Blocks: exact=37&quot;
&quot;        Buffers: shared hit=1998&quot;
&quot;        -&gt;  Bitmap Index Scan on bloom_idx_no_skills  (cost=0.00..20348.00 rows=1 width=0) (actual time=24.281..24.281 rows=156588 loops=1)&quot;
&quot;              Index Cond: (((color_is_red)::integer = 0) AND ((color_is_blue)::integer = 0) AND ((seeks_red)::integer = 1))&quot;
&quot;              Buffers: shared hit=1961&quot;
&quot;Planning Time: 0.458 ms&quot;
&quot;Execution Time: 27.905 ms&quot;

(Querying a table of 1 million randomly generated rows)