INCLUDE the columns the query reads as well as the ones it filters
An index-only scan needs every column the query touches to be in the index. Put the filter columns in the key and the rest in INCLUDE, so they do not bloat the key or the sort.
CREATE INDEX orders_customer_recent ON orders (customer_id, created_at DESC)
INCLUDE (status, total_cents);Check the plan says Index Only Scan and that Heap Fetches is near zero after a vacuum.
postgresqlperformance