0 votes
in AWS by

An application is currently accessing a DynamoDB table. Currently, the table queries are performing well. Changes have been made to the application, and now the performance of the application is starting to degrade. 

After looking at the changes, you see that the queries use an attribute that is not the partition key. Which of the following would be the adequate change to make to resolve the issue?

1 Answer

0 votes
by

Answer - A.

The AWS Documentation mentions the following.

Amazon DynamoDB provides fast access to items in a table by specifying primary key values.

However, many applications might benefit from having one or more secondary (or alternate) keys available to allow efficient access to data with attributes other than the primary key.

You can create one or more secondary indexes on a table and issue Query or Scan requests against these indexes to address this.

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.

You can retrieve data from the index using a Query, in much the same way as you use Query with a table.

A table can have multiple secondary indexes, which gives your applications access to many different query patterns.

Option B, although possible, is not the ideal approach to change the application code.

Option C is used for disaster recovery scenarios.

Option D is not right because we don't know if this would solve the issue in the long run.

For more information on Secondary Indexes, please refer to the below URL-

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.html

The issue is that the application queries are using an attribute that is not the partition key, which is causing the performance of the application to degrade. To resolve this issue, one of the following changes should be made:

A. Add a Global Secondary Index (GSI) to the DynamoDB table.

  • A GSI is a replica of the original table with an alternate key schema. It allows you to query the table using non-key attributes.
  • Adding a GSI with the non-key attribute used in the queries as the partition key will allow the queries to perform efficiently without requiring a full table scan.
  • Therefore, adding a GSI is an adequate change to resolve the issue.

B. Change all the queries to ensure they use the partition key.

  • Changing all the queries to use the partition key would ensure efficient query performance. However, this might not be feasible or desirable, especially if the non-key attribute is necessary for the queries.
  • Therefore, this may not be an adequate change to resolve the issue.

C. Enable global tables for DynamoDB.

  • Global tables are used to replicate a DynamoDB table across multiple AWS regions, allowing for low-latency access to the data from anywhere in the world.
  • Enabling global tables will not address the issue at hand, which is the inefficient queries due to the non-use of the partition key.
  • Therefore, this is not an adequate change to resolve the issue.

D. Change the read capacity on the table.

  • Changing the read capacity on the table would not address the issue at hand, which is the inefficient queries due to the non-use of the partition key.
  • Therefore, this is not an adequate change to resolve the issue.

In conclusion, adding a Global Secondary Index to the DynamoDB table is the adequate change to make to resolve the issue.

...