DVA-C02 exam dumps

DVA-C02 practice question 94 of 399

AWS Certified Developer - Associate. Associate level, Amazon Web Services. Free question with the correct answer and a full explanation.

DVA-C02 Question 94

Single answer

You are developing a serverless application using DynamoDB to store customer order data. The Orders table has a partition key CustomerId and a sort key OrderDate. You need to retrieve all orders for a specific customer within the last 30 days. Which operation should you use for optimal performance?

  1. A

    Query operation with a filter expression to specify the date range.

  2. B

    Scan operation with a filter expression to specify the date range.

  3. C

    Query operation specifying the partition key and a key condition expression for the date range.

  4. D

    Scan operation specifying the partition key and a key condition expression for the date range.

Show answer and explanation

Correct answer: C

Explanation

To efficiently retrieve items from a DynamoDB table, the Query operation should be used when you know the partition key. By providing a key condition expression, you can further limit the results using the sort key. In this scenario, the Query operation with the partition key (CustomerId) and a key condition expression for the date range on the sort key (OrderDate) ensures optimal performance. Scan operations, on the other hand, are less efficient as they read the entire table and are generally not suitable for specific queries.

  • A. Incorrect.

    Query operation with a filter expression is less efficient because filter expressions are applied after fetching all matching items. This does not leverage the index effectively for performance.

  • B. Incorrect.

    Scan operation is not optimal because it reads the entire table, which is both time-consuming and computationally expensive.

  • C. Correct.

    Query operation specifying the partition key and a key condition expression is the correct approach, as it retrieves only the items matching the specified partition key (CustomerId) and efficiently filters the results based on the date range using the sort key.

  • D. Incorrect.

    Scan operation does not allow specifying the partition key and key condition expressions together. Additionally, it scans the entire table, which is inefficient for this use case.

Timed practice exam

Take a DVA-C02 practice test under exam conditions

65 questions in 130 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam