Courseiva
Indexing and Performance →mediumMultiple Choice

C100DBA Indexing and Performance Practice Question

An e-commerce application frequently runs a query filtering by category and sorting by price descending. Which index structure provides the optimal performance for this access pattern?

⚠ Common exam trap

Candidates often ignore the sort direction in index creation, assuming that {category: 1, price: 1} will optimize a query that sorts by price in descending order.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

{ category: 1, price: -1 }

To optimize queries with equality filters and descending sorts, the index must match the equality field first, followed by the sort field with the correct direction. Placing category first satisfies equality lookup, while setting price to negative one avoids in-memory sorting stages during execution.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    { price: -1, category: 1 }

    Why it's wrong here

    Putting the range or sort field first prevents the index from efficiently filtering the equality condition on category. The database would have to scan a broader range of the index before applying the secondary predicate, degrading query execution performance.

  • ✗

    { category: 1, price: 1 }

    Why it's wrong here

    Ascending order on the price field fails to match the descending sort requirement of the query. Consequently, the query engine must perform an additional in-memory blocking sort stage to deliver the expected results to the client application.

  • ✓

    { category: 1, price: -1 }

    Why this is correct

    The category field uses an ascending index prefix for equality matching, while the price field uses a descending direction that matches the requested sort order. This exact alignment allows the query engine to retrieve documents pre-sorted, completely bypassing expensive memory sorting operations.

  • ✗

    { price: 1, category: -1 }

    Why it's wrong here

    Reversing both the field order and the sorting directions contradicts the specific requirements of the application query. The query planner will reject this index for sorting purposes, resulting in inefficient index usage and potential memory limit exceptions.

About these practice questions

One of 222 original C100DBA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official MongoDB exam blueprint

This C100DBA practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DBA exam.