1. What’s New in MongoDB 1.8 — Webinar
Richard M Kreuter
10gen Inc.
richard@10gen.com
March 17, 2011
What’s New in MongoDB 1.8 — Webinar
2. What is new
Write-ahead Journaling
Covered and sparse indexes
New map/reduce interface
Spherical geospatial search
Many new features for replica sets
What’s New in MongoDB 1.8 — Webinar
3. Write-ahead Journaling
MongoDB now supports a journaling mode, enabled with
--journal, that commits to an append-only write-ahead log
before making changes to database files.
On a clean system shutdown, database files are closed and journal
files are removed. In case of an unclean shutdown, journal sections
are automatically replayed to bring database files into a coherent
state.
What’s New in MongoDB 1.8 — Webinar
4. Journaling, continued
In MongoDB 1.8.0, journaling is not enabled by default; this
default may change in future. At the moment, journaling slows
down writes more than we expect it will in the long term, and so for
now you should consider enable journaling on a case-by-case basis.
The principle purpose of the journaling feature is to speed up
recovery after a node crashes; you can think of it as a better
solution than our existing “dbrepair” command.
What’s New in MongoDB 1.8 — Webinar
5. Journaling, continued continued
At present, the journal is committed to the file system every
100ms, or every 100MB, whichever is smaller. (Adaptive
automagic tuning of this parameter is something we’re thinking
about.) So on an unclean shutdown and restart, journal replay will
bring the database up to the most recent completed journal
section, i.e., the last 100ms or so of writes can be lost.
Client applications can use getLastError with the fsync option
to wait for their last write to have been written to the journal. (An
interface for triggering, rather than waiting for, a journal write is
forthcoming in the next weeks.)
What’s New in MongoDB 1.8 — Webinar
6. Sparse Indexes
Sparse indexes are a new flavor of index that may be useful when
you want to index on a field that is present in only a smallish
subset of a collection. A sparse index is created by specifying
{ sparse : true } to the index constructor, and it only
create entries for documents that contain the field.
What’s New in MongoDB 1.8 — Webinar
7. Covered Indexes
A covered index is an index from which a query’s results can be
produced without needing to access full document records. So, for
example, if you have an index on attributes foo and bar and you
execute find({ bar : { $gt : 10 } },
{ foo : 1 , id : 0 }), the results can be computed just by
examining the index.
Note that the id attribute is not present in indexes by default, and
so in order to take advantage of covered indexes, you’ll need to
exclude it from a query’s projection argument or include it in the
index explicitly.
What’s New in MongoDB 1.8 — Webinar
8. New map/reduce interface
The mapreduce command no longer creates “temporary
collections”, and now requires an out argument specifying where
the map/reduce job’s output goes. The out parameter must be
one of:
a collection name (a string), which will replace an collection
{ merge : collectionName } , which will merge the
Map/Reduce job’s output into an existing collection by
replacing any existing keys’ values in the collection with the
M/R output for those keys, and adding key/value pairs for
any new keys in the M/R output.
{ reduce : collectionName } , which uses the collection’s
key/value pairs as the initial state for a new reduce job.
{ inline : 1 } , which returns the Map/Reduce output
as a single document.
What’s New in MongoDB 1.8 — Webinar
9. Spherical geoSpatial search
MongoDB 1.8 includes support for “spherical” geoSpatial searches
in addition to our existing Cartesian search. Two new geoSpatial
query operators, $nearSphere and $centerSphere can be used
to produce result sets that take the curvature of the earth into
account when computing distances.
db.places.find({a : {$nearSphere : [50, 50]}})
db.places.find({ a: {$within: {$centerSphere:
[[50, 50], 10]}}}})
db.runCommand( { geoNear : "places" , near :
[50,50], num : 10, spherical : true } )
What’s New in MongoDB 1.8 — Webinar
10. Many new features for replica sets
Replica Sets have got some new features:
hidden – don’t advertize this member to client
initialSync – specify another node to perform an initial
sync
getLastErrorDefaults – specify default parameters (e.g., w
and wtimeout) for getLastError calls with no arguments.
Additionally, in sharded deployments, the mongos query router now
knows how to route queries to Replica Set secondaries when
slaveOk is enabled.
What’s New in MongoDB 1.8 — Webinar
11. New features in tools
mongostat now supports a --discover mode that
automatically discovers all nodes in a cluster and queries each
for statistics.
mongodump now supports a “point in time” feature that
dumps out the replication oplog after dumping all collections
(enable with --oplog).
mongorestore supports replaying an oplog dump as
generated by the new mongodump option (enable with
--oplogReplay).
What’s New in MongoDB 1.8 — Webinar
12. Odds and Ends
Maximum BSON document size has been increased to 16MB.
A new update modifier for changing attribute names,
$rename, has been added.
Naturally, many bug fixes and other improvements have been
committed.
What’s New in MongoDB 1.8 — Webinar
13. So try MongoDB 1.8 today!
http://www.mongodb.org/downloads
http://www.mongodb.org/display/DOCS/1.8+Release+Notes
10gen, Inc. offers support, training, and advising services for
mongodb.
What’s New in MongoDB 1.8 — Webinar