Book Image

DynamoDB Applied Design Patterns

By : Uchit Hamendra Vyas
Book Image

DynamoDB Applied Design Patterns

By: Uchit Hamendra Vyas

Overview of this book

Table of Contents (17 chapters)
DynamoDB Applied Design Patterns
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Secondary indexes


A quick question: while writing a query in any database, keeping the primary key field as part of the query (especially in the where condition) will return results much faster compared to the other way. Why? This is because of the fact that an index will be created automatically in most of the databases for the primary key field. This is the case with DynamoDB also. This index is called the primary index of the table. There is no customization possible using the primary index, so the primary index is seldom discussed.

In order to make retrieval faster, the frequently-retrieved attributes need to be made as part of the index. However, a DynamoDB table can have only one primary index and the index can have a maximum of two attributes (hash and range key). So for faster retrieval, the user should be given privileges to create user-defined indexes. This index, which is created by the user, is called the secondary index. Similar to the table key schema, the secondary index also...