Say I have this table
CREATE TABLE users(
id INT,
name TEXT,
state TEXT,
needs_advice TEXT
)
and there are 2 usage patterns
- querying users who need financial advice
- querying users who need relationship advice
and I'm thinking of adding these 2 partial indices or 1 generic index
CREATE INDEX idx_users_needs_financial_advice
ON users(state, needs_advice)
WHERE needs_advice = 'financial'
AND state = 'help'
CREATE INDEX idx_users_needs_relationship_advice
ON users(state, needs_advice)
WHERE needs_advice = 'relationship'
AND state = 'help'
and using a more generic index below
CREATE INDEX idx_users_needs_relationship_advice
ON users(state, needs_advice)
What would the tradeoffs be between using these 2 partial indices versus the 1 more generic index? My initial impression is the 2 partial indices require less maintenance than the 1 generic index but I'm not sure.