gpt4 book ai didi

java - Mongodb查询挂系统

转载 作者:太空宇宙 更新时间:2023-11-04 11:52:31 25 4
gpt4 key购买 nike

我使用的是 MongoDB 版本 2.6。

我里面有大约 300 万条数据。 当我触发下面的查询时,它会挂起我的整个 Java 应用程序。

(我正在使用 Mongodb 连接器 从那里检索数据。)

db.collection_name.find{
"client_id.event.currentDate": {
$gte: "2016-12-18",
$lte: "2017-01-17"
},
"client_id.event.name": "SEARCH HOTELS SUCCESS",
_id: {
$lt: ObjectId('5856428ce4b0f530cc74c090')
}
}

检索此类大数据的最佳方法是什么?

编辑1:

我们对我的 Collection 有一个索引

{"client_id.event.name" : 1 ,"_id" :1 ,"client_id.event.currentDate" :1} 

编辑2:

数据库中的示例文档:

{
"_id" : ObjectId("57a316a60cf26576defb7837"),
"client_id" : {
"clientIp" : "50.23.117.45",
"event" : {
"installationId" : "us2zv39vti5v",
"action" : "END",
"client_us_lastCommunicatedAt" : "2016-08-01T10:23:38.502Z",
"duration" : 60,
"client_us_userUpdatedOn" : null,
"name" : "APPSESSION",
"appId" : 3,
"userName" : "us2zv39vti5v",
"currentDate" : "2016-08-01T10:24:38.502Z",
"superProperties" : {
"client_us_installAt" : "2016-08-01T10:23:38.502Z",
"client_us_cookieEnabled" : true,
"client_us_referrer" : "Self",
"client_us_screen_width" : 768,
"client_us_counter" : 1,
"client_us_screen_height" : 1360,
"client_us_brand" : "Google",
"client_us_browser_version" : "23.32.12.20",
"client_us_screen_dpi" : 96,
"client_us_os" : "Windows",
"client_us_screen_colourDepth" : 24,
"client_us_os_version" : "10",
"client_us_flashVersion" : "no check",
"client_us_lastCommunicatedAt" : "2016-08-01T10:23:38.502Z",
"browser" : "Chrome",
"client_us_screen_pixelDepth" : 0,
"client_us_referring_domain" : "Self",
"client_us_css_pixel" : 1,
"client_us_mobile" : false
},
"userProperties" : {
"duration" : 60,
"Country" : "IN"
},
"installProperties" : {
"email" : "us2zv39vti5v@gmail.com"
}
}
}
}

最佳答案

您有 300 万条数据,每条数据至少有 4 个 Date 字段。现在,当 spring-mongo-data 向 mongo 请求所有这些内容时,它必须将日期的 String 值(这是一种 json 字符串日期格式 = Java String )转换为 1200 万个日期的 java Date 对象。所以还需要一段时间。

关于java - Mongodb查询挂系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41671358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com