Consider a MongoDB collection orders with documents having fields status and total. A partial index is created with filter { status: "completed" } on total. Which query will use this partial index?
db.orders.createIndex({ total: 1 }, { partialFilterExpression: { status: "completed" } })Partial indexes only cover documents matching the filter expression.
The partial index only includes documents where status is "completed". Only queries that filter on status: "completed" can use this index efficiently.
Which of the following commands correctly creates a partial index on the users collection for documents where age is greater than 18?
Check the exact option name for partial index filter in MongoDB.
The correct option uses partialFilterExpression with a valid MongoDB query document as the filter.
You have a large products collection with a category field. Most queries filter for category: "electronics". Which partial index filter will optimize these queries best?
Partial indexes should match the most common query filter exactly for best performance.
Filtering the index to only include documents with category: "electronics" makes the index smaller and more efficient for those queries.
A partial index is created on orders with filter { shipped: true }. The query db.orders.find({ shipped: false, total: { $gt: 50 } }) is slow. Why?
Think about which documents the partial index includes.
The partial index only includes documents where shipped is true. Queries filtering for shipped: false cannot use this index and must scan more documents.
How do partial indexes affect write performance in MongoDB compared to full indexes?
Consider how many documents get indexed during writes.
Partial indexes only index documents matching the filter, so fewer index entries are updated during writes, reducing overhead.