The difference between mongodb and mysql (super detailed)

2020-08-02 21:28:07 0 Comment 820 views
abstract

SQL statements and data structures are not as compatible as mysql, and there are many times when mongodb is used as an auxiliary mysql cache db like r

The difference between mongodb and mysql (super detailed)

The difference between mongodb and mysql (super detailed)

MySQL is a relational database.

Advantages:

There are different storage methods on different engines.

The query statement uses the traditional sql statement, with a relatively mature system and a high degree of maturity.

The share of open source databases continues to increase, and the share page of mysql continues to grow.

Disadvantages:

The efficiency will be significantly slower when processing massive data.

Mongodb is a non-relational database (nosql), which is a document database. A document is the basic unit of data in mongoDB, similar to the row of a relational database. Multiple key-value pairs are placed together in an orderly manner to form a document. The syntax is somewhat similar to javascript is an object-oriented query language, which is a collection-oriented, document-based database with free patterns.

Storage method: virtual memory + persistence.

Query statement: It is a unique Mongodb query method.

Suitable for scenarios: event recording, content management or blog platform, etc.

Architectural features: High availability can be achieved through replica sets and fragmentation.

Data processing: Data is stored on the hard disk, but the data that needs to be read frequently will be loaded into the memory, and the data will be stored in the physical memory to achieve high-speed reading and writing.

Maturity and breadth: emerging databases, low maturity, Nosql database is the closest to relational database, one of the more complete DB, the applicable population is constantly growing.

Pros:

Quick! In fitThe performance of Mongodb with an order of magnitude memory is very fast. It stores hot data in physical memory, making the read and write of hot data very fast. High scalability, the stored data format is json format!

Disadvantages:

Does not support transactions, and the development documentation is not very complete and complete.

The main application scenarios of Mysql and Mongodb

1. If you need to use mongodb as a backend db instead of mysql, that is, here mysql and mongodb are parallel, then such use is possible There are several considerations for the following situations: (1) The part responsible for mongodb is stored in the form of documents, which can have good code affinity, and it is convenient to write directly in the json format. (Such as logs) (2) From the datamodels design stage, the atomicityConsidering it, no assistance such as affairs is needed. Development uses languages ​​such as nodejs for development, which is more convenient for development. (3) The failover mechanism of mongodb itself does not need to be implemented in a way such as MHA.

2. Use mongodb as a similar redis, memcache to cache db, provide services for mysql, or back-end log collection and analysis. Considering that mongodb is a nosql database, sql statements and data structures are not as compatible as mysql, and there are many times when mongodb is used as an auxiliary mysql cache db like redis memcache. Or just for log collection and analysis.

---------------------

Original: https://blog.csdn.net/Gjc_csdn/article/details/80419997

avatar