Hi everybody,
The context:
I need to build a report that shows 1 year worth of data (around 1.7 million of records).
The database contains one collection per report, here the db stats:
/* 1 */
{
"db" : "dbarc",
"collections" : 839,
"views" : 0,
"objects" : 34745518,
"avgObjSize" : 3965.76271463272,
"dataSize" : 137792479785.0,
"storageSize" : 76157050880.0,
"numExtents" : 0,
"indexes" : 9287,
"indexSize" : 17899974656.0,
"fsUsedSize" : 276794646528.0,
"fsTotalSize" : 540052742144.0,
"ok" : 1.0
}
The problem:
The response time of queries for that amount of data is too much. 200 seconds for 1.7 million of records. Here the explain plan:
/* 1 */
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "dbarc.sps",
"indexFilterSet" : false,
"parsedQuery" : {},
"winningPlan" : {
"stage" : "COLLSCAN",
"direction" : "forward"
},
"rejectedPlans" : []
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 1727172,
"executionTimeMillis" : 141746,
"totalKeysExamined" : 0,
"totalDocsExamined" : 1727172,
"executionStages" : {
"stage" : "COLLSCAN",
"nReturned" : 1727172,
"executionTimeMillisEstimate" : 141095,
"works" : 1727174,
"advanced" : 1727172,
"needTime" : 1,
"needYield" : 0,
"saveState" : 14246,
"restoreState" : 14246,
"isEOF" : 1,
"invalidates" : 0,
"direction" : "forward",
"docsExamined" : 1727172
}
},
"serverInfo" : {
"host" : "MONGO1",
"port" : 27017,
"version" : "4.0.2",
"gitVersion" : "fc1573ba18aee42f97a3bb13b67af7d837826b47"
},
"ok" : 1.0
}
The collections has many indexes, one on a text field which can be large, iâm sure iâm missing something big, basic things. Iâm new about NoSQL dbs, i think the problem could be the total indexes size but i have no clue at the moment.
Thank you very much for the eventual help.