Java Mongodb查询挂起系统
我使用的是MongoDB 2.6版 我有大约300万个数据在里面当我触发下面的查询时,它挂起了我的整个Java应用程序。 (我正在使用Java Mongodb查询挂起系统,java,mongodb,mongodb-query,aggregation-framework,spring-data-mongodb,Java,Mongodb,Mongodb Query,Aggregation Framework,Spring Data Mongodb,我使用的是MongoDB 2.6版 我有大约300万个数据在里面当我触发下面的查询时,它挂起了我的整个Java应用程序。 (我正在使用Mongodb连接器从那里检索数据。) 检索此类大型数据的最佳方式是什么 编辑1: 我们有我收藏的索引 {"client_id.event.name" : 1 ,"_id" :1 ,"client_id.event.currentDate" :1} 编辑2: 数据库中的示例文档: { "_id" : ObjectId("57a316a60cf2
Mongodb连接器
从那里检索数据。)
检索此类大型数据的最佳方式是什么
编辑1:
我们有我收藏的索引
{"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个日期字段。
现在,当spring mongo data从mongo请求所有这些数据时,它必须将date的字符串值(类似于json String date format=Java String)转换为Java date对象,用于1200万个日期。所以这需要一段时间。您有300万个数据,每个数据至少有4个日期字段。
现在,当spring mongo data从mongo请求所有这些数据时,它必须将date的字符串值(类似于json String date format=Java String)转换为Java date对象,用于1200万个日期。因此需要一段时间。不应该是引号中的嵌入字段名,如
中的“client\u id.event.currentDate”
编辑,请再次查看。我错过了这里的双引号,但在真正的问题是它在那里。你需要调查什么挂起。通常,是在MongoDB实例上运行的查询执行,而不是从MongoDB加载数据。使用流式处理可以最好地处理大型数据集。您是否可以更新您的问题,以包含该集合中的两个文档,以便我们可以查看文档架构?这将特别回答关于“client\u id.event.currentDate”字段的数据类型是什么的问题……请您再看一次这个问题。问题中更新的数据库索引不应是引号中的嵌入字段名,如中的“client\u id.event.currentDate”
?已编辑,请重新查看。我错过了这里的双引号,但在真正的问题是它在那里。你需要调查什么挂起。通常,是在MongoDB实例上运行的查询执行,而不是从MongoDB加载数据。使用流式处理可以最好地处理大型数据集。您是否可以更新您的问题,以包含该集合中的两个文档,以便我们可以查看文档架构?这将特别回答关于“client\u id.event.currentDate”字段的数据类型是什么的问题……请您再看一次这个问题。我已将问题中更新的数据库编入索引
{
"_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"
}
}
}
}