The Index Sweet Spot
Indexes speed up reads but slow down writes. The art is finding the right balance for your workload. Most applications are read-heavy, so indexing is almost always worth it — but wrong indexes can be worse than none.
Composite Indexes
A composite index on (status, created_at) serves queries that filter by status and sort by date. But the column order matters: put the most selective column first.
INDEX idx_posts_status_date
blog_posts (published, published_at );
blog_posts
published published_at ;
blog_posts published ;
PostgreSQLDatabasePerformanceBackend
Add a comment