Question 1
You know both the id and the partition key value of an item in Azure Cosmos DB for NoSQL. What is the cheapest way to retrieve it?
- Read the change feed from the beginning
- Use a stored procedure that scans the container
- Run SELECT * FROM c WHERE c.id = @id across all partitions
- Use a point read (ReadItem) with the id and partition key — Correct
Correct answer
Use a point read (ReadItem) with the id and partition key
Explanation
A point read with id and partition key is the most efficient operation, costing about 1 RU for a 1 KB item.
Question 2
Building an HNSW index on 10 million embeddings takes hours. Which setting most directly speeds up the index build?
- Lower ef_search
- Increase max_connections so that more client sessions can build parts of the index
- Increase maintenance_work_mem (and parallel maintenance workers) — Correct
- Enable autovacuum
Correct answer
Increase maintenance_work_mem (and parallel maintenance workers)
Explanation
Index builds are faster when the graph fits in maintenance_work_mem. Parallel workers also help.
Question 3
Which Cosmos DB query correctly returns the five most similar items to a query vector @q?
- SELECT TOP 5 c.id, VectorDistance(c.embedding, @q) AS score FROM c WHERE score > 0.8 ORDER BY c.id
- SELECT TOP 5 c.id FROM c ORDER BY c.embedding DESC
- SELECT c.id FROM c WHERE c.embedding = @q
- SELECT TOP 5 c.id, VectorDistance(c.embedding, @q) AS score FROM c ORDER BY VectorDistance(c.embedding, @q) — Correct
Correct answer
SELECT TOP 5 c.id, VectorDistance(c.embedding, @q) AS score FROM c ORDER BY VectorDistance(c.embedding, @q)
Explanation
Vector search uses VectorDistance in ORDER BY together with TOP N. Results are ranked by similarity.
Question 4
A developer must import 2 million documents into Cosmos DB as fast as possible from a .NET app. Which SDK option helps?
- ConsistencyLevel = Strong
- MaxItemCount = 1
- AllowBulkExecution = true — Correct
- ConnectionMode = Gateway only
Correct answer
AllowBulkExecution = true
Explanation
Bulk mode groups concurrent operations to maximize throughput usage for large imports.
Question 5
A container stores 3,072-dimension embeddings. Which vector index type is NOT suitable because of its dimension limit?
- flat — Correct
- No vector index type has a dimension limit
- diskANN
- quantizedFlat
Correct answer
flat
Explanation
The flat index supports a limited number of dimensions (505). Higher-dimension embeddings use quantizedFlat or diskANN.
Question 6
An app receives HTTP 429 responses from Cosmos DB during short traffic spikes. Which response is most appropriate first?
- Rely on the SDK's built-in retries that honor retry-after, and consider autoscale throughput — Correct
- Create a new CosmosClient on every retry so the request is routed to a different gateway node
- Remove the partition key
- Switch to Strong consistency
Correct answer
Rely on the SDK's built-in retries that honor retry-after, and consider autoscale throughput
Explanation
429 means the provisioned RUs were exceeded. The SDK retries after the suggested delay. Autoscale handles spikes better.
Question 7
A change feed processor runs on three instances with the same processor name and lease container. What happens?
- Only the first instance runs; the others stay idle forever
- Every instance processes all changes, so the handler must deduplicate them by item id
- Leases are distributed so each partition range is processed by one instance — Correct
- Each instance processes every change three times
Correct answer
Leases are distributed so each partition range is processed by one instance
Explanation
Instances sharing a lease container split the lease ownership, which scales out processing without duplicate work.
Question 8
A product price cached in Redis must never be served for more than 10 minutes after it was cached. Which command sets the value with that expiry?
- SET price:42 19.99 EX 600 — Correct
- INCR price:42
- PERSIST price:42
- SET price:42 19.99 NX, followed by PERSIST price:42
Correct answer
SET price:42 19.99 EX 600
Explanation
EX sets a time-to-live in seconds. PERSIST removes a TTL, and NX only sets the key if it does not exist.
Question 9
Vector search commands fail on a newly created Azure Managed Redis instance with an unknown command error. What is the most likely cause?
- The client connects over TLS on port 10000, which does not support module commands
- The eviction policy is allkeys-lru
- The keys have no TTL
- The RediSearch module was not enabled when the instance was created — Correct
Correct answer
The RediSearch module was not enabled when the instance was created
Explanation
Vector search depends on the RediSearch module, which is selected when the instance is created.
Question 10
Embedding storage is too large. You want to reduce storage and memory with minimal impact on recall. Which pgvector option helps?
- Use a numeric[] column, which pgvector compresses automatically
- Store embeddings as halfvec (16-bit floats) — Correct
- Store embeddings as text
- Disable TOAST compression
Correct answer
Store embeddings as halfvec (16-bit floats)
Explanation
halfvec halves storage per dimension and can be indexed, usually with little recall loss.