Query around indexes and performance

23 views
Skip to first unread message

Preetham Gowda

unread,
Sep 13, 2017, 6:40:53 PM9/13/17
to mongodb-user

Query#1:  Let me know the how to create indexes on RecordID for following data sample that is stored in MongoDB.

{

    "_id" : ObjectId("59b72aea36d62fd9e60f28f7"),

    "EnrichedDocument" : {

        "Common" : {

            "Source" : {

                "#text" : "DELL"

            },

            "Stage" : {

                "#text" : "COMMON"

            },

            "RecordID" : {

                "#text" : "1111111"

            },

            "Stage" : {

                "#text" : "Order"

            }

                                }

                }

}

 

 

Query#2: After POC, we have narrowed to use following C# query to find duplicate records in a collection. Let me know if there is any better approach or index on the RecordID (refer query#1) will help to improve the performance.

 

returnDocument = collection.FindOneAndReplace(

                                         document,

                                         document,

                                         new FindOneAndReplaceOptions<BsonDocument, BsonDocument> {

                                                IsUpsert = true,

                                                ReturnDocument = ReturnDocument.Before

                                         }

                                  );

Wan Bachtiar

unread,
Sep 18, 2017, 10:32:41 PM9/18/17
to mongodb-user

Hi Preetham,

I would recommend to review MongoDB Indexes to get started in creating indexes.
See also MongoDB Query Optimization and Analyze Query Performance to see whether there are performance improvements that you could make.

Regards,
Wan

Reply all
Reply to author
Forward
0 new messages