25/32
Sign inSign up free

1104. Query Orders by Customer Without a Scan

medium 20 XP ~10 minHands-on lab

The table reviews-orders has the partition key order_id. The "my orders" page needs every order of one customer (attribute customer_id), newest first, and today it scans the whole table to find them. It gets slower and more expensive every week.

Task

  • Add a global secondary index named by-customer to reviews-orders, with partition key customer_id and sort key created_at (both strings).
  • The index projects all attributes, so the page can read orders from it directly.
  • A query on by-customer for customer c-1001 returns that customer's 3 orders.
  • Keep the table and all its items.

This machine has an AWS-style account (an emulator: nothing is billed). Your AWS CLI is signed in as the account's administrator.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.