开发者

Using mongodb for store intraday equity data

I want to store day bay day trading stock data. These data are composite ( ie Price-Volume ) and needs to be mantained in order. How to organize开发者_Go百科 the mongodb data in order to update the data very frequently and reading indexing by equity name,date ? Thanks in advance


You could use a schema something like this:

stocks

{
    _id: "MSFT",
    price: 24.69,
    volume: 53931025,
    date: 20110519
}

Then add indexes over the fields you'll be sorting and filtering by, e.g.

db.stocks.ensureIndex( { date: 1 } )

The _id key field is indexed by default, so updates like this will be very fast:

db.stocks.update( { _id: "MSFT" }, { $set : { price: 25.04 } } )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜