psql -d appdb -c "CREATE INDEX idx_orders_user ON orders (user_id) WHERE status = 'open';"
Create a partial index
A partial index covers only rows matching the WHERE clause, so it is smaller and cheaper to maintain when most queries target open orders. The planner uses it when the query's conditions imply the predicate.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.