On which filed you will create an index - projection field or filter field?
Difficulty: 5/10
index selection, covered queries, performance optimization
It would be beneficial to create an index on the field being used for filtering.
Scenario Questions
0-2 years experience
1You need to retrieve only the 'email' field from a users collection where 'status' is 'active'. Which field would you index to make this query fast, and why?
2If you create an index on the 'email' field but never filter by it, what impact does that have on query performance?
2-5 years experience
1We have a reporting feature that filters orders by 'orderDate' and returns only 'orderId' and 'total'. The current query is slow. Walk me through how you'd decide which fields to index and any trade‑offs.
2During a code review you notice an index built on a projection field that isn’t used in the filter. Explain why this might have been added and whether you’d keep or drop it.
5-8 years experience
1Our service handles millions of reads per second and uses covered queries to avoid fetching documents. How would you design the index strategy for queries that both filter on 'category' and project 'price' and 'stock'?
2A recent performance regression showed increased latency after adding a new compound index that includes a projection field. How would you investigate and resolve the issue?
8+ years experience
1We are migrating a legacy monolithic app to a microservice architecture, and the data model will be shared across services. How would you establish a long‑term indexing policy for projection vs filter fields to balance performance, storage, and operational overhead?
2Across several teams, some indexes are built on projection fields for analytics workloads while others focus on filter fields for transactional APIs. How would you create a governance framework to ensure consistent index usage and avoid redundant indexes?
Follow-up Questions
What metrics would you check to verify the index is being used?
Can you describe how a covered query works in MongoDB?
How does index cardinality influence your choice of filter vs projection fields?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.