您好我是MongoDB中的聚合新手。我的要求是将设备的GPS数据发送到服务器到我的mongoDB集合,即GPS数据。目前我的架构使用猫鼬是如下通过猫鼬在MongoDB中的RAM消耗
SerialNo:{
type:Number,
required:true,
index:true
},
Loc: {
type: [Number], // [<longitude>, <latitude>]
index: '2d',// create the geospatial index
required:true
},
Time:{
type:Date
},
Speed:{
type:Number,
default:0.0
},
Message_length:{
type:Number
},
No_Satellites:{
type:Number
},
Course:{
type:Number
},
Direction:{
type:String
},
gpsLocked:{
type:Boolean
},
isRealTime:{
type:Boolean
},
createdAt:{
type:Date,
default:Date.now
}
我发现它可能不是我的设计是可行等搜索有关MongoDB的网站很多我碰到这个链接Analyzing Time Series Data Using the Aggregation Framework and Hadoop,我发现自己来到了GPS数据使用类似于我的要求的文档结构如下所示是
data:[
{speed:NAN,time:NAN},
{speed:NAN,time:NAN},
{speed:NAN,time:NAN}
]
我的主要问题是,如果我将禄和时间戳转换为上述格式,我会节省内存消耗,由于索引,当我存500 GPS数据整合到单个文档中还是会保持不变由于索引保存500导致的内存消耗不同将文件加入我的收藏中?
这取决于你正在索引什么。你可以澄清你正在索引哪些领域..只是标准'_id'或其他领域以及 – Sundar
我索引我的loc和serialNo在我的模式中提到!!!!! _id在MongoDB中被默认编入索引。 – shubhamagiwal92