[SERVER-12952] Regex query performance regression in v2.6.0-rc0 Created: 27/Feb/14  Updated: 10/Dec/14  Resolved: 13/Mar/14

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

Type: Bug Priority: Major - P3
Reporter: Ben Becker Assignee: Benety Goh
Resolution: Duplicate Votes: 1
Labels: performance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File QA401.export     File SERVER-12952-master-with-patches.svg     File SERVER12952-v249.svg     File SERVER12952.cpp    
Issue Links:
Duplicate
is duplicated by SERVER-13139 Performance regression with smaller $... Closed
Related
is related to SERVER-12287 Query containing $regex operator: per... Closed
Operating System: ALL
Steps To Reproduce:

See QA-401.

Participants:

 Description   

The following regex query takes roughly 8x longer in v2.6.0-rc0 vs. v2.4.9:

db.QA401.find({ _id: /Big(ww)i/ }).sort({a:1})

The test collection has 920 documents (see attached) with the following indices:

db.QA401.ensureIndex({a:-1})
db.QA401.ensureIndex({'a.a':-1})
db.QA401.ensureIndex({'a.a.a':-1})

v2.6.0-rc0:

> db.QA401.find({ _id: /Big(ww)i/ }).sort({a:1}).explain();
{
        "cursor" : "BtreeCursor _id_",
        "isMultiKey" : false,
        "n" : 0,
        "nscannedObjects" : 0,
        "nscanned" : 1,
        "nscannedObjectsAllPlans" : 1,
        "nscannedAllPlans" : 2,
        "scanAndOrder" : true,
        "indexOnly" : false,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "millis" : 0,
        "indexBounds" : {
                "_id" : [
                        [
                                "",
                                {
 
                                }
                        ],
                        [
                                /Big(ww)i/,
                                /Big(ww)i/
                        ]
                ]
        },
        "server" : "zzyzx:27017",
        "filterSet" : false
}

v2.4.9:

> db.QA401.find({ _id: /Big(ww)i/ }).sort({a:1}).explain();
{
        "cursor" : "BtreeCursor _id_ multi",
        "isMultiKey" : false,
        "n" : 0,
        "nscannedObjects" : 0,
        "nscanned" : 1,
        "nscannedObjectsAllPlans" : 0,
        "nscannedAllPlans" : 3,
        "scanAndOrder" : true,
        "indexOnly" : false,
        "nYields" : 0,
        "nChunkSkips" : 0,
        "millis" : 0,
        "indexBounds" : {
                "_id" : [
                        [
                                "",
                                {
 
                                }
                        ],
                        [
                                /Big(ww)i/,
                                /Big(ww)i/
                        ]
                ]
        },
        "server" : "zzyzx:27018"
}

The query times are sub-millisecond; here is the output from QA-401:

{
        "_id" : ObjectId("530f6bad7e6c53525919dfb6"),
        "deltaRatio" : "8.40",
        "deltaUs" : 741,
        "v249Avg" : "100.17",
        "v249Results" : [
                100,
                102,
                101,
                99,
                100,
                99
        ],
        "rc0Avg" : "841.17",
        "rc0Results" : [
                870,
                882,
                839,
                817,
                815,
                824
        ],
        "testId" : "GeneratedTests::GeneratedQuery750[Descending]",
        "qry" : "{ query: { _id: //Big(ww)i// }, orderby: { a: 1 } }",
        "proj" : "{ NONE: 1 }",
        "idx" : "Descending",
        "rc0Count" : 0,
        "v249Count" : 0,
        "countsMatch" : true
}

I'm having a tough time distilling this down to something which can be reproduced in the shell (with measurable results).



 Comments   
Comment by Githook User [ 03/Mar/14 ]

Author:

{u'username': u'hkhalsa', u'name': u'Hari Khalsa', u'email': u'hkhalsa@10gen.com'}

Message: SERVER-12952 do less work for non-matching index docs
Branch: master
https://github.com/mongodb/mongo/commit/785b41bb229d49352e883df2fe0f927888772c8f

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