I'm creating a database of local businesses. My Primary key looks like this:
Partition key: "slug" - used by URL engine
Sort key: "category" - the category of business, such ass "services", "electronics" etc.
How can I scan DynamoDB for the count of businesses within a certain category, while keeping minimum reads? I want to get a result like: "8 electronics, 3 building, 4 services".
I have like 8 categories, maybe scanning the database with "Filter expressions" for each category will be efficient?
Other variables to think about are how often you need these counts and when the counts are needed, at what velocity. It might be cheaper to do an out of band process in Lambda to do these counts every so often and then write the count value back into an item. So when the app needs the counts, it just grabs those items. Otherwise doing counts all the time like this could get expensive for something that probably does not change very often.