I'm trying to design a simple configuration lookup table in dynamodb. I want to store three categories of data - "dropdowns", "metrics" and "fields".
Each category would have mutiple entries under them for example 100 dropdowns, 50 metrics and 200 fields.
I want the following operations:
1. Get all dropdowns or metric or fields config. But not all at the same time.
2. Ability to get only dropdowns/metrics/fields starting with a prefix.
I'm thinking of below -
Partition key: category (DROPDOWN/METRIC/FIELD)
Sort key: type-id
pk | sk |
---|---|
DROPDOWN | type1-1234 |
DROPDOWN | type1-1235 |
DROPDOWN | type2-1234 |
METRIC | type1-123 |
FIELD | type1-123 |
This design allows me to fetch all by the required category. And also I can further filter by type within a category by using BEGINS_WITH operator on the sk.
However, I understand having a non-uniform partition key is not recommended as it can lead to problems of hot partition. Can someone suggest an alternative table design that works with my use case?
Note: Total records to store in the table is not big. (< ~10,000)
Your design is fine for your needs.
If you had to load 10,000 items per second instead of 10,000 total, that's when you'd want to do a little extra thinking about "heat".