Search code examples
amazon-web-servicesdynamodb-queriesamazon-dynamodb

Impact of unique partition key on DynamoDB performance


I have the following table structure. My partitionKey currently are not unique however my sortKey is unique.

I also have a Global Secondary Index where my column Column Units is the partitionKey which is unique.

Will removing the GSI and making the partitionKey to Column Units which is unique make my queries faster and reduce latency.

Reason, I am asking is occasionally I see a spike in DDB calls to this table.

Current Table Structure
GSI - Column Units
Column Zone (partitionKey) Column Units (sortKey)
A unique-1
A unique-2
B unique-3

Solution

  • Removing or Adding Global Secondary Index has no impact on the performance of the base table. A global secondary index is a separate table under the hood and data from the base table get's replicated to it asynchronously.

    If you use the GetItem API to request items, it shouldn't matter if you have a primary key (only partition key) or composite primary key (partition key and sort key).