SlideShare a Scribd company logo
MONGODB vs POSTGRESQL BENCHMARKS
MONGODB vs POSTGRESQL
BENCHMARKS
Álvaro Hernández
MONGODB vs POSTGRESQL BENCHMARKS
`whoami`
Álvaro Hernández <aht@ongres.com>
@ahachete
● Founder & CEO, OnGres
● 20+ years PostgreSQL user and DBA
● Mostly doing R&D to create new, innovative
software on Postgres
● Frequent speaker at PostgreSQL, database
conferences
● Principal Architect of ToroDB
● Founder and President of the NPO
Fundación PostgreSQL
MONGODB vs POSTGRESQL BENCHMARKS
Introduction
MONGODB vs POSTGRESQL BENCHMARKS
OnGres Ethics Policy
This work was sponsored by EnterpriseDB, and performed by OnGres.
It was conducted according to OnGres Ethics Policy, that observes that:
● All the work is conducted with the maximum degree of professionalism
and independence.
● No technology is favored over another.
● No results are edited or omitted.
● The sponsor of the work does not intervene in the strategy,
implementation or execution of the work.
● Results are verifiable by external, third parties.
MONGODB vs POSTGRESQL BENCHMARKS
Benchmarking is hard
● Bench-marketing is easy --but not trustable.
● Benchmarking is hard.
● Benchmarking databases is harder.
● Benchmarking databases that follow different design models, is
even harder.
● Are MongoDB and PostgreSQL comparable?
● The market demands this: informed decision, performance is key.
MONGODB vs POSTGRESQL BENCHMARKS
Pursuing benchmarking fairness
How to present a fair arena in which the technologies compete in an
apples-to-apples scenario?
● Transparency and reproducibility. Infrastructure-as-Code.
https://gitlab.com/ongresinc/benchplatform/
https://gitlab.com/ongresinc/txbenchmark/
http://benchplatform.ongres.com.s3.amazonaws.com/
● Multiple benchmarks
● Close-to-real workloads
● Production-grade setups
MONGODB vs POSTGRESQL BENCHMARKS
Types of benchmarks
Three main benchmark categories:
● Transactions benchmark
● OLTP
○ In-memory dataset (4GB)
○ Larger, on-disk dataset (2TB)
● OLAP
MONGODB vs POSTGRESQL BENCHMARKS
The contenders
MongoDB 4.0
● Community version used
● Journaling active
● Replication active
(single node)
● No further tuning required
PostgreSQL 11
● Self-managed instance
● Basic production tuning
● Tested w/ and w/o
PgBouncer
MONGODB vs POSTGRESQL BENCHMARKS
Architecture: client-server, running on AWS
Data volume: io1, with number of reserved IOPS depending on the test.
MONGODB vs POSTGRESQL BENCHMARKS
Benchmarks:
Transactions
MONGODB vs POSTGRESQL BENCHMARKS
Previous discussion: isolation levels
MONGODB vs POSTGRESQL BENCHMARKS
Benchmark description
● Custom-developed benchmark.
● Inspired by MongoDB post about MongoDB transactions.
● Simulates air reservation system: check flight schedule, plane
availability, purchase, audit log.
● Tx with query, insertions and upsert.
● Programmed in Java. Official JDBC and MongoDB drivers.
● Open source: https://gitlab.com/ongresinc/benchplatform
MONGODB vs POSTGRESQL BENCHMARKS
Transaction performance
MONGODB vs POSTGRESQL BENCHMARKS
Transaction performance
MONGODB vs POSTGRESQL BENCHMARKS
Transaction retries
MONGODB vs POSTGRESQL BENCHMARKS
PostgreSQL latency (@ SERIALIZABLE)
MONGODB vs POSTGRESQL BENCHMARKS
MongoDB latency
MONGODB vs POSTGRESQL BENCHMARKS
Benchmarks:
OLTP
MONGODB vs POSTGRESQL BENCHMARKS
Benchmark description
● Industry standard Sysbench was used.
● Supports PostgreSQL and MongoDB (via sysbench-mongodb-lua).
● Resembles real-world OLTP workload.
● Different dimensions benchmarked:
○ Dataset size: fit in memory (4GB), on-disk (2TB)
○ Read/write work split: 50/50, 95/5.
○ Filesystems: XFS or ZFS.
○ Different levels of concurrency.
MONGODB vs POSTGRESQL BENCHMARKS
Discussion about PostgreSQL Connection Pooling
● PostgreSQL best practice is to run always behind a connection pool.
● PostgreSQL proved to be highly sensitive to the number of connections,
with degraded performance when overwhelmed.
● A connection pool offers close-to-ideal performance for almost any
workload.
● MongoDB does not require connection pooling:
is included in drivers.
MONGODB vs POSTGRESQL BENCHMARKS
Performance: dataset in memory
MONGODB vs POSTGRESQL BENCHMARKS
PG connection pooling effect (dataset in memory)
MONGODB vs POSTGRESQL BENCHMARKS
Performance: dataset on disk
MONGODB vs POSTGRESQL BENCHMARKS
Benchmarks:
OLAP
MONGODB vs POSTGRESQL BENCHMARKS
Benchmark description
● JSON dataset (GitHub Archive). Native to MongoDB, jsonb in PG.
● 2015 dataset: 212M records (340GB on PG, 206GB on MongoDB).
● Timing of OLAP-style queries that resemble BI natural questions:
○ Repositories ordered by most opened issues.
○ Most frequent git event types, ordered.
○ Top 10 most active actors.
○ Repositories that have more than two comments and a specific
event type, ordered.
MONGODB vs POSTGRESQL BENCHMARKS
Query A in PostgreSQL and MongoDB
MONGODB vs POSTGRESQL BENCHMARKS
Results
MONGODB vs POSTGRESQL BENCHMARKS
QUESTIONS?
Álvaro Hernández
<aht@ongres.com>
@ahachete / www.ongres.com
Thank you

More Related Content

PDF
Apache Iceberg: An Architectural Look Under the Covers
PPTX
Apache Spark Architecture
PDF
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
PDF
Ceph - A distributed storage system
PDF
Efficient Data Storage for Analytics with Apache Parquet 2.0
PDF
mysql 8.0 architecture and enhancement
PPTX
NoSQL databases - An introduction
PDF
ClickHouse Deep Dive, by Aleksei Milovidov
Apache Iceberg: An Architectural Look Under the Covers
Apache Spark Architecture
ClickHouse Data Warehouse 101: The First Billion Rows, by Alexander Zaitsev a...
Ceph - A distributed storage system
Efficient Data Storage for Analytics with Apache Parquet 2.0
mysql 8.0 architecture and enhancement
NoSQL databases - An introduction
ClickHouse Deep Dive, by Aleksei Milovidov

What's hot (20)

PPTX
High Performance, High Reliability Data Loading on ClickHouse
PPT
Introduction to mongodb
PDF
The Parquet Format and Performance Optimization Opportunities
PDF
Building a Data Pipeline using Apache Airflow (on AWS / GCP)
PPTX
NOSQL vs SQL
PDF
Iceberg: a fast table format for S3
PDF
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
PDF
Spark SQL
PPTX
PPTX
The Basics of MongoDB
PDF
PDF
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
PPTX
Getting started with postgresql
PDF
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
PDF
Redis persistence in practice
PPTX
로그 기깔나게 잘 디자인하는 법
PPTX
Introduction to NoSQL Databases
ZIP
NoSQL databases
PDF
The MySQL Query Optimizer Explained Through Optimizer Trace
PDF
An overview of BigQuery
High Performance, High Reliability Data Loading on ClickHouse
Introduction to mongodb
The Parquet Format and Performance Optimization Opportunities
Building a Data Pipeline using Apache Airflow (on AWS / GCP)
NOSQL vs SQL
Iceberg: a fast table format for S3
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
Spark SQL
The Basics of MongoDB
HTTP Analytics for 6M requests per second using ClickHouse, by Alexander Boc...
Getting started with postgresql
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
Redis persistence in practice
로그 기깔나게 잘 디자인하는 법
Introduction to NoSQL Databases
NoSQL databases
The MySQL Query Optimizer Explained Through Optimizer Trace
An overview of BigQuery
Ad

Similar to MongoDB vs. Postgres Benchmarks (20)

PDF
Analysis postgre sql-vs_mongodb_report
PPTX
PDF
SFScon14: Schrödinger’s elephant: why PostgreSQL can solve all your database ...
PDF
PostgreSQL versus MySQL - What Are The Real Differences
PDF
High performance json- postgre sql vs. mongodb
PDF
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
ODP
Introduction to PostgreSQL
PDF
Postgres NoSQL - Delivering Apps Faster
 
PPT
performance analysis between sql ans nosql
PDF
NoSQL on ACID - Meet Unstructured Postgres
 
PDF
An evening with Postgresql
PDF
Migrating to postgresql
PPTX
Relational RDBMS : MySQL, PostgreSQL and SQL SERVER
PDF
Beyond Postgres: Interesting Projects, Tools and forks
PPTX
PostgreSQL - Object Relational Database
PDF
Postgres database Ibrahem Batta
PPT
Object Relational Database Management System
PDF
Omnibus database machine
ODP
MongoDB + Pylons FTW: Scalable Web apps with Python & NoSQL
PDF
PostgreSQL - Case Study
Analysis postgre sql-vs_mongodb_report
SFScon14: Schrödinger’s elephant: why PostgreSQL can solve all your database ...
PostgreSQL versus MySQL - What Are The Real Differences
High performance json- postgre sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
Introduction to PostgreSQL
Postgres NoSQL - Delivering Apps Faster
 
performance analysis between sql ans nosql
NoSQL on ACID - Meet Unstructured Postgres
 
An evening with Postgresql
Migrating to postgresql
Relational RDBMS : MySQL, PostgreSQL and SQL SERVER
Beyond Postgres: Interesting Projects, Tools and forks
PostgreSQL - Object Relational Database
Postgres database Ibrahem Batta
Object Relational Database Management System
Omnibus database machine
MongoDB + Pylons FTW: Scalable Web apps with Python & NoSQL
PostgreSQL - Case Study
Ad

More from EDB (20)

PDF
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
PDF
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
PDF
Migre sus bases de datos Oracle a la nube
 
PDF
EFM Office Hours - APJ - July 29, 2021
 
PDF
Benchmarking Cloud Native PostgreSQL
 
PDF
Las Variaciones de la Replicación de PostgreSQL
 
PDF
NoSQL and Spatial Database Capabilities using PostgreSQL
 
PDF
Is There Anything PgBouncer Can’t Do?
 
PDF
Data Analysis with TensorFlow in PostgreSQL
 
PDF
Practical Partitioning in Production with Postgres
 
PDF
A Deeper Dive into EXPLAIN
 
PDF
IOT with PostgreSQL
 
PDF
A Journey from Oracle to PostgreSQL
 
PDF
Psql is awesome!
 
PDF
EDB 13 - New Enhancements for Security and Usability - APJ
 
PPTX
Comment sauvegarder correctement vos données
 
PDF
Cloud Native PostgreSQL - Italiano
 
PDF
New enhancements for security and usability in EDB 13
 
PPTX
Best Practices in Security with PostgreSQL
 
PDF
Cloud Native PostgreSQL - APJ
 
Cloud Migration Paths: Kubernetes, IaaS, or DBaaS
 
Die 10 besten PostgreSQL-Replikationsstrategien für Ihr Unternehmen
 
Migre sus bases de datos Oracle a la nube
 
EFM Office Hours - APJ - July 29, 2021
 
Benchmarking Cloud Native PostgreSQL
 
Las Variaciones de la Replicación de PostgreSQL
 
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Is There Anything PgBouncer Can’t Do?
 
Data Analysis with TensorFlow in PostgreSQL
 
Practical Partitioning in Production with Postgres
 
A Deeper Dive into EXPLAIN
 
IOT with PostgreSQL
 
A Journey from Oracle to PostgreSQL
 
Psql is awesome!
 
EDB 13 - New Enhancements for Security and Usability - APJ
 
Comment sauvegarder correctement vos données
 
Cloud Native PostgreSQL - Italiano
 
New enhancements for security and usability in EDB 13
 
Best Practices in Security with PostgreSQL
 
Cloud Native PostgreSQL - APJ
 

Recently uploaded (20)

PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Modernizing your data center with Dell and AMD
PDF
KodekX | Application Modernization Development
PDF
Omni-Path Integration Expertise Offered by Nor-Tech
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Event Presentation Google Cloud Next Extended 2025
PDF
Advanced IT Governance
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Review of recent advances in non-invasive hemoglobin estimation
madgavkar20181017ppt McKinsey Presentation.pdf
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
GamePlan Trading System Review: Professional Trader's Honest Take
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Modernizing your data center with Dell and AMD
KodekX | Application Modernization Development
Omni-Path Integration Expertise Offered by Nor-Tech
“AI and Expert System Decision Support & Business Intelligence Systems”
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Understanding_Digital_Forensics_Presentation.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Event Presentation Google Cloud Next Extended 2025
Advanced IT Governance
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf

MongoDB vs. Postgres Benchmarks

  • 1. MONGODB vs POSTGRESQL BENCHMARKS MONGODB vs POSTGRESQL BENCHMARKS Álvaro Hernández
  • 2. MONGODB vs POSTGRESQL BENCHMARKS `whoami` Álvaro Hernández <[email protected]> @ahachete ● Founder & CEO, OnGres ● 20+ years PostgreSQL user and DBA ● Mostly doing R&D to create new, innovative software on Postgres ● Frequent speaker at PostgreSQL, database conferences ● Principal Architect of ToroDB ● Founder and President of the NPO Fundación PostgreSQL
  • 3. MONGODB vs POSTGRESQL BENCHMARKS Introduction
  • 4. MONGODB vs POSTGRESQL BENCHMARKS OnGres Ethics Policy This work was sponsored by EnterpriseDB, and performed by OnGres. It was conducted according to OnGres Ethics Policy, that observes that: ● All the work is conducted with the maximum degree of professionalism and independence. ● No technology is favored over another. ● No results are edited or omitted. ● The sponsor of the work does not intervene in the strategy, implementation or execution of the work. ● Results are verifiable by external, third parties.
  • 5. MONGODB vs POSTGRESQL BENCHMARKS Benchmarking is hard ● Bench-marketing is easy --but not trustable. ● Benchmarking is hard. ● Benchmarking databases is harder. ● Benchmarking databases that follow different design models, is even harder. ● Are MongoDB and PostgreSQL comparable? ● The market demands this: informed decision, performance is key.
  • 6. MONGODB vs POSTGRESQL BENCHMARKS Pursuing benchmarking fairness How to present a fair arena in which the technologies compete in an apples-to-apples scenario? ● Transparency and reproducibility. Infrastructure-as-Code. https://gitlab.com/ongresinc/benchplatform/ https://gitlab.com/ongresinc/txbenchmark/ http://benchplatform.ongres.com.s3.amazonaws.com/ ● Multiple benchmarks ● Close-to-real workloads ● Production-grade setups
  • 7. MONGODB vs POSTGRESQL BENCHMARKS Types of benchmarks Three main benchmark categories: ● Transactions benchmark ● OLTP ○ In-memory dataset (4GB) ○ Larger, on-disk dataset (2TB) ● OLAP
  • 8. MONGODB vs POSTGRESQL BENCHMARKS The contenders MongoDB 4.0 ● Community version used ● Journaling active ● Replication active (single node) ● No further tuning required PostgreSQL 11 ● Self-managed instance ● Basic production tuning ● Tested w/ and w/o PgBouncer
  • 9. MONGODB vs POSTGRESQL BENCHMARKS Architecture: client-server, running on AWS Data volume: io1, with number of reserved IOPS depending on the test.
  • 10. MONGODB vs POSTGRESQL BENCHMARKS Benchmarks: Transactions
  • 11. MONGODB vs POSTGRESQL BENCHMARKS Previous discussion: isolation levels
  • 12. MONGODB vs POSTGRESQL BENCHMARKS Benchmark description ● Custom-developed benchmark. ● Inspired by MongoDB post about MongoDB transactions. ● Simulates air reservation system: check flight schedule, plane availability, purchase, audit log. ● Tx with query, insertions and upsert. ● Programmed in Java. Official JDBC and MongoDB drivers. ● Open source: https://gitlab.com/ongresinc/benchplatform
  • 13. MONGODB vs POSTGRESQL BENCHMARKS Transaction performance
  • 14. MONGODB vs POSTGRESQL BENCHMARKS Transaction performance
  • 15. MONGODB vs POSTGRESQL BENCHMARKS Transaction retries
  • 16. MONGODB vs POSTGRESQL BENCHMARKS PostgreSQL latency (@ SERIALIZABLE)
  • 17. MONGODB vs POSTGRESQL BENCHMARKS MongoDB latency
  • 18. MONGODB vs POSTGRESQL BENCHMARKS Benchmarks: OLTP
  • 19. MONGODB vs POSTGRESQL BENCHMARKS Benchmark description ● Industry standard Sysbench was used. ● Supports PostgreSQL and MongoDB (via sysbench-mongodb-lua). ● Resembles real-world OLTP workload. ● Different dimensions benchmarked: ○ Dataset size: fit in memory (4GB), on-disk (2TB) ○ Read/write work split: 50/50, 95/5. ○ Filesystems: XFS or ZFS. ○ Different levels of concurrency.
  • 20. MONGODB vs POSTGRESQL BENCHMARKS Discussion about PostgreSQL Connection Pooling ● PostgreSQL best practice is to run always behind a connection pool. ● PostgreSQL proved to be highly sensitive to the number of connections, with degraded performance when overwhelmed. ● A connection pool offers close-to-ideal performance for almost any workload. ● MongoDB does not require connection pooling: is included in drivers.
  • 21. MONGODB vs POSTGRESQL BENCHMARKS Performance: dataset in memory
  • 22. MONGODB vs POSTGRESQL BENCHMARKS PG connection pooling effect (dataset in memory)
  • 23. MONGODB vs POSTGRESQL BENCHMARKS Performance: dataset on disk
  • 24. MONGODB vs POSTGRESQL BENCHMARKS Benchmarks: OLAP
  • 25. MONGODB vs POSTGRESQL BENCHMARKS Benchmark description ● JSON dataset (GitHub Archive). Native to MongoDB, jsonb in PG. ● 2015 dataset: 212M records (340GB on PG, 206GB on MongoDB). ● Timing of OLAP-style queries that resemble BI natural questions: ○ Repositories ordered by most opened issues. ○ Most frequent git event types, ordered. ○ Top 10 most active actors. ○ Repositories that have more than two comments and a specific event type, ordered.
  • 26. MONGODB vs POSTGRESQL BENCHMARKS Query A in PostgreSQL and MongoDB
  • 27. MONGODB vs POSTGRESQL BENCHMARKS Results
  • 28. MONGODB vs POSTGRESQL BENCHMARKS QUESTIONS? Álvaro Hernández <[email protected]> @ahachete / www.ongres.com Thank you