A covered query in MongoDB is a performance optimization where all the data required by a query can be found within the index itself, eliminating the need for MongoDB to fetch documents from the collection resulting in significantly faster query execution because index data is typically cached in memory and requires fewer disk I/O operations.
For a query to be covered, three conditions must be met: First, all fields in the query filter must be part of an index. Second, all fields returned in the projection must be included in the same index. Third, none of the query fields can be searching for null values (i.e., {field: null} or {field: {$eq: null}}). Additionally, when working with array fields, covered queries have limitations because multikey indexes cannot cover queries over array fields.
You can verify whether a query is covered by examining the explain plan. Look for two key indicators: a PROJECTION_COVERED stage in the execution plan, and totalDocsExamined: 0 in the execution statistics. If you see a FETCH stage or totalDocsExamined greater than zero, the query is not covered and MongoDB is reading documents from the collection.
Multikey indexes cannot cover queries over array fields. If any field in the index is an array, the index is multikey and cannot provide covered queries, even for parts of the query that don't involve the array[citation:1][citation:4][citation:5].
$expr queries currently do not support covered queries. When using $expr with $match, MongoDB cannot determine that only indexed fields are needed, forcing a document fetch.
Partial indexes can be used with covered queries, but the partial filter expression must be carefully designed[citation:7].
Update operations cannot be covered. Even if the query part is covered, the update itself requires fetching the document to modify it.
Consider a collection of users where you frequently search by phone number and need only the name fields. Start by creating a compound index on phoneNumber, firstName, and lastName[citation:8]. When querying, explicitly project only the fields you need and exclude _id. The explain plan will show a PROJECTION_COVERED stage and totalDocsExamined: 0, confirming the query is covered[citation:8]. This optimization can dramatically improve query performance, especially for high-traffic queries[citation:10].