Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 Below is a compound index that we have that is not selective enough. Whether its due to poor indexes or our queries is a different question. This seems like the default view for the browser forums. Another solution may be to limit the results.

Expand
titlenon selective index

db.contents.find({"_type":"CommentThread", "course_id":"BerkeleyX/GG101x/1T2014", "context":"course"}).explain()
{
"cursor" : "BtreeCursor _type_-1_course_id_1_context_1_pinned_-1_last_activity_at_-1_created_at_-1",
"isMultiKey" : false,
"n" : 76481,
"nscannedObjects" : 76481,
"nscanned" : 76481,
"nscannedObjectsAllPlans" : 77520,
"nscannedAllPlans" : 77531,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 6691,
"nChunkSkips" : 0,
"millis" : 85812,
"indexBounds" : {
"_type" : [
[
"CommentThread",
"CommentThread"
]
],
"course_id" : [
[
"BerkeleyX/GG101x/1T2014",
"BerkeleyX/GG101x/1T2014"
]
],
"context" : [
[
"course",
"course"
]
],
"pinned" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
],
"last_activity_at" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
],
"created_at" : [
[
{
"$maxElement" : 1
},
{
"$minElement" : 1
}
]
]
},
"server" : "c0:27017",
"filterSet" : false
}