Welcome to your interview.
The question is on your right: Optimizing Slow Queries at Scale. Take a moment with it first.
Talk your thinking through with me if you like - when you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes). Discussion and graded submissions share your five interviewer interactions, so spend them well.
Large analytical queries can become slow as data volume grows, especially in customer reporting and product usage analysis. Interviewers want to see whether you can diagnose the real bottleneck instead of suggesting generic fixes.
You are asked to explain how you would optimize a SQL query that is taking too long to run on a large dataset in PostgreSQL. Walk through how you would investigate the issue, what parts of the query and schema you would inspect, and which changes you would consider across joins, aggregations, filters, CTEs, indexes, and execution plans. If relevant, refer to customer analytics workloads such as queries over Apidel Technologies customer events, accounts, and subscription activity.
Go beyond saying "add an index." The interviewer expects a structured explanation of how you would use EXPLAIN or EXPLAIN ANALYZE, identify expensive operations, reduce scanned data, choose better join strategies, and validate that the optimized query is actually faster without changing the result.