首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何提高单节点大数据集的mongodb性能?

如何提高单节点大数据集的mongodb性能?
EN

Stack Overflow用户
提问于 2015-09-09 14:47:29
回答 1查看 869关注 0票数 0

我刚开始使用mongodb。我正在使用ssd存储的38 am数据集(6800万个文档)。但性能是在有索引和没有索引的情况下完成的。它使用了如此多的ram来进行简单的查找查询,有两个字段,没有cpu使用。

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

我的文档如下所示:

代码语言:javascript
复制
{ "_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" } 

我的索引在titleIdresultStatusId上。

我的问题是:

代码语言:javascript
复制
   db.collection.find({"titleId":21, resultStatusId:1}) 

解释输出为:

代码语言:javascript
复制
{
    "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
}
EN

回答 1

Stack Overflow用户

发布于 2015-09-09 20:23:27

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

http://docs.mongodb.org/manual/core/sharding-introduction/

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32472647

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档