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

add the ability for a query to match multiple arbitrary ranges within a single index

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • Index Maintenance, Querying
    • None
    • Fully Compatible

    Description

      Right now it's easy to specify a query that will scan a range on an index:

      index { a:1 }
      query { a:{ $gte:5, $lte:10 } }

      or a set of points on an index:

      index { a:1 }
      query { a:{ $in:[ 1, 2 ] } }

      Using a regular expression it is also possible to specify certain combinations of ranges on an index:

      index { a:1 }
      query { a:{ $in:[ /^x/, /^y/ ] } }

      This ticket represents functionality for easily specifying more than one arbitrary range on a single index, scanned efficiently by the query optimizer. For example on

      index { a:1 }:
       
      1) query { $or:[ { a:{ $gte:5, $lte:10 } }, { a:{ $gte:100 } } ] }
      2) query { a:{ $in:[ { $gte:5, $lte:10 }, { $gte:100 } ] } }
       

      Example 1 is not currently optimized to work as a single index scan because $or is only implemented to support more general cases where or clauses may use different indexes.

      Example 2 is not an allowed query currently.

      Attachments

        Issue Links

          Activity

            People

              david.storch@mongodb.com David Storch
              aaron Aaron Staple
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: