I'm trying to define a dynamodb table so that I can easily filter it based on multiple ranges (date
and type
neither are assumed to be unique). I ended up with the below schema (stolen from DynamoDB queries on secondary index, how to define the indexes), but it doesn't seem to be particularly efficient for the primary use case (returning data after filtering by 2 ranges).
Is it better to make type
a range on the primary table and set date
as a localSecondaryIndex. Or is there another method which keeps the flexibility associated with GSIs.
Properties:
TableName: TableName
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: date
AttributeType: S
- AttributeName: type
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
GlobalSecondaryIndexes:
- IndexName: dateIndex
KeySchema:
- AttributeName: date
KeyType: HASH
Projection:
ProjectionType: KEYS_ONLY
ProvisionedThroughput:
ReadCapacityUnits: 100
WriteCapacityUnits: 100
- IndexName: typeIndex
KeySchema:
- AttributeName: type
KeyType: HASH
Projection:
ProjectionType: KEYS_ONLY
ProvisionedThroughput:
ReadCapacityUnits: 100
WriteCapacityUnits: 100
ProvisionedThroughput:
ReadCapacityUnits: 100
WriteCapacityUnits: 100