Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The difference between mongodb and mysql

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MySQL is a relational database.

Advantages:

1. There are different storage methods on different engines.

2. The query statement uses the traditional sql statement, which has a relatively mature system and high maturity.

3. The share of open source databases is increasing, and the share of mysql pages continues to grow.

Disadvantages:

The main results are as follows: 1. the efficiency will be significantly slower when dealing with massive data.

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

Storage mode: virtual memory + persistence.

Query statement: it is a unique query method of Mongodb.

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

Architectural features: high availability can be achieved through replica sets and shards.

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

Maturity and extensiveness: emerging database, low maturity, Nosql database is the closest to relational database, one of the more perfect DB, the applicable population is growing.

Advantages:

1. Fast! The performance of Mongodb in the right amount of memory is very fast. It stores hot data in physical memory, which makes the reading and writing of hot data very fast. High scalability, stored data format is json format!

Disadvantages:

1, does not support transactions, and the development documentation is not very complete, perfect.

Main application scenarios of Mysql and Mongodb

1. If you need to use mongodb as a back-end db instead of mysql, that is, where mysql and mongodb belong to a parallel level, then such use may be considered in the following cases: (1) the part that mongodb is responsible for is stored in document form, can have good code affinity, and the json format is easy to write directly. (such as logs) (2) atomicity has been taken into account from the datamodels design phase without assistance such as transactions. Developers use languages such as nodejs to develop, which is more convenient for development. (3) the failover mechanism of mongodb itself does not need to be implemented in ways such as MHA.

two。 Use mongodb as a cache db like redis and memcache to provide services for mysql or backend log collection and analysis. Considering that mongodb is a nosql database, sql statements are not as compatible with data structures as mysql, and mongodb is often used as a cache db such as redis memcache, which is used as an auxiliary mysql. Or only log collection and analysis.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report