## 11.2.2 If you remove a document, does MongoDB remove it from disk? 

Yes. 

When you use remove() , the object will no longer exist in MongoDB’s on-disk data storage. 

## 11.2.3 When does MongoDB write updates to disk? 

MongoDB flushes writes to disk on a regular interval. In the default configuration, MongoDB writes data to the main data files on disk every 60 seconds and commits the journal roughly every 100 milliseconds. These values are configurable with the commitIntervalMs and syncPeriodSecs . 

These values represent the maximum amount of time between the completion of a write operation and the point when the write is durable in the journal, if enabled, and when MongoDB flushes data to the disk. In many cases MongoDB and the operating system flush data to disk more frequently, so that the above values represents a theoretical maximum. 

However, by default, MongoDB uses a “lazy” strategy to write to disk. This is advantageous in situations where the database receives a thousand increments to an object within one second, MongoDB only needs to flush this data to disk once. In addition to the aforementioned configuration options, you can also use fsync and Write Concern Reference (page 130) to modify this strategy. 

## 11.2.4 How do I do transactions and locking in MongoDB? 

MongoDB does not have support for traditional locking or complex transactions with rollback. MongoDB aims to be lightweight, fast, and predictable in its performance. This is similar to the MySQL MyISAM autocommit model. By keeping transaction support extremely simple, MongoDB can provide greater performance especially for partitioned or replicated systems with a number of database server processes. 

MongoDB does have support for atomic operations within a single document. Given the possibilities provided by nested documents, this feature provides support for a large number of use-cases. 

See also: 

The Atomicity and Transactions (page 80) page. 

## 11.2.5 How do you aggregate data with MongoDB? 

In version 2.1 and later, you can use the new aggregation framework (page 439), with the aggregate command. 

MongoDB also supports map-reduce with the mapReduce command, as well as basic aggregation with the group , count , and distinct . commands. 

See also: 

The Aggregation (page 435) page. 

## 11.2.6 Why does MongoDB log so many “Connection Accepted” events? 

If you see a very large number connection and re-connection messages in your MongoDB log, then clients are fre- quently connecting and disconnecting to the MongoDB server. This is normal behavior for applications that do not use request pooling, such as CGI. Consider using FastCGI, an Apache Module, or some other kind of persistent application server to decrease the connection overhead. 

If these connections do not impact your performance you can use the run-time quiet option or the command-line option --quiet to suppress these messages from the log. 

