您好我是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