Reputation: 1149
I'm working on an intranet app, where one of the requirements is to display recent news from inside the company. This thing doesn't need to be "webscale"--we have less than 20,000 users, and of course they won't all be logging in at the same time. We're going with DynamoDB not so much because we need its scalability, but more because it's fairly cheap and easy to use from Lambda (where our app code will run).
With all that being said, I need a way to display the most recent, say, 5 news articles. I can think of two ways to do this:
I know neither of these is ideal or playing to DynamoDB's strengths, but is one of them "less bad"? I'm also open to other solutions, of course.
Upvotes: 0
Views: 55
Reputation: 10712
Option 2 (or a variant) looks better. Query on the timestamp sort index with ScanIndexForward = false
to achieve descending order. Timestamp value can either be a numeric timestamp or ISO format string (YYYY-DD-MM HH:mm:ss
) - either is sortable.
For the partition key, you can either use a dummy value for all records (but make it short to save space), or a subset of the timestamp (year or year-month).
Upvotes: 1