Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execution time millis equal to 0 - MongoDB

I used two NOSQL database, MongoDB and Neo4j, to handle the same information. I want to compare the performance using the first and second db. I talked about my problem with MongoDB in this question: the execution time millis was always equal to 0. So I added approximately 250 documents in my collection but without any success:

> db.team.find({common_name:"Milan"},{_id:0, "stadium.name":1}).explain("executionStats")

{
        "queryPlanner" : {
                "plannerVersion" : 1,
                "namespace" : "Progettino.team",
                "indexFilterSet" : false,
                "parsedQuery" : {
                        "common_name" : {
                                "$eq" : "Milan"
                        }
                },
                "winningPlan" : {
                        "stage" : "PROJECTION",
                        "transformBy" : {
                                "_id" : 0,
                                "stadium.name" : 1
                        },
                        "inputStage" : {
                                "stage" : "COLLSCAN",
                                "filter" : {
                                        "common_name" : {
                                                "$eq" : "Milan"
                                        }
                                },
                                "direction" : "forward"
                        }
                },
                "rejectedPlans" : [ ]
        },
        "executionStats" : {
                "executionSuccess" : true,
                "nReturned" : 1,
                "executionTimeMillis" : 0,
                "totalKeysExamined" : 0,
                "totalDocsExamined" : 253,
                "executionStages" : {
                        "stage" : "PROJECTION",
                        "nReturned" : 1,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 255,
                        "advanced" : 1,
                        "needTime" : 253,
                        "needFetch" : 0,
                        "saveState" : 0,
                        "restoreState" : 0,
                        "isEOF" : 1,
                        "invalidates" : 0,
                        "transformBy" : {
                                "_id" : 0,
                                "stadium.name" : 1
                        },
                        "inputStage" : {
                                "stage" : "COLLSCAN",
                                "filter" : {
                                        "common_name" : {
                                                "$eq" : "Milan"
                                        }
                                },
                                "nReturned" : 1,
                                "executionTimeMillisEstimate" : 0,
                                "works" : 255,
                                "advanced" : 1,
                                "needTime" : 253,
                                "needFetch" : 0,
                                "saveState" : 0,
                                "restoreState" : 0,
                                "isEOF" : 1,
                                "invalidates" : 0,
                                "direction" : "forward",
                                "docsExamined" : 255
                        }
                }
        }


For example in MongoDB, this query will work better than in Neo4j, because I used denormalized model to represent information about teams' stadium. In fact, in Neo4j, this query needs 50 ms as you can see:
enter image description here

So, what can I do to have information about execution time millis in MongoDB? I have some problems if execution time millis is always equal to 0 because I can't show different performance on same queries with the two different NoSQL DB.

like image 230
DistribuzioneGaussiana Avatar asked Aug 03 '15 16:08

DistribuzioneGaussiana


1 Answers

As stated in your other question that I answered. Your collection is just too small. here is the output I have from a database with over 3K items. Notice my executionTimeInMillis is only 2 milliseconds. You are going to need a lot more data to make mongo really churn. talking 10K plus records depending on what the size of your machine is.

{
"queryPlanner" : {
    "plannerVersion" : 1,
    "namespace" : "arenas.arenas",
    "indexFilterSet" : false,
    "parsedQuery" : {
        "$and" : []
    },
    "winningPlan" : {
        "stage" : "COLLSCAN",
        "filter" : {
            "$and" : []
        },
        "direction" : "forward"
    },
    "rejectedPlans" : []
},
"executionStats" : {
    "executionSuccess" : true,
    "nReturned" : 3718,
    "executionTimeMillis" : 2,
    "totalKeysExamined" : 0,
    "totalDocsExamined" : 3718,
    "executionStages" : {
        "stage" : "COLLSCAN",
        "filter" : {
            "$and" : []
        },
        "nReturned" : 3718,
        "executionTimeMillisEstimate" : 0,
        "works" : 3724,
        "advanced" : 3718,
        "needTime" : 1,
        "needFetch" : 4,
        "saveState" : 31,
        "restoreState" : 31,
        "isEOF" : 1,
        "invalidates" : 0,
        "direction" : "forward",
        "docsExamined" : 3718
    },
    "allPlansExecution" : []
}

}

like image 145
ThrowsException Avatar answered Oct 28 '22 17:10

ThrowsException