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

How to choose the database

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "how to choose the database". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to choose the database.

1 read and write speed

This way of storing data often determines the speed of reading and writing.

Mysql both data and indexes are stored on the hard disk. Don't swap it into memory until you want to use it. Can handle data that far exceeds the total amount of memory.

All the data of MongoDB is actually stored on the hard disk, and all the data to be operated is mapped to a certain area of memory by mmap. MongoDB then modifies the data in this area to avoid piecemeal hard disk operations.

Redis all data is kept in memory. But it also supports data persistence to the hard disk.

We all know that disk is far less efficient than memory in reading data. Therefore, in general, the speed order of reading and writing data of the three is: Redis > MongoDB > Mysql.

2 whether transactions and complex queries are supported

MySql is a relational database that supports transaction operations and complex structured queries in the form of join. On the other hand, MongoDB is a non-relational database, which supports neither transaction operation nor join operation. Redis also does not support it.

Therefore, you should consider using MySql for the following scenarios:

1) there is a large amount of structured data in the business data, such as user account number, address, etc. Because these data usually need to do structured query.

2) there are many transactional operations in the business, so it is necessary to ensure the strong consistency of transactions.

3 growth rate of business data volume

In one to two years, the growth of business data is not within the forecast, priority is given to the use of MongoDB.

Because MongoDB has built-in sharding and many data slicing features, it is easy to expand horizontally and better adapt to the needs of large data growth. However, the performance of MySql is inferior in this respect. When the amount of data in a single MySql table reaches 5-10 G, the performance of the details will be degraded. It is necessary to split the data horizontally and vertically, and to split the database to complete the expansion.

Due to memory limitations, Redis will not be used to store large amounts of data. It is usually used as a cache.

4 whether the structure of the table is clear

If in a business scenario, the database table interface is not clear, the data is still increasing. For example, in the following scenarios, content management platforms (such as post scenarios in BBS forums), user social platforms (such as posts in post bars and user comments), MangDB is preferred.

Because MongoDB is an unstructured document database, extending fields is easy and does not affect the original data.

At this point, I believe you have a deeper understanding of "how to choose the database". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Internet Technology

Wechat

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

12
Report