|
I had to obfuscate logs a little bit, but the idea is the same.
The more data I tried to fetch from server, the faster it is. "Department" field represents an array of object with a lot of properties. It seems like when I include it in a projection, it slightly reduces the number of locks.
db.companies.aggregate([
|
{"$sample": {"size": 20}},
|
{"$match": {"$or": [{"status": "ACTIVE"}, {"status": "$exists"}]}},
|
{"$project": {"companyId": 1}},
|
{"$sample": {"size": 10}}]
|
)
|
|
2017-07-26T19:15:47.008+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:135 nreturned:10 reslen:752 locks:{ Global: { acquireCount: { r: 280 } }, Database: { acquireCount: { r: 140 } }, Collection: { acquireCount: { r: 139 } } } protocol:op_command 1647ms
|
2017-07-26T19:15:49.005+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:131 nreturned:10 reslen:752 locks:{ Global: { acquireCount: { r: 272 } }, Database: { acquireCount: { r: 136 } }, Collection: { acquireCount: { r: 135 } } } protocol:op_command 1520ms
|
2017-07-26T19:15:51.125+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:131 nreturned:10 reslen:754 locks:{ Global: { acquireCount: { r: 272 } }, Database: { acquireCount: { r: 136 } }, Collection: { acquireCount: { r: 135 } } } protocol:op_command 1511ms
|
2017-07-26T19:15:52.992+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:130 nreturned:10 reslen:750 locks:{ Global: { acquireCount: { r: 270 } }, Database: { acquireCount: { r: 135 } }, Collection: { acquireCount: { r: 134 } } } protocol:op_command 1438ms
|
2017-07-26T19:15:54.999+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:131 nreturned:10 reslen:751 locks:{ Global: { acquireCount: { r: 272 } }, Database: { acquireCount: { r: 136 } }, Collection: { acquireCount: { r: 135 } } } protocol:op_command 1491ms
|
2017-07-26T19:15:56.985+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:132 nreturned:10 reslen:751 locks:{ Global: { acquireCount: { r: 274 } }, Database: { acquireCount: { r: 137 } }, Collection: { acquireCount: { r: 136 } } } protocol:op_command 1560ms
|
2017-07-26T19:15:58.958+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:135 nreturned:10 reslen:750 locks:{ Global: { acquireCount: { r: 280 } }, Database: { acquireCount: { r: 140 } }, Collection: { acquireCount: { r: 139 } } } protocol:op_command 1545ms
|
|
|
db.companies.aggregate([
|
{"$sample": {"size": 20}},
|
{"$match": {"$or": [{"status": "ACTIVE"}, {"status": "$exists"}]}},
|
{"$project": {"companyId": 1, "name": 1, "description": 1}},
|
{"$sample": {"size": 10}}]
|
)
|
|
2017-07-26T19:10:52.706+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:92 nreturned:10 reslen:1480 locks:{ Global: { acquireCount: { r: 194 } }, Database: { acquireCount: { r: 97 } }, Collection: { acquireCount: { r: 96 } } } protocol:op_command 1136ms
|
2017-07-26T19:10:54.106+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:92 nreturned:10 reslen:1459 locks:{ Global: { acquireCount: { r: 194 } }, Database: { acquireCount: { r: 97 } }, Collection: { acquireCount: { r: 96 } } } protocol:op_command 991ms
|
2017-07-26T19:10:55.820+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:95 nreturned:10 reslen:1480 locks:{ Global: { acquireCount: { r: 200 } }, Database: { acquireCount: { r: 100 } }, Collection: { acquireCount: { r: 99 } } } protocol:op_command 1116ms
|
2017-07-26T19:10:57.349+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:92 nreturned:10 reslen:1490 locks:{ Global: { acquireCount: { r: 194 } }, Database: { acquireCount: { r: 97 } }, Collection: { acquireCount: { r: 96 } } } protocol:op_command 1061ms
|
2017-07-26T19:10:58.965+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:93 nreturned:10 reslen:1471 locks:{ Global: { acquireCount: { r: 196 } }, Database: { acquireCount: { r: 98 } }, Collection: { acquireCount: { r: 97 } } } protocol:op_command 1197ms
|
2017-07-26T19:11:00.323+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:94 nreturned:10 reslen:1517 locks:{ Global: { acquireCount: { r: 198 } }, Database: { acquireCount: { r: 99 } }, Collection: { acquireCount: { r: 98 } } } protocol:op_command 1155ms
|
2017-07-26T19:11:02.052+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:94 nreturned:10 reslen:1514 locks:{ Global: { acquireCount: { r: 198 } }, Database: { acquireCount: { r: 99 } }, Collection: { acquireCount: { r: 98 } } } protocol:op_command 1170ms
|
|
db.companies.aggregate([
|
{"$sample": {"size": 20}},
|
{"$match": {"$or": [{"status": "ACTIVE"}, {"status": "$exists"}]}},
|
{"$project": {"companyId": 1, "name": 1, "description": 1, "departments": 1}},
|
{"$sample": {"size": 10}}]
|
)
|
|
2017-07-26T19:12:35.507+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0, departments: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:134840 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 23ms
|
2017-07-26T19:12:36.167+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0, departments: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:216443 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 27ms
|
2017-07-26T19:12:36.826+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0, departments: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:2 nreturned:10 reslen:155636 locks:{ Global: { acquireCount: { r: 14 } }, Database: { acquireCount: { r: 7 } }, Collection: { acquireCount: { r: 6 } } } protocol:op_command 38ms
|
2017-07-26T19:12:37.506+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0, departments: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:143475 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 24ms
|
2017-07-26T19:12:38.066+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0, departments: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:151309 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 21ms
|
2017-07-26T19:12:38.791+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0, departments: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:176909 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 19ms
|
2017-07-26T19:12:39.514+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { companyId: 1.0, name: 1.0, description: 1.0, departments: 1.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:88417 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 21ms
|
|
db.companies.aggregate([
|
{"$sample": {"size": 20}},
|
{"$match": {"$or": [{"status": "ACTIVE"}, {"status": "$exists"}]}},
|
{"$project": {"departments": 0, "geoData": 0, "status": 0, "createdOn": 0, "modifiedOn": 0, "version": 0}},
|
{"$sample": {"size": 10}}]
|
)
|
|
2017-07-26T19:16:53.976+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { departments: 0.0, geoData: 0.0, status: 0.0, createdOn: 0.0, modifiedOn: 0.0, version: 0.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:1428 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 22ms
|
2017-07-26T19:16:54.408+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { departments: 0.0, geoData: 0.0, status: 0.0, createdOn: 0.0, modifiedOn: 0.0, version: 0.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:1451 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 22ms
|
2017-07-26T19:16:54.735+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { departments: 0.0, geoData: 0.0, status: 0.0, createdOn: 0.0, modifiedOn: 0.0, version: 0.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:1448 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 20ms
|
2017-07-26T19:16:55.191+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { departments: 0.0, geoData: 0.0, status: 0.0, createdOn: 0.0, modifiedOn: 0.0, version: 0.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:1462 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 17ms
|
2017-07-26T19:16:55.694+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { departments: 0.0, geoData: 0.0, status: 0.0, createdOn: 0.0, modifiedOn: 0.0, version: 0.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:0 nreturned:10 reslen:1488 locks:{ Global: { acquireCount: { r: 10 } }, Database: { acquireCount: { r: 5 } }, Collection: { acquireCount: { r: 4 } } } protocol:op_command 20ms
|
2017-07-26T19:16:56.122+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { departments: 0.0, geoData: 0.0, status: 0.0, createdOn: 0.0, modifiedOn: 0.0, version: 0.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:2 nreturned:10 reslen:1479 locks:{ Global: { acquireCount: { r: 14 } }, Database: { acquireCount: { r: 7 } }, Collection: { acquireCount: { r: 6 } } } protocol:op_command 35ms
|
2017-07-26T19:16:56.561+0000 I COMMAND [conn557] command Whatever.companies command: aggregate { aggregate: "companies", pipeline: [ { $sample: { size: 20.0 } }, { $match: { $or: [ { status: "ACTIVE" }, { status: "$exists" } ] } }, { $project: { departments: 0.0, geoData: 0.0, status: 0.0, createdOn: 0.0, modifiedOn: 0.0, version: 0.0 } }, { $sample: { size: 10.0 } } ], cursor: {} } planSummary: MULTI_ITERATOR keysExamined:0 docsExamined:0 cursorExhausted:1 numYields:1 nreturned:10 reslen:1490 locks:{ Global: { acquireCount: { r: 12 } }, Database: { acquireCount: { r: 6 } }, Collection: { acquireCount: { r: 5 } } } protocol:op_command 20ms
|
|
|