Build the right index for support's hottest query
On a SaaS ticket board support constantly runs «open tickets sorted by priority descending, first 50». A simple index on status covers the filter but not the sort — Postgres still sorts the result separately.
A composite index over two columns at once — status plus priority descending — covers both the filter and the sort in one pass. Build a tickets table with id (primary key), status (string up to 20 chars), priority (integer), and created_at (timestamp with timezone), then create an index named tickets_status_priority_idx where status is the first column and priority is the second in descending order.
Just CREATE/ALTER/DROP — no trailing SELECT needed.
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inNo starting schema
This task starts with no tables — you'll create them via CREATE TABLE.