explain() in Mongodb: differences between “nscanned” and “nscannedObjects”

前端 未结 2 1130
迷失自我
迷失自我 2020-12-14 02:02

I cannot get the exact difference between \"nscanned\" and \"nscannedObjects\" in the Mongodb\'s explain query output.

On MongoDB Explain documentation I can read:

相关标签:
2条回答
  • 2020-12-14 02:34

    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

    0 讨论(0)
  • 2020-12-14 02:48

    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!

    0 讨论(0)
提交回复
热议问题