Skip to content

Instantly share code, notes, and snippets.

@extrawurst
Created August 22, 2020 08:22
Show Gist options
  • Save extrawurst/6385e793a841111a6f81c71f18be1edf to your computer and use it in GitHub Desktop.
Save extrawurst/6385e793a841111a6f81c71f18be1edf to your computer and use it in GitHub Desktop.
cosmos db compound index count RU issue
globaldb:PRIMARY> db.users.count({test:"TelescopeTest2",created:{$gte:"2020-08-20T06:00:00Z"}})
29239
globaldb:PRIMARY> db.runCommand({getLastRequestStatistics:1})
{
"CommandName" : "count",
"RequestCharge" : 1290.15,
"RequestDurationInMilliSeconds" : NumberLong(268),
"ActivityId" : "f94b30bb-3599-49a7-a888-982827b6be51",
"ok" : 1
}
globaldb:PRIMARY> db.users.explain().count({test:"TelescopeTest2",created:{$gte:"2020-08-20T06:00:00Z"}})
{
"stages" : [
{
"stage" : "$aggregateQuery",
"timeInclusiveMS" : 246.0923,
"timeExclusiveMS" : 0.0361,
"in" : 1,
"out" : 1,
"details" : {
"database" : "telescope",
"collection" : "users",
"query" : {
"$and" : [
{
"test" : {
"$eq" : "TelescopeTest2"
}
},
{
"created" : {
"$gte" : "2020-08-20T06:00:00Z"
}
}
]
},
"pathsIndexed" : [
"test",
"created"
],
"pathsNotIndexed" : [ ],
"aggregate" : {
"$count" : "c"
},
"shardInformation" : [
{
"activityId" : "2a0da7a0-c666-488d-8eb1-33b28d352926",
"shardKeyRangeId" : "0",
"durationMS" : 245.0833,
"preemptions" : 1,
"outputDocumentCount" : 1,
"retrievedDocumentCount" : 29283
}
],
"queryMetrics" : {
"retrievedDocumentCount" : 29283,
"retrievedDocumentSizeBytes" : 14203581,
"outputDocumentCount" : 1,
"outputDocumentSizeBytes" : 46,
"indexHitRatio" : 0,
"totalQueryExecutionTimeMS" : 243.55,
"queryPreparationTimes" : {
"queryCompilationTimeMS" : 0.17,
"logicalPlanBuildTimeMS" : 0.13,
"physicalPlanBuildTimeMS" : 0.25,
"queryOptimizationTimeMS" : 0.04
},
"indexLookupTimeMS" : 0.24000000000000002,
"documentLoadTimeMS" : 154.12,
"vmExecutionTimeMS" : 242.72,
"runtimeExecutionTimes" : {
"queryEngineExecutionTimeMS" : 88.36,
"systemFunctionExecutionTimeMS" : 34.82,
"userDefinedFunctionExecutionTimeMS" : 0
},
"documentWriteTimeMS" : 0
}
}
}
],
"estimatedDelayFromRateLimitingInMilliseconds" : 0,
"continuation" : {
"hasMore" : false
},
"ok" : 1
}
globaldb:PRIMARY> db.users.getIndexes()
[
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_",
"ns" : "telescope.users"
},
{
"v" : 1,
"key" : {
"test" : 1
},
"name" : "test_1",
"ns" : "telescope.users"
},
{
"v" : 1,
"key" : {
"test" : 1,
"created" : 1
},
"name" : "test_1_created_1",
"ns" : "telescope.users"
},
{
"v" : 1,
"key" : {
"test" : 1,
"group" : 1
},
"name" : "test_1_group_1",
"ns" : "telescope.users"
},
{
"v" : 1,
"unique" : true,
"key" : {
"id" : 1,
"test" : 1
},
"name" : "id_1_test_1",
"ns" : "telescope.users"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment