|
What is MongoDB?
What are the more important MongoDB features?
Indexes
.
- Improves performance for frequent queries
- Indexes are based on a field or set of fields
- Queries containing only indexed fields are optimal
- Can affect other operations such as sort()
- Main Types: single field and compound
- Other types: multikey, geospatial, text, hashed
- Properties: unique, sparse
Distributed queries
.
- Sharded clusters allow you to partition a data set
- Reads are most efficient when directed to a specific shard
- Scatter gather queries (no shard key) can be inefficient
Read preferences
.
- Allows you to control queries (reads)
- Concerns replica sets
- Modes: primary, primaryPreferred, secondary,
secondaryPreferred, nearest
Distributed write operations
.
- Directs write operations from apps to shard clusters
- Partitions data into ranges based on value of the shard key
- Write operations go to the primary
- Secondaries continuously replicating the primary oplog
and apply the operations to themselves - Write concerns can apply
Write concerns
.
- Guaranteed delivery
- Stronger settings: slower, better guarantee
- Levels: Errors Ignored, Unacknowledged, Acknowledged,
Journaled, Replica Acknowledged
Query plans and optimizers
.
- Optimizer processes queries
- Chooses the most efficient query plan
- Over time deletes and re-evaluates the plan
|
|