Urgent.News

the world's headlines, one feed

Editions

Tech

DynamoDB: GSI, LSI, and related design ideas

This note explains the important DynamoDB concepts in a simple and practical way. First idea: think in access patterns Before designing a DynamoDB table, ask: What questions will the application ask? Which fields will be used for filtering and sorting? Which operations must be fast and cheap? Which data can be deleted or archived later? A good DynamoDB design is not only about storing data. It is…

This summary explains key DynamoDB concepts in a straightforward manner. When designing a DynamoDB table, consider the access patterns your application will use - what questions will be asked and which fields must be fast to query. A Global Secondary Index (GSI) provides an alternative way to access the same table using different partition and sort keys.

Utilize a GSI when your common query pattern doesn't match the main table key, or you need to query by a different field often. It works by keeping a separate index structure storing the indexed attributes, the primary key of the GSI and a pointer to the original item.

Local Secondary Index (LSI) offers another sort key within the same partition key as the base table. Use an LSI when you want to query items within the same partition using a different sort key. It's built inside the same partition as the base table and allows the same partition key with a different sort key. LSI is more inflexible than GSI due to the same partition key requirement, but it's less costly.

A sparse index only includes items with the indexed attribute present, making it useful for optional data. It avoids storing unnecessary index data and focuses the storage. Queries are selective and target specific items based on key values, while scans read the entire table or large portions. Use queries whenever possible as they are faster and cheaper than scans.

Hot partitions occur when one partition key experiences too much traffic, leading to throttling and uneven performance. Mitigate this by choosing a partition key with many possible values and even usage or by using a composite key with a stable prefix and unique suffix.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — it may contain errors, so check the original before relying on it.

Read the original at dev.to →

More in Tech

Terms and Policies

  • CNBC+ offers limited, non-exclusive license to access and use services.
  • Content quality varies based on format, location, internet bandwidth, device.
  • Commercial use prohibited; automatic ad blocking and recording restricted.