DEV Community

Cover image for MongoDB vs MySQL: A Real-World Performance Showdown Using Disneyland Data
Christian Holländer
Christian Holländer

Posted on • Originally published at christian-hollaender.de

MongoDB vs MySQL: A Real-World Performance Showdown Using Disneyland Data

This post was originally posted over on my personal website. Maybe you want to check it out [HERE].


MongoDB vs MySQL head-to-head: We benchmarked both databases with real Disneyland data. MongoDB won writes by 67% and some queries by 98%, but MySQL had surprises too!


When choosing a database for your next project, performance benchmarks often feel abstract and disconnected from real-world scenarios. That's why our recent university project comparing MongoDB and MySQL using actual Disneyland visitor data provides such valuable insights – we tested both databases against the same complex dataset with realistic use cases.

The Dataset: Perfect for Database Testing

We used a comprehensive Disneyland Paris dataset that presented real analytical challenges:

  • Wait times for 37 attractions (2018-2019)
  • Daily attendance data (2018-2022)
  • Weather conditions (1999-2022)
  • Park operational schedules (2018-2022)

This dataset was ideal for performance testing because it required:

  • High-frequency writes (weather data every hour, wait times every 15 minutes)
  • Complex aggregations across multiple data sources
  • Time-series analysis
  • JOIN operations between related data

Database Setup: Fair Fight Conditions

To ensure a fair comparison, we:

  • Identical hardware: Same server (20GB RAM, 6 CPU cores, HDD storage)
  • Equivalent indexing: Created the same indexes on both systems
  • Standardized schema: Normalized data structure for MySQL, embedded documents for MongoDB
  • Same queries: Translated identical business logic between SQL and MongoDB aggregation pipelines

Schema Differences

MySQL: Traditional normalized approach with separate tables for weather descriptions, linked via foreign keys.

MongoDB: Document-based approach with embedded weather objects, eliminating the need for joins.

Performance Results: The Numbers Don't Lie

We ran each query 100 times sequentially to get reliable averages. Here are the results:

Write Operations (Data Insertion)

Operation MySQL MongoDB MongoDB Advantage
Weather Data Insert 56.7ms 19.6ms 65.4% faster
Wait Times Insert 59.2ms 19.3ms 67.4% faster
Attendance Insert 57.2ms 19.3ms 66.2% faster
Schedule Insert 57.7ms 28.4ms 50.7% faster

Takeaway: MongoDB consistently outperformed MySQL for write operations, often by more than 2:1 ratios.

Read Operations (Analytics Queries)

Query Type MySQL MongoDB Winner
RQ1: Average wait times by attraction 52.6 seconds 1.0 seconds MongoDB (98.1% faster)
RQ2: Attendance by weather conditions 413ms 20.7 seconds MySQL (98% faster)
RQ3: Wait times vs weather correlation 1h 12m 37s 5ms* MongoDB
RQ4: Holiday vs regular attendance 66.3ms 58.5ms MongoDB (11.7% faster)

*MongoDB query completed quickly, MySQL query failed after 4+ hours

What These Results Actually Mean

MongoDB's Strengths Revealed

  1. Simple Aggregations: The 98% performance advantage in RQ1 shows MongoDB's aggregation pipeline excels at straightforward grouping and averaging operations.

  2. Complex Time-Based Queries: RQ3's dramatic difference (MySQL took over an hour, MongoDB completed in milliseconds) demonstrates MongoDB's superiority for complex temporal correlations.

  3. Write-Heavy Workloads: Consistent 50-67% faster write performance makes MongoDB ideal for real-time data ingestion scenarios.

MySQL's Surprising Victory

RQ2 (weather-based attendance analysis) was 98% faster in MySQL. This query required complex temporary table operations and multiple data source correlations – an area where SQL's mature optimization still shines.

The Technical Why Behind the Performance

MongoDB Advantages:

  • No JOIN overhead: Embedded documents eliminate expensive table joins
  • Optimized aggregation pipeline: Purpose-built for analytical workloads
  • Flexible indexing: Better suited for document-based queries
  • Schema flexibility: No rigid structure constraints during writes

MySQL Advantages:

  • Mature query optimization: Decades of SQL optimizer improvements
  • Efficient temporary operations: Better handling of complex intermediate results
  • Memory management: Superior for certain multi-table operations

Real-World Application Insights

Based on our findings, choose:

MongoDB when you have:

  • High-frequency data ingestion (IoT sensors, real-time analytics)
  • Time-series data analysis
  • Simple to moderate aggregation needs
  • Schema evolution requirements

MySQL when you have:

  • Complex multi-source data correlations
  • Heavy use of temporary tables and complex JOINs
  • Mature application ecosystems expecting SQL
  • Strict consistency requirements

The Unexpected Learning: Context Matters

The most valuable insight wasn't that one database is universally better – it's that workload characteristics determine the winner. MongoDB dominated write operations and simple aggregations by massive margins, while MySQL excelled at complex relational operations.

Performance Optimization Lessons

  1. Index Strategy: Both databases benefited equally from proper indexing on date fields and frequently queried attributes.

  2. Query Design: MongoDB's aggregation pipelines required different thinking than SQL, but often resulted in more maintainable code.

  3. Hardware Considerations: Even on modest hardware (HDD storage), the performance differences were dramatic, suggesting they'd be even more pronounced on modern SSD systems.

Bottom Line for Database Selection

Don't choose a database based on hype or familiarity alone. Our Disneyland data analysis proved that:

  • Write-heavy applications: MongoDB provides substantial advantages
  • Complex analytical queries: Results vary dramatically by query type
  • Mixed workloads: Consider using both databases for different use cases

The 98% performance differences we observed aren't edge cases – they represent real-world scenarios that could mean the difference between a responsive application and one that frustrates users.


This performance analysis was conducted as part of a Modern Database Systems course at TH Köln. The complete benchmark code and query implementations are available here for those interested in replicating these tests.

Top comments (0)