Ravi Sir's Cards › AWS
Partition key and sort key
This revision card explains Partition key and sort key. It starts from the need that bad keys create hot partitions and slow queries. It describes pK spreads data. SK orders items that share a PK for range queries. The how-to section notes design from access patterns first — what will you Query? An example on the card is userId + createdAt lets you list one user's notes newest first.
Read card text
What this card says
Why do we need it?
Bad keys create hot partitions and slow queries.
What is it?
PK spreads data. SK orders items that share a PK for range queries.
How to do it
Design from access patterns first: what will you Query?
PK userId SK noteId
Example
userId + createdAt lets you list one user's notes newest first.