Today let’s check on AWS DynamoDB local secondary index article by our AWS Support Services at Bobcares.
AWS DynamoDB local secondary index Overview
You can add up local secondary indexes on tables with composite primary keys. A local secondary index maintains the HASH key as the underlying table which allow for a different RANGE key.
Some extra notes about local secondary indexes:
- Must be specified at table creation. You cannot add a local secondary index to any existing table, it must be provided at creation.
- 10GB limit per HASH key. For a given HASH key, you can store up to 10GB of data. This includes the size of the items in the base table plus the merged size of the items in all local secondary indexes.
- Consistency options. For local secondary indexes, you may choose between strong and eventual consistency, just like on the underlying table. Strong consistency will consume more read capacity however it can be the right choice in some situations.
- Shares with underlying table. All local secondary indexes will use the read-and-write units of the underlying table.
Creating a Local Secondary Index
To create one or multiple local secondary indexes on a table, use the LocalSecondaryIndexes
parameter of the CreateTable
operation. Local secondary indexes on a table which created when the table is created. When you delete a table, any local indexes on that table will also get deleted.
Further, you should specify one non-key attribute, to act as the sort key of the local secondary index. The attribute that you choose must have scalar String
, Number
, or Binary
. Note that Other scalar types, document types, and set types will not allow.
[Looking for a solution to another query? We are just a click away.]
Conclusion
To sum up, some apps only need to query data using the base table’s primary key. But, there might be situations where an alternative sort key would be helpful. You can retrieve items from a local secondary index using the Query
and Scan
operations.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments