explain() in Mongodb: differences between “nscanned” and “nscannedObjects”
I cannot get the exact difference between "nscanned" and "nscannedObjects" in the Mongodb's explain query output.
On MongoDB Explain documentation I can read:
nscanned Number of items (documents or index entries) examined. Items
might be objects or index keys. If a "covered index" is involved,
nscanned may be higher than nscannedObjects.
nscannedObjects Number of documents scanned.
What's the different between these two fields?
And more specific what does exactly mean when I have a query, which uses a BtreeCursor (an index), and these two fields have two different values, for example:
{
"cursor" : "BtreeCursor a_1_b_1",
"isMultiKey" : false,
"n" : 5,
"nscannedObjects" : 5,
"nscanned" : 9,
(...)
}
I know what a "covered index" is.
I would like to understand exactly what the query did in the example above.
Did it pass through ("scanned") 9 elements (nscanned = 9), where all of them are index entries and read ("examined") the value of only 5 of them (nscannedObjects = 5) to produce the result set?
mongodb
add a comment |
I cannot get the exact difference between "nscanned" and "nscannedObjects" in the Mongodb's explain query output.
On MongoDB Explain documentation I can read:
nscanned Number of items (documents or index entries) examined. Items
might be objects or index keys. If a "covered index" is involved,
nscanned may be higher than nscannedObjects.
nscannedObjects Number of documents scanned.
What's the different between these two fields?
And more specific what does exactly mean when I have a query, which uses a BtreeCursor (an index), and these two fields have two different values, for example:
{
"cursor" : "BtreeCursor a_1_b_1",
"isMultiKey" : false,
"n" : 5,
"nscannedObjects" : 5,
"nscanned" : 9,
(...)
}
I know what a "covered index" is.
I would like to understand exactly what the query did in the example above.
Did it pass through ("scanned") 9 elements (nscanned = 9), where all of them are index entries and read ("examined") the value of only 5 of them (nscannedObjects = 5) to produce the result set?
mongodb
add a comment |
I cannot get the exact difference between "nscanned" and "nscannedObjects" in the Mongodb's explain query output.
On MongoDB Explain documentation I can read:
nscanned Number of items (documents or index entries) examined. Items
might be objects or index keys. If a "covered index" is involved,
nscanned may be higher than nscannedObjects.
nscannedObjects Number of documents scanned.
What's the different between these two fields?
And more specific what does exactly mean when I have a query, which uses a BtreeCursor (an index), and these two fields have two different values, for example:
{
"cursor" : "BtreeCursor a_1_b_1",
"isMultiKey" : false,
"n" : 5,
"nscannedObjects" : 5,
"nscanned" : 9,
(...)
}
I know what a "covered index" is.
I would like to understand exactly what the query did in the example above.
Did it pass through ("scanned") 9 elements (nscanned = 9), where all of them are index entries and read ("examined") the value of only 5 of them (nscannedObjects = 5) to produce the result set?
mongodb
I cannot get the exact difference between "nscanned" and "nscannedObjects" in the Mongodb's explain query output.
On MongoDB Explain documentation I can read:
nscanned Number of items (documents or index entries) examined. Items
might be objects or index keys. If a "covered index" is involved,
nscanned may be higher than nscannedObjects.
nscannedObjects Number of documents scanned.
What's the different between these two fields?
And more specific what does exactly mean when I have a query, which uses a BtreeCursor (an index), and these two fields have two different values, for example:
{
"cursor" : "BtreeCursor a_1_b_1",
"isMultiKey" : false,
"n" : 5,
"nscannedObjects" : 5,
"nscanned" : 9,
(...)
}
I know what a "covered index" is.
I would like to understand exactly what the query did in the example above.
Did it pass through ("scanned") 9 elements (nscanned = 9), where all of them are index entries and read ("examined") the value of only 5 of them (nscannedObjects = 5) to produce the result set?
mongodb
mongodb
edited May 23 '17 at 12:17
Community♦
11
11
asked Dec 17 '12 at 7:40
Luigi Massa GalleranoLuigi Massa Gallerano
1,58011524
1,58011524
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
This means that :
The query returned 5 documents - n
scanned 9 documents from the index - nscanned
and then read 5 full documents from the collection - nscannedObjects
Similar example is given at :
http://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain
add a comment |
if "cursor" is Index ==> nscanned = no. of index scanned
else if "cursor" is FullTableScan ==> nscanned = no. of document scanned
nscannedObjects ==> No. of document scanned
when querying, try to minimise all count, i.e. nscanned and nscannedObjects both are minimum means your query should run faster!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13910097%2fexplain-in-mongodb-differences-between-nscanned-and-nscannedobjects%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
This means that :
The query returned 5 documents - n
scanned 9 documents from the index - nscanned
and then read 5 full documents from the collection - nscannedObjects
Similar example is given at :
http://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain
add a comment |
This means that :
The query returned 5 documents - n
scanned 9 documents from the index - nscanned
and then read 5 full documents from the collection - nscannedObjects
Similar example is given at :
http://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain
add a comment |
This means that :
The query returned 5 documents - n
scanned 9 documents from the index - nscanned
and then read 5 full documents from the collection - nscannedObjects
Similar example is given at :
http://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain
This means that :
The query returned 5 documents - n
scanned 9 documents from the index - nscanned
and then read 5 full documents from the collection - nscannedObjects
Similar example is given at :
http://docs.mongodb.org/manual/reference/method/cursor.explain/#cursor.explain
edited Oct 7 '14 at 16:01
answered Dec 17 '12 at 8:04
Ajay GeorgeAjay George
9,63713244
9,63713244
add a comment |
add a comment |
if "cursor" is Index ==> nscanned = no. of index scanned
else if "cursor" is FullTableScan ==> nscanned = no. of document scanned
nscannedObjects ==> No. of document scanned
when querying, try to minimise all count, i.e. nscanned and nscannedObjects both are minimum means your query should run faster!
add a comment |
if "cursor" is Index ==> nscanned = no. of index scanned
else if "cursor" is FullTableScan ==> nscanned = no. of document scanned
nscannedObjects ==> No. of document scanned
when querying, try to minimise all count, i.e. nscanned and nscannedObjects both are minimum means your query should run faster!
add a comment |
if "cursor" is Index ==> nscanned = no. of index scanned
else if "cursor" is FullTableScan ==> nscanned = no. of document scanned
nscannedObjects ==> No. of document scanned
when querying, try to minimise all count, i.e. nscanned and nscannedObjects both are minimum means your query should run faster!
if "cursor" is Index ==> nscanned = no. of index scanned
else if "cursor" is FullTableScan ==> nscanned = no. of document scanned
nscannedObjects ==> No. of document scanned
when querying, try to minimise all count, i.e. nscanned and nscannedObjects both are minimum means your query should run faster!
answered Dec 17 '12 at 14:58
Raxit ShethRaxit Sheth
89011017
89011017
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13910097%2fexplain-in-mongodb-differences-between-nscanned-and-nscannedobjects%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown