cockroachDB-mongoDB-logo

A comparison of two very different approaches to scale

CockroachDB vs MongoDB

/* Distributed relational SQL or the document model? Which will get you further, faster, better? */

Why developers choose CockroachDB over MongoDB

Scale Icon

Consistent Transactions

CockroachDB guarantees consistent and high performant ACID transactions at global scale and is never eventual

Global transaction icon

Development Ease

CockroachDB ensures data integrity, provides joins, and eliminates complex, error-prone application code

Multi Region Icon

Business Workloads

CockroachDB delivers a relational database built for operational workloads and more complex data models

CockroachDB and MongoDB are both used for scale-out applications; however, you should use CockroachDB for operational and transactional workloads.

image
image
imageSchema
Document Model: JSON, partial SQL coverage through connectors
Relational Model and JSON, native SQL language
imageData model complexity

Optimized for non-relational data

Simple and complex, deep operational data models
imageData integrity
Optional schema validation lacks referential integrity
Relational model enforces referential integrity and strict data types
imageSchema changes
Agile with limited schema
Online, orchestrated schema changes
imageAvailability
Raft protocol ensures availability during node failure
Raft protocol ensures availability during node failure
imageResilience
With Atlas, failed nodes restart.
Up-replicates data if nodes do not restart
imageQuery routing
Router processes act as gateways to the entirety of the database for unlimited reads and writes in any region
Every node is a gateway to the entirety of the database for unlimited reads and writes in any region
imageTransactional consistency
Consistent transactions not guaranteed by default. Eventually consistent
Serializable, guaranteed consistent transactions
imageTransaction performance
Sub-optimal for transactional workloads
Optimized for transactional workloads
imageMulti-region writes
Not by default, but possible with complex, careful setup
Native, all nodes can accept reads and writes even across regions
imageData residency
Tie data to a node to optimize performance or comply with data regulations
Tie data to a node to optimize performance or comply with data regulations
imageDeveloper tools
Closed system with limited tooling, mostly created by vendor
Rich ecosystem of PostgreSQL developer tools
imageMulti-cloud
Deploy in any environment
Deploy in any environment and even run a single instance across envs
imageIdeal workloads
Simple hierarchical data models, access forward with minimal transactions (if any)
Optimized for relationship based, simple and complex transactional workloads

Relational (SQL) vs document model (NoSQL) databases

Relational databases are founded in relational algebra and deliver a highly efficient store that enforces data integrity in the database as opposed to in code.

Referential Integrity

With a relational database, maintaining parent/child, data types, and cardinality of relationships is enforced by the database. With NoSQL, the developer needs to add complex code to the application to ensure data integrity and relationships.

Complex Joins

A relational database implements complex joins and aggregate views as part of its execution layer and offers simple DDL for making requests. With NoSQL, joins are often the task of a developer who has to code these routines in their application logic.

Workloads

A relational database is optimal for workloads where data relationships are paramount such as transactional system of record workloads. NoSQL is typically used when you have an established access pattern that will not evolve, with simple data models and minimal transactions (if any).

Download the comparison

/* Save and share a PDF breakdown of how MongoDB stacks up against ultra-resilient, strongly consistent CockroachDB. */