Day 24 10 min
psql
1 / 14 · ≈ 9 min left
The problem
Support says the order history page of one customer, id 42, takes seconds to load. You open a terminal on your laptop and connect with psql shop. You need to see the tables, time the slow query, ask PostgreSQL for its plan and pull the rows into a CSV file for the bug report.
The database shop has one table: orders (id bigint PRIMARY KEY, customer_id bigint NOT NULL, region text NOT NULL, total numeric(10,2) NOT NULL) with 3 rows. Your current directory on the laptop holds new_orders.csv, with the header line id,customer_id,region,total and 2 orders. Reps 1 to 9 are typed at the shop=> prompt, reps 10 and 11 in your shell.