Home > Database > Mysql Tutorial > What are the differences between MySQL and Redis?

What are the differences between MySQL and Redis?

青灯夜游
Release: 2022-06-14 16:53:48
Original
34247 people have browsed it

Difference: 1. MySQL is a relational database; while Redis is a non-relational database. 2. MySQL is used to persistently store data to the hard disk, which is powerful but slow; while Redis is used to store frequently used data in the cache and has fast reading speed. 3. MySQL data is stored on disk; Redis data is stored in memory. 4. MySQL’s commonly used data types include numerical values, date/time, and strings; Redis’s commonly used data types include strings, Hash, List, Set, and Zset.

What are the differences between MySQL and Redis?

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

1. Database types of MySQL and Redis

1. Mysql is a relational database, mainly used to store persistent data and store data In a hard disk, the read speed is relatively slow.

2. Redis is a NOSQL database, that is, non-relational database, and it is also a cache database, that is, data is stored in memory. The cached read speed is fast and can Greatly improves operating efficiency, but the storage time is limited.

2. The operating mechanism of MySQL and Redis

1. As a stored relational database, the relative weakness of MySQL database is that every time a request is made to access the database, There are I/O operations. If the database is accessed repeatedly and frequently, the following problems will occur:

(1)会在反复链接数据库上花费大量的时间,从而导致运行效率过慢
(2)反复的访问数据库也会导致数据库的负载过高,那么此时缓存的概念就衍生出来了
Copy after login

2. Redis is based on single thread, and Redis is more efficient because Redis is based on memory. operation, so the CPU is not the performance bottleneck, the machine's memory and bandwidth are the bottlenecks of Redis.

3. What is a cache database?

The cache is the buffer (cache) for data exchange. When the browser performs a request, it will first search the cache and obtain it if it exists; otherwise, it will Access the database.

Benefits of caching: Fast reading speed

##Example: Redis database is a cache database , used to store frequently used data, thus reducing the number of database accesses and improving operating efficiency.

4. Summary of the differences between Redis and MySQL

4.1 Database type

(1) MySQL is relational Type database

(2) Redis is a cache database (non-relational database)

4.2 Database function

(1) MySQL is used for persistence Store data to the hard drive, powerful, but slow.

(2) Redis is used to store frequently used data in the cache and has fast reading speed.

4.3 Business Requirements

MySQL and Redis are generally used together in practical applications due to different requirements.

4.4 Data storage location

(1)MySQL: Data is stored in disk

(2)Redis: Data is stored in memory

4.5 Storage data types (commonly used)

(1) MySQL: numerical value, date/time, string

(2) Redis: String, Hash , List, Set, Zset

[Related recommendations:

mysql video tutorial]

The above is the detailed content of What are the differences between MySQL and Redis?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template