views:

30

answers:

1

Supposed we have something using Mongoid:

data: 
  'products':
    "2010-09-07":
      { pageviews: 123
        timeOnPage: 1823 }
    "2010-09-08":
      { pageviews: 138
        timeOnPage: 2607 } 
      ...

So 2, 3 years down the road, there will be 700 or 1000 dates mapping to a hash. If we modify 1 number, will it require reading the whole big object into memory, make the change, and write back the big object back to disk? Or does Mongoid know how to go to that particular location to change that 1 number?

I suppose if it is for reading one number, it shouldn't need to read the whole structure in RAM?

A: 

Yes to both.

For reading only select fields, see #3 on this list: http://www.mongodb.org/display/DOCS/Optimization#Optimization-Optimization%233%3ASelectonlyrelevantfields

For the typical analytic use case of incrementing a counter, see: http://www.mongodb.org/display/DOCS/Optimization#Optimization-IncrementOperations

Jim Garvin