Reputation: 9
Suppose I'm building a board game, I divide my board in cells, the board has 100 columns by 100 rows.
In dynamodb, I'm storing the player's position in 2 attributes, col and row.
I need to query what players are in a given section of the board, like this: Give me all the players that are currently in this section: (col >= 10 AND col <= 20) AND (row >= 30 and row <= 50)
Is it possible to create an index for it so I don't have to scan the whole table every time? Follow up question, can this be done if I'm using a single table for all the entities in my application?
I'm completely new to dynamodb
Upvotes: 0
Views: 37
Reputation: 19813
You'll only be able to do the condition on one of the attributes, but given its a boardgame I think client side filtering on the second attribute will suffice and not impact cost or performance.
This blog post will help you understand how you can create an index with global sort order which you should define the sort key as either col or row.
Upvotes: 0