A startup uses Cloud SQL (MySQL) for a blogging platform. The schema has a table 'posts' with columns: post_id (auto-increment PK), title, content, author_id, created_at. The application frequently runs a query to display the latest 10 posts from a specific author: SELECT * FROM posts WHERE author_id = ? ORDER BY created_at DESC LIMIT 10. This query is slow when an author has thousands of posts. The team wants to optimize this query without changing the application code. What schema change will be most effective?
This index directly supports the query, allowing an index range scan and limit.
Why this answer
Option A is correct. A composite index on (author_id, created_at) allows the database to efficiently find the posts for a given author ordered by created_at without scanning all rows. Option B (query cache) is not a schema change.
Option C (Spanner) is a different database. Option D (partitioning) could help but ordering across partitions is complex and not as effective.