Composite index design where only a subset will be queried
Consider N partial indexes:

CREATE INDEX tbl_a_b1_idx ON tbl (A) WHERE B1;


All together only occupying slightly more space than a plain btree index on (A). You can have hundreds of indexes like that without problem. (I had a case with ~ 250.) The number is certainly not exhausted by the maximum of possible columns (250 - 1600 depending on column types).

Since each partial index is comparatively small, this will typically benefit performance as long as query patterns match.

Additional indexes may be useful and adding more index expressions may make sense to get index-only scans ....

Using a current version of Postgres is advisable in any case, but for this in particular, since there have been a number of optimizations for partial indexes lately.

To create all DDL statements:

SELECT format ('CREATE INDEX tbl_a_b%1$s_idx ON tbl(a) WHERE b%1$s;', g)
FROM generate_series(1, 24) g;


Returns:

CREATE INDEX tbl_a_b1_idx ON tbl(a) WHERE b1;
CREATE INDEX tbl_a_b2_idx ON tbl(a) WHERE b2;
...


Related:


PostgreSQL multi-column unique constraint and NULL values