Which is faster: MySQL or MongoDB? Does it depend on the use case?

Posted on February 24, 2012. Filed under: Uncategorized |

So the question should have been more like ‘When is MongoDB a better data retrieval solution than mysql?’

I’m going to try to do justice to the comments, adding a little flavor here or there.

Sui generis
Of course its difficult to say without benchmarking your app both ways.  That’s not entirely helpful as the number of data stores is swelling and you don’t want to prototype and load test all of them.

To me, the Mysql vs MongoDB benchmarks are revealing as they show that with beefy hardware, a NoSQL engine does not have to be faster than a well indexed Mysql Table, which might seem the case.  Its likely that in less optimal hardware the mongodb’s performance drops off more slowly than mysql – the sql front end must have some overhead.

So, what can be said?  the Answers left me with three take home issues for data store choice:

What Data Structure do I really want?
MongoDB’s object oriented data storage makes it much more flexible when the documents stored are not uniform – often the case in web apps.  MongoDBs various APIs can take in JSON directly.   If you have designed your sql schema for fast data retrieval, you are avoiding large numbers of documents (high millions) or are partitioning the tables and avoiding  joins to tables with any large size.  NoSQL data structures encourage you to do this naturally, having no real provisions for  joins.

How much is this going to cost?
If your app is already built over an SQL operation or that is where your engineering expertise is much stronger in SQL it sounds like engineering can deliver strong scaling performance can be had from mysql or oracle.

As far as scaling MongoDB there is a lot of engineering you don’t have to do to scale. It shards and scales effectively using built in features without the extensive setup required for clustering RDBMS systems.

There is no free lunch
There’s no magic in NoSQL;- The indexes should always be smaller than your RAM – this is true for NoSQL and SQL.  I think scaling some applications with large numbers of commits might be difficult with SQL apps unless you have careful partitioning designed in.  On the other if you have good throughput reads while doing commits, not all the users will see the updated data at the same time.

A lot of well known scaling issues are built into the newer data stores, but experience and careful design are still important to get anything to performance scale well.

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

One Response to “Which is faster: MySQL or MongoDB? Does it depend on the use case?”

RSS Feed for I Know This Now Comments RSS Feed

Very nice article and right to the point. I am not sure if this is really the best place to ask but do you people have any ideea where to employ some professional writers? Thanks 🙂


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: