This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
A developer runs db.products.find({ productType: "bike" }).explain("executionStats") and sees stage: "COLLSCAN", totalDocsExamined: 500000, and nReturned: 230. What does this output indicate?
db.products.find({ productType: "bike" }).explain("executionStats")
stage: "COLLSCAN"
totalDocsExamined: 500000
nReturned: 230
The query returned 230 of 500,000 results because the projection excluded the other documents.
The query scanned all 500,000 documents because no index exists on the productType field.
The database used an index but it wasn't selective enough, so it examined 500,000 entries.
A developer has two indexes on the products collection: { category: 1 } and { category: 1, price: -1 }. The application only queries by category alone or by category and price together. Which action optimizes the indexing strategy?
{ category: 1 }
{ category: 1, price: -1 }
Keep both indexes because the single-field index is faster for category-only queries.
Drop the compound index and keep only the single-field index for simpler maintenance.
Drop the single-field { category: 1 } index because the compound index covers category-only queries through prefix matching.
A social media application has a users collection where only 15% of users have a verified phone number in the phone field. The application queries verified phone numbers frequently. Which index type minimizes storage while supporting these queries?
users
phone
A standard single-field index on the phone field.
A partial index on the phone field with a filter expression that requires the field to exist.
A wildcard index on all user fields.
A developer runs db.products.aggregate([{ $indexStats: {} }]) and discovers an index named productType_1 with accesses.ops: 0 over the past 90 days. All application queries filter by category, not productType. What should the developer do before dropping the index?
db.products.aggregate([{ $indexStats: {} }])
productType_1
accesses.ops: 0
Drop the index immediately since it has zero usage.
Verify that no periodic jobs, reports, or seasonal queries depend on the index, then confirm with explain() that no critical queries use it before dropping.
Rebuild the index to reset the usage counter and monitor for another 90 days.
Azure DocumentDB indexes only the _id field by default. A developer creates a new collection and inserts 100,000 documents. Which statement accurately describes the indexing behavior?
_id
All fields in every document are automatically indexed, and the developer should drop unnecessary indexes to reduce write overhead.
Only the _id field is indexed. Queries on any other field perform a collection scan until the developer creates appropriate indexes.
No fields are indexed by default. The developer must create all indexes including the _id index.
You must answer all questions before checking your work.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?