[SERVER-19973] FInd using a boxed match causes full index scan Created: 15/Aug/15  Updated: 17/Aug/15  Resolved: 17/Aug/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Trivial - P5
Reporter: Paul Reed Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 0
Labels: regex
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

If I run this find query:

db.data.findOne({G:/^[W]/})

I get a full index scan being performed.
explained as :

   "indexBounds" : {
           "G" : [
                   "[\"\", {})",
                   "[/^[W]/, /^[W]/]"
           ],



 Comments   
Comment by Sam Kleinman (Inactive) [ 17/Aug/15 ]

This looks like the expected behavior, you can see a discussion of index use for regexps in the documentation. I'm going to go ahead and close this ticket, but if you have additional questions, feel free to address them to the mongodb-users group
or Stack Overflow with the mongodb tag. These forums may be better suited to these kinds of questions than the SERVER project which is for bug reports and feature requests concerning the core MongoDB product.

Regards,
sam

Comment by Paul Reed [ 15/Aug/15 ]

pressed ctrl enter by mistake...

however, if I run this query

db.data.findOne({G:/^W/})

it is explained as

 "indexBounds" : {
         "G" : [
                 "[\"W\", \"X\")",
                 "[/^W/, /^W/]"
         ],
         "B" : [
                 "[MinKey, MaxKey]"
         ]
 }

Can not something be done with the bounds to restrain the first querys scan. ideally restrain it to just W and X - but equally you could restrain it to the max and min of all items to match i,e,

db.,,,findOne({G:/^[WY]/})

should be restricted to min W and max Z ?

Generated at Thu Feb 08 03:52:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.