patternMinor
DynamoDB - Multiple range keys
Viewed 0 times
rangedynamodbkeysmultiple
Problem
Is it possible to have multiple fields as range key?
Say I have a table where each row is uniquely identified by `
How can I have more than 2 fields as a primary key in DynamoDB?
Say I have a table where each row is uniquely identified by `
-------------------------------
A | B | C | D | E |
-------------------------------
where A is the primary hash key
and I want B and C to be the primary range` keys.How can I have more than 2 fields as a primary key in DynamoDB?
Solution
You can't have more than 2 fields as primary key in DynamoDB.
As a workaround you can create
Consider using filter expressions, you will probably end up using more read throughput (filtering is performed after data is received from db) than you need but get the desired results.
As a workaround you can create
local secondary index for each field that you want to be a range key. But you will not be able to build query with multiple range keys simultaneously because DynamoDB can only use one index at a time.Consider using filter expressions, you will probably end up using more read throughput (filtering is performed after data is received from db) than you need but get the desired results.
Context
StackExchange Database Administrators Q#116280, answer score: 9
Revisions (0)
No revisions yet.