runtime
52 / 88

task Query plans & SARGable filters · hard

Top events without a temporary sort

Return the eight highest-amount events for shopper 5, breaking ties by larger id first. Build a full index with exactly (shopper_id, amount, id). Require an indexed search and no temporary sorting B-tree in the final plan.

what to return

Columns
idamount in this order
Rows
8 rows · in the order asked
Watch for
Order by amount DESC, id DESC, limit 8. Keep source rows unchanged.
This exercise expressly requires avoiding temporary sorting; no general speed claim is made.
Skill
Use reverse index traversal to satisfy a tie-broken top-N request without a temporary B-tree. Refresher: Partitioning & workload trade-offs →

expected result

Your query should return exactly these columns and values. Run it and compare.

expected result8 rows · in this order
idamount
12005900
12004900
3497497

first 3 of 8 rows

data you can query

Sample rows from each table. Each column shows its type underneath; → marks a link to another table.

market_query_log5 columns · 0 rows

all 0 rows

solution.sql
 

Hints and the answer are always available. Using them counts the question as solved with help.