The characteristics and merits of MySQL and MongoDB

Source: Internet
Author: User

First, we analyze the characteristics and merits of MySQL and MongoDB.
Here is the part of the PPT I used to do.






To analyze the application scenario,
A. If you need to use MongoDB as a back-end db instead of MySQL, where MySQL and MongoDB are parallel levels, then there are a few things that can be considered:
(1) MongoDB is responsible for the part of the document storage, can have good code affinity, JSON format for direct write convenience. (such as logs, etc.)
(2) Consider atomicity from the data models design phase, without the need for assistance such as transactions. Development using language such as Nodejs to develop, it is more convenient for development.
(3) The failover mechanism of MongoDB itself does not need to be implemented in such a way as MHA.

This situation is also a lot of, my hands on the game is Nodejs+mongodb, the total user is also tens other, water what is good.

B. Use MongoDB as a redis-like, memcache to cache db, serve MySQL, or back-end log collection analysis.
Given that MongoDB is a nosql database, SQL statements and data structures are not as friendly as MySQL, and there will be times when MongoDB is used as a cache db such as Redis memcache, which is used to assist MySQL.
or only for log collection analysis.

Question 2:
The landlord may not observe carefully.
I did the experiment. Examples are as follows:
> Db.a.save ({"A": 3});
> Db.a.save ({"A": 4});
> Db.a.find ()
{"_id": ObjectId ("540826eb0e83c3fb7ea07a0f"), "a": 3}
{"_id": ObjectId ("5416869a9fa8a67830dfc9a8"), "a": 4}
> Db.a.find (). Sort ({a:1})
{"_id": ObjectId ("540826eb0e83c3fb7ea07a0f"), "a": 3}
{"_id": ObjectId ("5416869a9fa8a67830dfc9a8"), "a": 4}
> Db.a.find (). Sort ({a:-11})
{"_id": ObjectId ("5416869a9fa8a67830dfc9a8"), "a": 4}
{"_id": ObjectId ("540826eb0e83c3fb7ea07a0f"), "a": 3}
> Db.system.profile.find ({"ns": "TEST.A"})
{"OP": "Query", "ns": "TEST.A", "query": {"query": {}, "by": {"a": 1}}, "Ntoreturn": 0, "Ntoskip": 0, "Nscanned": 2, "Scanandorder": True, "Keyupdates": 0, "Numyield": 0, "Lockstats": {"Timelockedmicros": {"R": Numb Erlong (156), "W": Numberlong (0)}, "Timeacquiringmicros": {"R": Numberlong (4), "W": Numberlong (3)}}, "nreturned":  2, "ResponseLength":, "Millis": 0, "ts": Isodate ("2014-09-15t06:26:36.681z"), "Client": "127.0.0.1", "allUsers": [ ], "User": ""}
{"OP": "Query", "ns": "TEST.A", "query": {"query": {}, "by": {"a": -11}, "Ntoreturn": 0, "Ntoskip": 0 , "nscanned": 2, "Scanandorder": True, "Keyupdates": 0, "Numyield": 0, "Lockstats": {"Timelockedmicros": {"R": Nu Mberlong (+), "W": Numberlong (0)}, "Timeacquiringmicros": {"R": Numberlong (4), "W": Numberlong (3)}}, "nreturned"  : 2, "ResponseLength": "Millis": 0, "ts": Isodate ("2014-09-15t06:26:39.125z"), "Client": "127.0.0.1", "allUsers": [], "User": ""}

The use of sort is not placed in query, but instead has a separate field to store. such as the Scarlet Letter section above.

The characteristics and merits of MySQL and MongoDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.