Pageable请求如何运作?

时间:2018-06-15 07:19:18

标签: mongodb mongo-java-driver

我有一个Pageable请求,查询大约160万个文档,每个请求限制对1000个文档的响应。查询使用索引......至少它应该......我使用db.currentOp()来查找需要一段时间才能处理的请求。当我启动查询(昨天下午01:00)时,它使用1000的每个部分的索引。但似乎在某些时候他决定不再使用它...而且我无法弄清楚原因。 ..

我对同一个查询也有一个command操作,它正在使用索引。

{
        "desc" : "conn7758",
        "threadId" : "1012",
        "connectionId" : 7758,
        "client" : "10.10.10.3:64670",
        "clientMetadata" : {
                "driver" : {
                        "name" : "mongo-java-driver",
                        "version" : "unknown"
                },
                "os" : {
                        "type" : "Windows",
                        "name" : "Windows Server 2008 R2",
                        "architecture" : "x86",
                        "version" : "6.1"
                },
                "platform" : "Java/Oracle Corporation/1.8.0_73-b02"
        },
        "active" : true,
        "opid" : 119588895,
        "secs_running" : 1299,
        "microsecs_running" : NumberLong(1299666014),
        "op" : "command",
        "ns" : "thingsplay.data",
        "query" : {
                "count" : "data",
                "query" : {
                        "device" : "S000110",
                        "topic" : "INPUTS/COIL1000",
                        "date" : {
                                "$gt" : ISODate("2015-08-08T06:00:00Z"),
                                "$lt" : ISODate("2018-06-14T11:28:08.369Z")
                        }
                }
        },
        "planSummary" : "IXSCAN { device: 1, topic: 1, vhost: 1}",
        "numYields" : 81449,
        "locks" : {
                "Global" : "r",
                "Database" : "r",
                "Collection" : "r"
        },
        "waitingForLock" : false,
        "lockStats" : {
                "Global" : {
                        "acquireCount" : {
                                "r" : NumberLong(162900)
                        }
                },
                "Database" : {
                        "acquireCount" : {
                                "r" : NumberLong(81450)
                        }
                },
                "Collection" : {
                        "acquireCount" : {
                                "r" : NumberLong(81450)
                        }
                }
        }
}

请求仍在运行......我认为这将持续几个小时。 以下是最后运行的操作:

{
        "desc" : "conn7758",
        "threadId" : "1012",
        "connectionId" : 7758,
        "client" : "10.10.10.3:64670",
        "clientMetadata" : {
                "driver" : {
                        "name" : "mongo-java-driver",
                        "version" : "unknown"
                },
                "os" : {
                        "type" : "Windows",
                        "name" : "Windows Server 2008 R2",
                        "architecture" : "x86",
                        "version" : "6.1"
                },
                "platform" : "Java/Oracle Corporation/1.8.0_73-b02"
        },
        "active" : true,
        "opid" : 120813021,
        "secs_running" : 134,
        "microsecs_running" : NumberLong(134586683),
        "op" : "query",
        "ns" : "thingsplay.data",
        "query" : {
                "find" : "data",
                "filter" : {
                        "device" : "S000110",
                        "topic" : "INPUTS/COIL1000",
                        "date" : {
                                "$gt" : ISODate("2015-08-08T06:00:00Z"),
                                "$lt" : ISODate("2018-06-14T11:28:08.369Z")
                        }
                },
                "projection" : {

                },
                "skip" : 1124000,
                "limit" : 1000
        },
        "numYields" : 8445,
        "locks" : {
                "Global" : "r",
                "Database" : "r",
                "Collection" : "r"
        },
        "waitingForLock" : false,
        "lockStats" : {
                "Global" : {
                        "acquireCount" : {
                                "r" : NumberLong(16892)
                        }
                },
                "Database" : {
                        "acquireCount" : {
                                "r" : NumberLong(8446)
                        }
                },
                "Collection" : {
                        "acquireCount" : {
                                "r" : NumberLong(8446)
                        }
                }
        }
}

不幸的是,我没有完成第一次操作的操作,但是你可以看到它没有使用索引。

[
        {
                "v" : 2,
                "key" : {
                        "_id" : 1
                },
                "name" : "_id_",
                "ns" : "thingsplay.data"
        },
        {
                "v" : 2,
                "key" : {
                        "device" : 1,
                        "topic" : 1,
                        "date" : 1
                },
                "name" : "device_1_topic_1_date_1",
                "ns" : "thingsplay.data",
                "background" : true
        },
        {
                "v" : 2,
                "key" : {
                        "device" : 1,
                        "topic" : 1,
                        "vhost" : 1
                },
                "name" : "device_1_topic_1_vhost_1",
                "ns" : "thingsplay.data",
                "background" : true
        }
]

0 个答案:

没有答案