AWS DynamoDB - Working with Indexes Last Updated : 28 Mar, 2023 Comments Improve Suggest changes Like Article Like Report An index is a data structure that enables us to perform fast queries on different columns in a table. After creating an index, the database handles it for us. Whenever data is modified in the table, the index is automatically modified to reflect changes in the table. We can create and use a secondary index to query faster. While creating a secondary index, we must specify its key attributes—a partition key and a sort key. After the secondary index is created, we can perform operations such as Query or Scan just as we do on the table. DynamoDB doesn't have any query optimizer, so a secondary index is used while you Query it or Scan it. DynamoDB supports two types of indexes which have been discussed below in detail: Global Secondary Index: A Global Secondary Index (GSI) is an index with a partition key and a sort key that can be different from keys in the base table. A global secondary index is said t be "global" because queries on the index can cover all the data in the base table, across all partitions. A global secondary index has no size limitations like that of the base table and has its own provisioned read and write throughput settings that are separate from those of the table. Therefore, for fast retrieval of results on non-key attributes, we use Secondary Global Indexes. See the below example: BoardExams A table named BoardExams has been created with partition key as StudentID and sort key as Stream. The data stored in the above table will be represented as shown in the below image: Representation of Base table Now, suppose we need to know the maths marks scored in each stream. Thus, we create a GSI named Stream-index with partition key as Stream and sort key as Maths. See the below image: Note: The partition key of the base table will also be projected into the index. Stream-indexLocal Secondary Index: A Local Secondary Index has the same partition key as the base table but a different sort key. It is "local" in the sense that every partition of a local secondary index is scoped to a base table partition that has the same partition key value. It is created when a table is created. See the below image: Comment More infoAdvertise with us R rohanchopra96 Follow Improve Article Tags : DynamoDB DynamoDB-Basics Similar Reads AWS DynamoDB - Working with Scans Amazon DynamoDB is NoSQL managed database that stores semi-structured data like key-value pairs and document data. When creating tables in DynamoDB, no schema structure is required but only a partition key (primary key) is required. DynamoDB tables stores data in form of items and each item consists 3 min read AWS DynamoDB - Working with Queries Amazon DynamoDB is a NoSQL managed database service provided by Amazon that stores semi-structured data like key-value pairs. A DynamoDB table consists of items. Each item consists of one partition key and one or more attributes. An example of an item is given below: Example: { "MovieID": 101, "Name 5 min read AWS DynamoDB - Working with Tables In this article, we will work on DynamoDB tables. DynamoDB is a NoSQL database that stores document data or key-value pairs. A Dynamodb table consists of items and each item is made up of attributes. Different items can have different attributes. See the below example: Example 1: { "MovieID": 123, " 3 min read AWS DynamoDB - Working with Streams DynamoDB Streams is a DynamoDB feature that allows users to keep track of any changes made to the data in DynamoDB. It is an "ordered flow of data" that contains information about changes made to the data in the DynamoDB table. Let us talk of a use case. Consider a "users" table in DynamoDB and your 3 min read AWS DynamoDB - Working with Items & Attributes AWS DynamoDB is a NoSQL managed database that stores semi-structured data i.e. key-value and document data. It stores data in form of an item. An item consists of attributes. Upon table creation in DynamoDB, it only requires a primary key to differentiate between items and no schema is to be defined 3 min read AWS DynamoDB - Working with Backups Amazon DynamoDB supports on-demand backup and restores features. Those features are available to the user independent of whether the user uses AWS Backup or not. Users can use the DynamoDB on-demand backup capability to create full backups of its tables for a long-term period and archival for regula 3 min read Like