Database Reference
In-Depth Information
Figure 4-4. Performance with hierarchical documents
Separate documents by granularity level
Pre-allocation of documents helps our update speed significantly, but we still have a problem
when querying data for long, multiday periods like months or quarters. In such cases, storing
daily aggregates in a higher-level document can speed up these queries.
Thisintroducesasecondsetofupsertoperationstothedatacollection andaggregationportion
of your application, but the gains in reduction of disk seeks on the queries should be worth the
costs. Consider the example schema presented in Example 4-1 and Example 4-2 .
Example 4-1. Daily statistics
{
_id : "20101010/site-1/apache_pb.gif" ,
metadata : {
date : ISODate ( "2000-10-10T00:00:00Z" ),
site : "site-1" ,
page : "/apache_pb.gif" },
hourly : {
"0" : 227850 ,
"1" : 210231 ,
...
Search WWH ::




Custom Search