How can improve the performance of this query:
SELECT designs.* FROM designs
WHERE designs.state = 'in_stock'
ORDER BY designs.grade, id DESC
Explain output:
Sort (cost=47475.35..47591.91 rows=46621 width=763)
Sort Key: grade, id
-> Seq Scan on designs (cost=0.00..12304.20 rows=46621 width=763)
Filter: ((state)::text = 'in_stock'::text)
The table has over 250000 records.
Building an index on state doesn't help much.
CREATE INDEX design_order_idx ON designs (grade, id);[postgresql-performance].