Every item in Dynamo must have a unique primary key. The primary key is the base table index. A primary key must have a partition key and can optionally have a range key (also called a sort key). Within a partition, items are ordered by range key. Accessing items using a partition key is fast.

Secondary indexes allow you to query the table using an alternative key. A Local Secondary Index (LSI) has the same partition key as the primary key (index), but a different range key. The way to think about an LSI is that its the same data as the primary index (key), just ordered by a different attribute.

A Global Secondary Index (GSI) has a different partition key to the primary key and is therefore a different set of data.

One of the important differences between an LSI and GSI is that an LSI takes its throughput capacity from the base table, whereas you have to purchase GSI throughput capacity separately. Put another way, an LSI costs you nothing, and a GSI incurs extra costs over your base table.

Let's have a look at the Music table example. Let's say the base table has this schema;

Artist: (Primary Key) Partition Key
SongTitle: (Primary Key) Range Key
AlbumTitle:
DateOfRelease:

This table is a list of songs. I can access all the songs for an artist really efficiently (i.e. query by Artist using the partition key). When I do this query, the songs will be ordered by SongTitle. I can also access songs by Artist and SongTitle very efficiently using the unique primary key.

Now lets say I want to get all songs by an Artist but ordered by DateOfRelease. In the current schema I would need to get all the songs and then order them in my application. A good alternative would be to create a new index, with a partition key of Artist and a range key DateOfRelease. This will be a LSI because the partition key of the index (Artist) is the same as the partition key of the primary key. I do not need to purchase additional throughput capacity as this index will provision itself from the base table capacity.

Now lets say I want to access the songs by AlbumTitle, ordered by SongTitle, i.e. create lists of Albums. To do this efficiently I create a new index with partition key AlbumTitle and range key SongTitle. This is a GSI because the partition key is different to the primary key. This GSI must be provisioned separately to the base table and therefore costs extra.

In answer to your question, GenreAlbumTitle is a GSI because it has a different partition key to Music.

Answer from F_SO_K on Stack Overflow
🌐
AWS
docs.aws.amazon.com › amazon dynamodb › developer guide › working with tables, items, queries, scans, and indexes › improving data access with secondary indexes in dynamodb › local secondary indexes
Local secondary indexes - Amazon DynamoDB
Every local secondary index automatically contains the partition and sort keys from its base table; you can optionally project non-key attributes into the index. When you query the index, DynamoDB can retrieve these projected attributes efficiently. When you query a local secondary index, the ...
Top answer
1 of 2
58

Every item in Dynamo must have a unique primary key. The primary key is the base table index. A primary key must have a partition key and can optionally have a range key (also called a sort key). Within a partition, items are ordered by range key. Accessing items using a partition key is fast.

Secondary indexes allow you to query the table using an alternative key. A Local Secondary Index (LSI) has the same partition key as the primary key (index), but a different range key. The way to think about an LSI is that its the same data as the primary index (key), just ordered by a different attribute.

A Global Secondary Index (GSI) has a different partition key to the primary key and is therefore a different set of data.

One of the important differences between an LSI and GSI is that an LSI takes its throughput capacity from the base table, whereas you have to purchase GSI throughput capacity separately. Put another way, an LSI costs you nothing, and a GSI incurs extra costs over your base table.

Let's have a look at the Music table example. Let's say the base table has this schema;

Artist: (Primary Key) Partition Key
SongTitle: (Primary Key) Range Key
AlbumTitle:
DateOfRelease:

This table is a list of songs. I can access all the songs for an artist really efficiently (i.e. query by Artist using the partition key). When I do this query, the songs will be ordered by SongTitle. I can also access songs by Artist and SongTitle very efficiently using the unique primary key.

Now lets say I want to get all songs by an Artist but ordered by DateOfRelease. In the current schema I would need to get all the songs and then order them in my application. A good alternative would be to create a new index, with a partition key of Artist and a range key DateOfRelease. This will be a LSI because the partition key of the index (Artist) is the same as the partition key of the primary key. I do not need to purchase additional throughput capacity as this index will provision itself from the base table capacity.

Now lets say I want to access the songs by AlbumTitle, ordered by SongTitle, i.e. create lists of Albums. To do this efficiently I create a new index with partition key AlbumTitle and range key SongTitle. This is a GSI because the partition key is different to the primary key. This GSI must be provisioned separately to the base table and therefore costs extra.

In answer to your question, GenreAlbumTitle is a GSI because it has a different partition key to Music.

2 of 2
25

There is some misconceptions about the costs of using LSI, so let me clarify here.

Using LSI is not free of charge. Just like GSI, dynamoDB needs to create and maintain additional partial copies of the table in order to quickly get the results. This maintenance of additional copies will incur additional read, write, and storage costs identical to that of GSI. (Additional cost will be written in bold). The only difference is that instead of allocating a separate pay plan, you use the same pay plan as the main table.

Before discussing the additional cost, let me again summarize what kind of information is stored in the partial copy table. The partial table copy (LSI) contains the partition key (same as original table), the sort key (a different one than the original table), and any additional projected attributes.

Original Table

Artist (Primary Key) Song title (sort key) Album Title Date Of Release
Michael Jackson Beat It Thriller December 1, 1982
Weeknd The Hills Beauty Behind the Madness May 27, 2015,

LSI

Artist (Primary Key) Album Title (sort key) Date Of Release
Michael Jackson Thriller December 1, 1982
Weeknd Beauty Behind the Madness May 27, 2015,

Projected attributes are the additional information we want to query from the LSI. I could say, "show me all of release dates of the albums by the Weeknd, ordered by the album name". As you can see, we don't care about the song title here, and is not included in our LSI projections.

Additional cost for reads:

  • You are charged for 1 Read Unit for queries that can be satisfied by using LSI table alone. Example: "Show me all of release dates of the songs by the Weeknd, ordered by the album name."

  • You are charged 1 additional Read Unit for queries that LSI doesn't know how to serve on its own, forcing it to go to the main table for help. This will cost a total of 2 Read Units. Example: "show me all of release dates AND the song titles of the songs by the Weeknd, ordered by the album name."

Additional cost for writes:

(Writes are done to the main table, with its own write costs, and changes are later propagated to LSI's)

  • If the update to the main table results in creation of a new row in the LSI => 1 additional Write Unit
  • If the update to the main table results in the key attribute of an existing row in the LSI to be updated => cost for deletion (1 unit) + creation (1 unit) = 2 additional Write Unit
  • If the update to the main table results in the non-key attribute of an existing row in the LSI to be updated => 1 additional Write Unit
  • If the update to the main table results in the deletion of an existing attribute of an existing row in the LSI => 1 additional Write Unit
  • If the update to the main table does not change any rows of LSI => 0 additional Write Unit

Additional cost for storage

  • You pay additional cost for: (size of index keys + size of projected attributes + overhead) x number of rows

As you can see, if we are not careful with LSI, extra costs can become overbearing. To minimize cost, you must:

  • Carefully consider your typical queries. Which types of information do you need?
  • There is tradeoff between read cost and storage cost. If you project every attribute to the LSI, than you will incur no extra read cost, but your storage cost will double. If you project only the key attributes, and you often fetch additional information other than the key attributes, there will be a lot of extra read costs from having to go back to the main table for help.
  • For tables that are write-heavy, expect to incur a huge uptick in the write cost. Remember, if the update to the main table updates the key attribute of an item in the LSI, you pay 2 additional write units, and for non-key attributes, 1 additional write unit.
Discussions

Need a small suggestion regarding DynamoDB local secondary indexes
Hey! Regarding secondary indexes the thing is whenever you put a record in the table in has to be indexed by all the existing indexes, because the idea is when you query one of those indexes later on, the records are stored in such a way to be retrieved as soon as possible for the keys of the index you are searching by, so even if you don't "use"( I assume this means not specify a value) for the index range key, it will still be indexed and I believe a default value will be assigned to that range key attribute based on it's type. About the restriction of the LSI, here is a quote from the AWS docs: For any local secondary index, you can store up to 10 GB of data per distinct partition key value. This figure includes all of the items in the base table, plus all of the items in the indexes, that have the same partition key value. And about creating the max number of LSI, just in case you might need them in the future, I think is unnecessary - you can always create a GSI with the same partition key and a different range key later on if you need it. More on reddit.com
🌐 r/aws
2
2
March 8, 2021
DynamoDB local secondary index and global secondary index
Yes it will create another table and update automatically. It handles it internally. For your access you will need to specify the gsi index in the query . That is not implicit More on reddit.com
🌐 r/aws
2
2
November 15, 2021
DynamoDB - performance difference between querying primary index and global secondary index?
Try this search for more information on this topic. Comments, questions or suggestions regarding this autoresponse? Please send them here . I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/aws
5
1
September 3, 2024
DynamoDB: GSI & Sort Key
Every table can have one partition key and one sort key composited together as the table’s primary key. A GSI is a second index, unrelated to the table’s primary key, that can have its own partition and sort key. The sort key is also optional. You can have a table or an index with only a partition key. Hope that helps. More on reddit.com
🌐 r/aws
12
9
February 13, 2024
🌐
Medium
joudwawad.medium.com › dynamodb-indexes-deep-dive-afe86a1cac48
DynamoDB Indexes Deep Dive | By Joud W. Awad | Medium
5 days ago - The most efficient way to query this data and to avoid fetch operations would be to project the Replies attribute from the table into the local secondary index, as shown in this diagram. ... A projection is the set of attributes that is copied from a table into a secondary index. The partition key and sort key of the table are always projected into the index; you can project other attributes to support your application’s query requirements. When you query an index, Amazon DynamoDB can access any attribute in the projection as if those attributes were in a table of their own.
🌐
ScyllaDB
scylladb.com › home › dynamodb secondary index
What is a DynamoDB Secondary Index? Definition & FAQs | ScyllaDB
August 7, 2025 - A DynamoDB Local Secondary Index (LSI) is a type of secondary index that lets you query data using the same partition key as the base table but with a different sort key. This allows you to create alternate views of your data within the same ...
🌐
Reddit
reddit.com › r/aws › need a small suggestion regarding dynamodb local secondary indexes
r/aws on Reddit: Need a small suggestion regarding DynamoDB local secondary indexes
March 8, 2021 -

Hey guys! So I'm in the process of migrating our relational database to DynamoDB and everything is going great. I'm using one local secondary index currently but I had a question that I could not find online. I would greatly appreciate your help!

If I researched correctly, when the table has a local secondary index, it will only be 'used' when a record has a value for the index range key. Meaning that those records that do not use the local secondary index range key do not have the limitations and costs associated with LSIs (e.g. the 10GB limit doesn't apply to them).

So now I'm thinking since LSIs can only be created while the table is being created, would it be a good idea to just create the maximum of 5 LSIs right now but not necessarily use or need them? Just to have them down the road in case a new query will require them.

Hope that makes sense! Thanks again!

🌐
AWS re:Post
repost.aws › knowledge-center › dynamodb-gsi-lsi-difference
Know the difference in global and local secondary indexes | AWS re:Post
August 9, 2024 - To create a local secondary index for an existing table, create a new table with a local secondary index. Then, use the AWS CLI or AWS SDK to migrate the data to the destination table. For more information, see How can I migrate my DynamoDB tables from one AWS Account to another?
Find elsewhere
🌐
Momento
gomomento.com › home › which flavor of dynamodb secondary index should you pick?
Which flavor of DynamoDB secondary index should you pick? - Momento
June 7, 2024 - You can’t write directly to a secondary index, but when you write to an item in your base table DynamoDB will project relevant changes into your secondary indexes for you. There are two types of secondary index: Local Secondary Indexes (LSIs) and Global Secondary Indexes (GSIs).
🌐
Pete's Ponderings
blog.highbar.solutions › all-about-dynamodb-local-secondary-indexes
All about DynamoDB Local Secondary Indexes
November 12, 2023 - Defining a Local Secondary Index for your table allows you to read (Query or Scan) the same data with an optional filter applied and with item collections applying a sort order that differs from the base table.
🌐
Tutorials Dojo
tutorialsdojo.com › home › aws cheat sheets › aws comparison of services › global secondary index vs local secondary index
Global Secondary Index vs Local Secondary Index
January 24, 2024 - Bookmarks Global Secondary Index Local Secondary Index A secondary index is a data structure that contains a subset of attributes from a table, along with an alternate key to support Query operations.
🌐
AWS
docs.aws.amazon.com › amazon dynamodb › developer guide › working with tables, items, queries, scans, and indexes › improving data access with secondary indexes in dynamodb
Improving data access with secondary indexes in DynamoDB - Amazon DynamoDB
April 15, 2026 - The following table shows the main ... and a local secondary index. If you want to create more than one table with secondary indexes, you must do so sequentially. For example, you would create the first table and wait for it to become ACTIVE, create the next table and wait for it to become ACTIVE, and so on. If you try to concurrently create more than one table with a secondary index, DynamoDB returns a ...
🌐
AWS
docs.aws.amazon.com › amazon dynamodb › developer guide › working with tables, items, queries, scans, and indexes › improving data access with secondary indexes in dynamodb › local secondary indexes › working with local secondary indexes: java
Working with Local Secondary Indexes: Java - Amazon DynamoDB
April 16, 2026 - Create an instance of the ... throughput values. For the local secondary index, you must provide the index name, the name and data type for the index sort key, the key schema for the index, and the attribute projection....
🌐
Medium
medium.com › @b.stoilov › dynamodb-indexes-quick-intro-ac4e09312135
DynamoDB Indexes. Quick Intro. Secondary Indexes (Global vs. Local) | by Borislav Stoilov | Medium
March 11, 2025 - That is where Indexes come into play · LSIs share the Partition Key with the primary table but have their own new Sort Key · By defining the Local Secondary Index 1 (LSI1) we will be able to query items using the additional SK of the LSI (LSI1SK).
🌐
Dynamodbguide
dynamodbguide.com › local secondary indexes
Local Secondary Indexes | DynamoDB, explained.
Now that we have a table set up with a local secondary index, let's run a query against it. In our filter example, we looked for all of Daffy Duck's Orders that were over $100. We can now convert this directly to a Query without using a filter: $ aws dynamodb query \ --table-name UserOrdersTable \ --index-name UserAmountIndex \ --key-condition-expression "Username = :username AND Amount > :amount" \ --expression-attribute-values '{ ":username": { "S": "daffyduck" }, ":amount": { "N": "100" } }' \ $LOCAL
🌐
Medium
medium.com › @jun711.g › aws-dynamodb-global-and-local-secondary-indexes-comparison-80f4c587b1d7
AWS DynamoDB Global And Local Secondary Indexes Comparison | by Jun711 | Medium
August 16, 2019 - With a local secondary index that has UserId as its partition key and DateCreated as its sort key, you can retrieve a user’s articles sorted by date created. |UserId(Partition Key) | DateCreated(Sort Key) | ArticleName | Data| In short, use DynamoDB Global Secondary Index when you need to support querying non-primary key attribute of a table.
🌐
Dynamodbguide
dynamodbguide.com › local or global: choosing a secondary index type in dynamodb
Local or global: Choosing a secondary index type in DynamoDB | DynamoDB, explained.
With a secondary index, you can add additional access patterns to your application without the hassle of maintaining multiple copies of the same data. DynamoDB will handle all replication from the base table to your secondary index. There are two types of secondary indexes: local secondary indexes and global secondary indexes.
🌐
DZone
dzone.com › data engineering › databases › indexing in dynamodb
Indexing in DynamoDB
April 11, 2018 - Every local secondary index automatically contains the partition and sort keys from its base table. You can optionally project non-key attributes into the index. When you query the index, DynamoDB can retrieve these projected attributes efficiently.
🌐
Reddit
reddit.com › r/aws › dynamodb local secondary index and global secondary index
r/aws on Reddit: DynamoDB local secondary index and global secondary index
November 15, 2021 -

Im trying to wrap my head around the storage of the two types of indexes.

Lets say you have a table that 100MBs. The Table has a Primary Key of State and Sort Key of City. There are attributes for Population and if the State voted Democrat or Republican we can call this Politics.

On the initial create table I set a local secondary index on Politics. Would I actually be storing the entire tables (all attributes) from the original table? So the new global secondary index would be another 100mbs?

For the Global Secondary index. Lets say I dont define a local secondary index on creation and now I want a GSI. I use my Politics attribute but now I define that my Global Secondary Index is set on Politics with just an attribute of State. Would this create another table with the Politics and State attribute only?

🌐
Jun711 blog
jun711.github.io › home › aws
AWS DynamoDB Global And Local Secondary Indexes Comparison | Jun711 blog
February 19, 2019 - With a local secondary index that has UserId as its partition key and DateCreated as its sort key, you can retrieve a user’s articles sorted by date created. | UserId(Partition Key) | DateCreated(Sort Key) | ArticleName | Data | In short, use DynamoDB Global Secondary Index when you need to support querying non-primary key attribute of a table.
🌐
AWS
aws.amazon.com › blogs › aws › local-secondary-indexes-for-amazon-dynamodb
Local Secondary Indexes for Amazon DynamoDB | Amazon Web Services
January 15, 2021 - You can now create local secondary indexes for Amazon DynamoDB tables. These indexes provide give you the power to query your tables in new ways, and can also increase retrieval efficiency. What’s a Local Secondary Index?The local secondary index model builds on DynamoDB’s existing key model.