Home >Database >Mysql Tutorial >Is mysql single-threaded or multi-threaded?

Is mysql single-threaded or multi-threaded?

青灯夜游
青灯夜游Original
2020-09-28 09:58:467477browse

mysql is multi-threaded. Mysql is a single-process multi-thread database. There are about three types of threads in innodb: 1. Master Thread; 2. IO Thread thread, used to process write requests asynchronously; 3. Purge Thread thread, used to delete undo logs .

Is mysql single-threaded or multi-threaded?

(Recommended tutorial: mysql video tutorial)

mysql is a single-process multi-thread database, in innodb There are probably the following types of threads in it:

(1) Master Thread: This is the main thread, very core. Its purpose is mainly to do some periodic tasks, in different innodb versions Their functions are different, here is the earliest version. The early innodb Master thread will have two frequency tasks, one is once every 1 second, and the other is once every 10 seconds.

Work every second:

1. Refresh the log;

2. Refresh up to 100 dirty pages

3. Merge the insert buffer;

4. If idle, switch to background.

In fact, the most important ones are the first two. And only refreshing the log must be done every time, and the rest will only be done if conditions are met. For example, refreshing dirty pages will only be refreshed if the proportion of dirty pages in the cache exceeds a threshold.

Work every 10 seconds:

1. Refresh log;

2. Refresh dirty pages;

3. Delete undo log;

4. Merge insert buffer

(2) IO Thread: Mainly used for asynchronous processing of write requests.

(3) purge Thread: is used to delete undo logs. This is the subsequent innodb version that separates this matter from the Master thread.

Finally, a memory map of innodb:

Is mysql single-threaded or multi-threaded?

Related recommendations: php training

The above is the detailed content of Is mysql single-threaded or multi-threaded?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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