Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-47330

Extend IDHACK to any unique index where all properties are given as simple "equality" values.

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Query Optimization

      The IDHACK is an optimization for _id lookups. It exploits the fact that _id ~always has a unique index; if the internal find cursor yields a document, there’s no need to iterate the cursor any more, or make an additional “step” in the query planner, which improves performance. This could be generalized to apply to any unique index where all properties of the index are given as simple equality values.

      For example, given unique index {foo: 1, bar: 1}, a query {foo: 123, bar: "abc", baz: {$lt: 789}} would be able to use this enhanced IDHACK optimization.

      A much more common case for us would be $in queries on _id, which I suspect is common to many users, since it's what you'd do to emulate joins. Today, an $in would require 2x the steps/cursor iterations compared to applying the IDHACK.

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            bartle David Bartley
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: