Overview
- 1MongoDB 8.0 (Oct 2024) is the latest major release — supported until February 2027.
- 2Performance: 3x speedup on mixed read/write workloads from internal storage optimisations.
- 3$rankFusion combines vector search scores and full-text search scores into a single ranked result.
- 4Atlas Vector Search adds multi-vector indexing for storing multiple embeddings per document.
- 5Queryable Encryption allows queries over encrypted fields without decrypting on the server.
Key Features in 8.0
Use Cases
- →Product catalogs and content management with varying schemas
- →User profiles, session data, and event logs
- →Hybrid search applications combining semantic and keyword search
- →Real-time analytics and operational data stores
What's New in MongoDB 8.0
- 3x faster mixed workload performance: new WiredTiger storage engine optimisations
- $rankFusion: `{ $rankFusion: { input: { pipelines: { vs: [...], fts: [...] } } } }`
- Multi-vector indexes: store multiple embedding vectors per document in a single HNSW index
- Queryable Encryption: range queries on encrypted fields (date, int, double, decimal)
- sortArray: `{ $sortArray: { input: "$scores", sortBy: { score: -1 } } }`
- Extended JSON v2 improvements for cross-driver serialisation consistency
CRUD & Aggregation
- insertOne/insertMany, findOne/find, updateOne/updateMany, deleteOne/deleteMany
- Aggregation pipeline: $match, $group, $project, $sort, $limit, $skip, $unwind, $lookup
- $lookup: left outer join between collections; with pipeline for complex joins
- Transactions: multi-document ACID transactions across collections (since 4.0)
- Bulk writes: bulkWrite() for mixed insert/update/delete in a single round-trip
- Change streams: real-time notification of insert/update/delete events via oplog tailing
Schema Design Patterns
- Embedded documents: embed related data in one document for atomic reads (one-to-few)
- References: store _id references between documents for large or frequently-updated sub-docs
- Subset pattern: store hot fields in a summary document; full data in separate collection
- Outlier pattern: handle edge-case documents with unusually large arrays
- Versioning pattern: store history as array of snapshots with a currentVersion field
- Bucket pattern: group time-series measurements into buckets of N records per document
Atlas & Ecosystem
- MongoDB Atlas: fully managed DBaaS with M0 free tier (512MB), auto-scaling clusters
- Atlas Vector Search: HNSW index on vector fields; cosine/euclidean similarity; $vectorSearch stage
- Atlas Search: Lucene-based full-text search with autocomplete, facets, and custom scoring
- Atlas Data Federation: query S3, Atlas, and HTTP sources as a unified MongoDB interface
- Mongoose 8.x: schema-based ODM for Node.js with virtuals, middleware, and plugins
- Prisma + MongoDB driver: type-safe access with generated client from schema
Frequently Asked Questions
When should I use MongoDB over PostgreSQL?
Choose MongoDB when: your data schema varies significantly between documents (product catalogs, CMS), you need horizontal sharding built-in for massive scale, your access pattern is predominantly document-level reads, or you are building a prototype needing flexible schema iteration. Choose PostgreSQL when you need complex joins, strong ACID transactions, or rich SQL query capabilities.
What is Atlas Vector Search and how does it work?
Atlas Vector Search stores vector embeddings as fields in MongoDB documents and creates an HNSW (Hierarchical Navigable Small World) index for approximate nearest-neighbor search. Use the `$vectorSearch` aggregation stage to find documents whose embeddings are most similar to a query vector. Combine it with $rankFusion in MongoDB 8.0 for hybrid keyword + semantic search.
Does MongoDB support ACID transactions?
Yes. MongoDB supports multi-document ACID transactions since version 4.0 (2018). Transactions work across collections, databases, and shards. For most document-model use cases, proper schema design (embedding related data) avoids needing transactions. Use them when you must atomically update multiple collections.