Google Cloud Professional Cloud Architect — Question 68
You are creating an App Engine application that uses Cloud Datastore as its persistence layer. You need to retrieve several root entities for which you have the identifiers. You want to minimize the overhead in operations performed by Cloud Datastore. What should you do?
Answer options
- A. Create the Key object for each Entity and run a batch get operation
- B. Create the Key object for each Entity and run multiple get operations, one operation for each entity
- C. Use the identifiers to create a query filter and run a batch query operation
- D. Use the identifiers to create a query filter and run multiple query operations, one operation for each entity
Correct answer: A
Explanation
The correct answer is A because creating a Key object for each entity and executing a batch get operation is the most efficient way to retrieve multiple entities and reduces the number of operations performed. Option B is less efficient as it involves multiple get operations, which increases overhead. Options C and D involve query filters, which are not necessary when you already have the keys for the entities you want to retrieve.