Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在单节点大数据集的情况下提高mongodb的性能?_Mongodb_Performance_Mongodb Query_Nosql - Fatal编程技术网

如何在单节点大数据集的情况下提高mongodb的性能?

如何在单节点大数据集的情况下提高mongodb的性能?,mongodb,performance,mongodb-query,nosql,Mongodb,Performance,Mongodb Query,Nosql,我刚从mongodb开始。我正在使用ssd stoarge处理38GB数据集(6800万个文档)。 但是性能是通过索引和不索引来实现的。而且它使用了如此多的ram来进行带有两个字段的简单查找查询,而不使用cpu 获取160万条记录需要18分钟。哪些因素有助于提高单节点mongodb的性能 我的文档如下所示: { "_id" : ObjectId("55e7eec02756dd0f1e693b72"), "categorieId" : 2, "title" : "AntiMalware

我刚从mongodb开始。我正在使用ssd stoarge处理38GB数据集(6800万个文档)。 但是性能是通过索引和不索引来实现的。而且它使用了如此多的ram来进行带有两个字段的简单查找查询,而不使用cpu

获取160万条记录需要18分钟。哪些因素有助于提高单节点mongodb的性能

我的文档如下所示:

{ "_id" : ObjectId("55e7eec02756dd0f1e693b72"), 
  "categorieId" : 2, 
  "title" : "AntiMalware",  
  "messageValue" : " #\"Antimalware: \"Windows Defender\" is Not Updated and Running\"#",  
  "timestamp" : "8/19/2015 11:06:24 AM",  
  "resultStatusId" : 2,  
  "messageFormat" : "Text",  
  "titleId" : 1,  
  "resultStatus" : "Warning",  
  "antiMalwareName" : "Comodo Antivirus",  
  "categories" : "Security" } 
我的索引位于
标题ID
结果状态ID

我的问题是:

   db.collection.find({"titleId":21, resultStatusId:1}) 
解释输出为:

{
    "queryPlanner" : {
        "plannerVersion" : 1,
        "namespace" : "techHealLogAnalysis.techHealTestLogData",
        "indexFilterSet" : false,
        "parsedQuery" : {
            "$and" : [
                {
                    "resultStatusId" : {
                        "$eq" : 1
                    }
                },
                {
                    "titleId" : {
                        "$eq" : 21
                    }
                }
            ]
        },
        "winningPlan" : {
            "stage" : "FETCH",
            "inputStage" : {
                "stage" : "IXSCAN",
                "keyPattern" : {
                    "titleId" : 1,
                    "resultStatusId" : 1
                },
                "indexName" : "titleId_1_resultStatusId_1",
                "isMultiKey" : false,
                "direction" : "forward",
                "indexBounds" : {
                    "titleId" : [
                        "[21.0, 21.0]"
                    ],
                    "resultStatusId" : [
                        "[1.0, 1.0]"
                    ]
                }
            }
        },
        "rejectedPlans" : [ ]
    },
    "executionStats" : {
        "executionSuccess" : true,
        "nReturned" : 1671842,
        "executionTimeMillis" : 1108805,
        "totalKeysExamined" : 1671842,
        "totalDocsExamined" : 1671842,
        "executionStages" : {
            "stage" : "FETCH",
            "nReturned" : 1671842,
            "executionTimeMillisEstimate" : 177670,
            "works" : 2143234,
            "advanced" : 1671842,
            "needTime" : 0,
            "needFetch" : 471391,
            "saveState" : 471391,
            "restoreState" : 471391,
            "isEOF" : 1,
            "invalidates" : 0,
            "docsExamined" : 1671842,
            "alreadyHasObj" : 0,
            "inputStage" : {
                "stage" : "IXSCAN",
                "nReturned" : 1671842,
                "executionTimeMillisEstimate" : 1470,
                "works" : 1671843,
                "advanced" : 1671842,
                "needTime" : 0,
                "needFetch" : 0,
                "saveState" : 471391,
                "restoreState" : 471391,
                "isEOF" : 1,
                "invalidates" : 0,
                "keyPattern" : {
                    "titleId" : 1,
                    "resultStatusId" : 1
                },
                "indexName" : "titleId_1_resultStatusId_1",
                "isMultiKey" : false,
                "direction" : "forward",
                "indexBounds" : {
                    "titleId" : [
                        "[21.0, 21.0]"
                    ],
                    "resultStatusId" : [
                        "[1.0, 1.0]"
                    ]
                },
                "keysExamined" : 1671842,
                "dupsTested" : 0,
                "dupsDropped" : 0,
                "seenInvalidated" : 0,
                "matchTested" : 0
            }
        }
    },
    "serverInfo" : {
        "host" : "instance-7",
        "port" : 27017,
        "version" : "3.0.6",
        "gitVersion" : "1ef45a23a4c5e3480ac919b28afcba3c615488f2"
    },
    "ok" : 1
}

具有大数据集和高吞吐量应用程序的数据库系统可能会挑战单个服务器的容量。较大的数据集超过了一台机器的存储容量。最后,大于系统RAM的工作集大小会增加磁盘驱动器的I/O容量。为您的案例部署分片可能非常有用。一旦查看以下链接


MongoDB的大内存使用是正常的。它总是使用尽可能多的RAM来缓存最近的结果。为了帮助您改进查询,您需要向我们展示您的文档的外观、索引以及执行的查询。我的文档的外观如下:-{“_id”:ObjectId(“55e7eec02756dd0f1e693b72”),“categorieId”:2,“title”:“AntiMalware”,“messageValue”:“#\”反恶意软件:“Windows Defender\”未更新并正在运行“#”、“timestamp”:“8/19/2015 11:06:24 AM”、“resultStatusId”:2,“messageFormat”:“Text”、“titleId”:1,“resultStatus”:“Warning”、“antiMalwareName”:“Comodo Antivirus”、“categories”:“Security”}我的查询是:-db.collection.find({“titleId”:21,resultStatusId:1})我的索引在“标题ID”和“结果状态ID”上“这是两个独立的索引还是一个复合索引?请同时输入并将输出添加到问题中。它提供了有关索引是否使用以及如何使用的重要信息。它是单一的复合索引。谢谢。您能告诉我如何更改mongodb中的存储引擎吗?就我而言,我使用的是MMAPv1,但我想使用WiredTiger。@user3835987完全不知道。我是这里的新手。但是试着学习部署碎片和复制,这将使您了解使用MongoDB的全部本质