I have a table with columns A (typedate), B1 ... B24 (all boolean).
Generally, A will always be used in every query and only one of B1 ... B24. A large subset of the B columns (more than half) will generally be queried more than the rest, but all of them will be used fairly frequently.
Should I create indexes on 24 two-tuples of (A, B1) ... (A, B24)?
Or 1 huge composite index encompassing all the columns?
If I'm creating a lot of indexes, at what point am I adding too many indexes to the table and what is the approach to working that out? The table is used in a lot of core functionality and will be queried very frequently.
The B columns will only be filtered by true, and generally only one B column will be used in a single query. So the where clause of the query will generally look like:
... WHERE A = '2018-11-22' AND B12
(A, B1),(A, B13), etc.? But please disclose your version of Postgres first. – Erwin Brandstetter Nov 22 '18 at 16:56WHERE A = foo AND B1 = bar– Isaac Nov 22 '18 at 16:58... AND B1 = true(or simply... AND B1)? Meaning your queries will retrieve rows where the BN column is set (true)? – Erwin Brandstetter Nov 22 '18 at 17:03