mongodb查询解释和索引nscanned大于nscannedObjects

时间:2016-11-16 15:30:47

标签: mongodb mongodb-query

我的查询出了问题。它表现不佳。

它做得像300毫秒--1000毫秒。

我在每个列上添加了索引。但似乎无法做到正确。

抱歉忘了提及下面的文件是upsert的查询。

只有一个额外的{value.count:1}

文件:

    {
            "_id.browser" : "Facebook",
            "_id.c1" : "hpb",
            "_id.c2" : "003",
            "_id.c3" : "us100_01",
            "_id.c4" : "us-18-13a",
            "_id.campaign_id" : "47cff2989aef12808a8a596b9b703efc",
            "_id.city" : "Edgewood",
            "_id.cloaked" : "0",
            "_id.country" : "United States",
            "_id.date_visited" : "2016-11-16",
            "_id.device_name" : "Samsung Galaxy S6",
            "_id.device_type" : "mobile",
            "_id.domain" : "healthypowerbuzz.com",
            "_id.hour_visited" : "10",
            "_id.isp" : "AT&T U-verse",
            "_id.landingpage_id" : "38a67be59dc9d8f6db81be94b207f2d7",
            "_id.netspeed_id" : NumberLong(3),
            "_id.offer_id" : [ 
                {
                    "offer_id" : "cd0d1a0fa7021b99a6f1b630cac64a39"
                }, 
                {
                    "offer_id" : "1f42d6d81d69bf8c9912ae75544eea9c"
                }
            ],
            "_id.org" : "AT&T U-verse",
            "_id.platform" : "Android",
            "_id.server_id" : "b5e04772f2ee237a36f24e8298c3d002",
            "_id.set" : "13",
            "_id.traffic_account_id" : "cdd60f26f1723f05ee4e964a8e6f43a7",
            "_id.week_visited" : "Wednesday",
"value.count" : 100
        }

查询:

db.tes.update(
   {
        "_id.browser" : "Facebook",
        "_id.c1" : "hpb",
        "_id.c2" : "003",
        "_id.c3" : "us100_01",
        "_id.c4" : "us-18-13a",
        "_id.campaign_id" : "47cff2989aef12808a8a596b9b703efc",
        "_id.city" : "Edgewood",
        "_id.cloaked" : "0",
        "_id.country" : "United States",
        "_id.date_visited" : "2016-11-16",
        "_id.device_name" : "Samsung Galaxy S6",
        "_id.device_type" : "mobile",
        "_id.domain" : "healthypowerbuzz.com",
        "_id.hour_visited" : "10",
        "_id.isp" : "AT&T U-verse",
        "_id.landingpage_id" : "38a67be59dc9d8f6db81be94b207f2d7",
        "_id.netspeed_id" : NumberLong(3),
        "_id.offer_id" : [ 
            {
                "offer_id" : "cd0d1a0fa7021b99a6f1b630cac64a39"
            }, 
            {
                "offer_id" : "1f42d6d81d69bf8c9912ae75544eea9c"
            }
        ],
        "_id.org" : "AT&T U-verse",
        "_id.platform" : "Android",
        "_id.server_id" : "b5e04772f2ee237a36f24e8298c3d002",
        "_id.set" : "13",
        "_id.traffic_account_id" : "cdd60f26f1723f05ee4e964a8e6f43a7",
        "_id.week_visited" : "Wednesday"},
   {
     $inc: { value.count:1 }
   },
   { upsert: true }
)

我在每个上面添加了一个复合索引。因为我用它来upsert $ inc count:1。但它真的很慢。

当我解释时,我得到了这个。我需要帮助来解决这个问题。

"n" : 1,
    "nscannedObjects" : 7773,
    "nscanned" : 15546,
    "nscannedObjectsAllPlans" : 7773,
    "nscannedAllPlans" : 15546,

0 个答案:

没有答案