Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. for(i=0;i<1000;i++){db.doc.insert({"doc":{"k1":"v_"+i,"k2":i},"scal":i})}
  2.  
  3. var d1 = db.doc.findOne()
  4. {
  5. "_id" : ObjectId("5ce25f8920b0be2428648e38"),
  6. "doc" : {
  7. "k1" : "v_0",
  8. "k2" : 0
  9. },
  10. "scal" : 0
  11. }
  12.  
  13. db.doc.createIndex({"doc":1})
  14. db.doc.createIndex({"scal":1})
  15.  
  16. db.doc.explain(true).find({doc:{$gt:d1.doc}},{_id:0,doc:1})
  17. {
  18. ...
  19. "executionStats" : {
  20. "executionSuccess" : true,
  21. "nReturned" : 999,
  22. "executionTimeMillis" : 1,
  23. "totalKeysExamined" : 999,
  24. "totalDocsExamined" : 999,
  25. ...
  26. }
  27.  
  28. db.doc.explain(true).find({scal:{$gt:d1.scal}},{_id:0,scal:1})
  29. {
  30. ...
  31. "executionStats" : {
  32. "executionSuccess" : true,
  33. "nReturned" : 999,
  34. "executionTimeMillis" : 0,
  35. "totalKeysExamined" : 999,
  36. "totalDocsExamined" : 0,
  37. ...
  38. }
  39.  
  40. db.doc.explain(true).find({doc:d1.doc},{_id:0,doc:1})
  41. {
  42. ...
  43. "executionStats" : {
  44. "executionSuccess" : true,
  45. "nReturned" : 1,
  46. "executionTimeMillis" : 0,
  47. "totalKeysExamined" : 1,
  48. "totalDocsExamined" : 0,
  49. ...
  50. }
  51.  
  52. var dis = db.doc.distinct("doc")
  53. db.doc.explain(true).find({doc:{$in:dis}},{_id:0,doc:1})
  54. {
  55. ...
  56. "executionStats" : {
  57. "executionSuccess" : true,
  58. "nReturned" : 1000,
  59. "executionTimeMillis" : 8,
  60. "totalKeysExamined" : 1000,
  61. "totalDocsExamined" : 0,
  62. ...
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement