16

I am really new to database and am interested in some high level basic knowledge. I have read this wonderful SO post. I under one is better than another in some cases, but not sure why.

  1. Why is MySQL faster than MongoDB at join operations?

  2. Why does MongoDB scale better in distributed system?

  3. Why is MongoDB faster if I am "just selecting a bunch of tables and putting all the objects together, AKA what most people do in a web app" ?

Thanks a lot!

Community
  • 1
  • 1
CuriousMind
  • 15,168
  • 20
  • 82
  • 120

1 Answers1

20

This question lacks any real research, I mean you say you read that question but either that question has some real problems with the source of its information or...well; anyway:

Why is MySQL faster than MongoDB at join operations?

Because it doesn't have any? MongoDB HAS NO SERVER SIDE JOINS. I am sorry to put that in capitals but I say it soooooo often, I just feel like placing it as the defacto answer for most questions.

Any joins you do are client side. This means they will actually be slower than MySQL, or other SQL techs. The important idea behind doing joins client side is that doing them server-side becomes very hard to scale in huge distributed environments, if not impossible. That is why many big SQL users actually attempt to prevent huge joins and are effectively trying to do in SQL what MongoDB does.

The case for this is scenario dependant of course.

Why does MongoDB scale better in distributed system?

http://docs.mongodb.org/manual/replication/ is very important here and so too is http://docs.mongodb.org/manual/core/sharded-clusters/ and I would recommend reading both carefully and how they scale to data partitions and what not.

Why is MongoDB faster if I am "just selecting a bunch of tables and putting all the objects together, AKA what most people do in a web app" ?

I don't know what you mean by that.

I realise this isn't much of an answer but your question is one of those defacto questions and so I answered with a defacto answer.

Since you are new to databases in general I would personally recommend you go use one...

peterh
  • 11,875
  • 18
  • 85
  • 108
Sammaye
  • 43,242
  • 7
  • 104
  • 146
  • So, if I doing this : http://blog.mongodb.org/post/35133050249/mongodb-for-the-php-mind-part-3 For 300k row data, it will be faster to join with MySQL than MongoDB right? – Anggie Aziz Sep 23 '13 at 05:45
  • @AnggieAziz It depends upon the specific queries, with the embedded lists JOIN (the first example) if you were to pick all tags out it would actually be faster in MongoDB since it is two indexed queries however, if you were to do complex joins across multiple tables, sort on that join and paginate that JOIN across millions of rows then SQL techs would just pound MongoDB – Sammaye Sep 23 '13 at 07:13
  • 1
    "Go use one".. lol brutal. Great answer – NiCk Newman Mar 08 '16 at 09:16