Partition keys in DynamoDB-style stores

NoSQL and choosing a database Mid-level Python 3.13+ PostgreSQL 17+ Reviewed By Best Latest Apps

Pick the fix

An events table uses event_date as the partition key and today's writes are throttled. Fix?

Options
Hint 1 of 1

How many partitions does 'today' map to?

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A Partition by a high-cardinality key such as device id, or shard the date with a suffix

Correct. Spreads writes across partitions.

Each partition has its own throughput limit, and today's date sends every write to one partition. A high-cardinality key, or the date plus a random suffix, spreads writes across many partitions.

Why not the others?
  • B Raise provisioned capacity. One partition still has its own limit.
  • C Add a sort key on time. Sort keys don't change which partition takes the writes.
  • D Use Scan with a filter. Makes reads worse and doesn't help writes.

30-second answer

Items are spread across partitions by hashing the partition key, and each partition has throughput limits, so the key must spread traffic evenly and match how you read. A user id often works; a date or a status value doesn't, because today's writes all land on one partition. Design from access patterns: list every query first, then shape partition and sort keys (and secondary indexes) so each query is a single key lookup or range read.

Practise saying it · 30 s. No recording, just a timer

Choose a partition key.

Say your answer out loud, then check which of these points you covered:

  • Even spread
  • Access patterns first
  • Sort key for ranges
  • Write sharding
  • Avoid scans

Deep dive

Sort keys enable range queries within a partition (begins_with, between).

Write sharding: add a suffix (2026-10-31#3) to spread a hot key, then query all suffixes.

Adaptive capacity helps uneven load but doesn't remove per-partition limits.

Scans read the whole table; avoid them on hot paths.

Common mistakes

  • Partitioning by status or date.
  • Designing tables like relational ones and then needing joins.
  • Relying on Scan with filters for common queries.

Senior take & follow-ups

Access patterns first, even spread, sort keys for ranges, and write sharding for hot keys.

Follow-up questions

Think of your answer first, then open the hint.

  1. What's single-table design?

    Show hint

    Storing several entity types in one table with overloaded keys to serve all access patterns.

  2. How do you query by a second attribute?

    Show hint

    A global secondary index on it.

Suggest a fix if something here is wrong or out of date.