MySQL Query Cache and Buffer Pool

MySQL Query Cache and Buffer Pool

1. Caches - Query Cache

The following figure is provided by the MySQL official website: MySQL architecture system diagram.

The query cache that people often refer to is the Cache part in the figure below.

If MySQL is divided into two parts: the server layer and the storage engine layer, then Caches are located in the server layer.

In addition, you should know:

When a SQL statement is sent to MySQL Server, MySQL Server will first check the query cache to see if the SQL statement has been executed before. If it has been executed before, the query results of the previous execution will be saved in the query cache in the form of Key-Value. The key is the SQL statement and the value is the query result. We call this process query caching!

If the data you are looking for is not in the query cache, MySQL will execute the subsequent logic and retrieve the data through the storage engine. And the query cache will be shared cache for sessions, yes, it will be shared by all sessions.

Disadvantages of query cache:

As long as there is a SQL update on the table, the query cache of the table will become invalid. So when the proportion of table CRUD in your business is similar, query cache may affect the throughput efficiency of the application.

You can disable query caching by setting the parameter query_chache_type=demand. And in the MySQL 8.0 version, the query cache module has been deleted.

Therefore, you can consider whether it is necessary to disable a function according to your own situation.

Buffer Pool

Again, if MySQL is divided into two parts: the server layer and the storage engine layer, then the Buffer Pool is located in the storage engine layer.

In fact, everyone knows that whether it is a connection pool or a cache pool, as long as it is an XXX pool, it is designed for acceleration. For example, in order to speed up data reading, the file system of the operating system designs a buffered write mechanism for inefficient random disk IO every time.

The Buffer Pool is a buffering mechanism designed by the MySQL storage engine to speed up data reading. The gray part in the picture below is the mind map of BufferPool. (The handwriting is authentic, very beautiful!)

The above is the details of MySQL query cache and Buffer Pool. For more information about MySQL query cache and Buffer Pool, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • MySQL Innodb key features insert buffer
  • Detailed explanation of the buffer pool in MySQL
  • Important parameters for mysql optimization key_buffer_size table_cache
  • Optimize mysql key_buffer_size settings
  • What is the appropriate setting for mysql read_buffer_size?
  • MySQL Sort aborted: Out of sort memory, consider increasing server sort buffer size
  • Analyzing the Innodb buffer hit rate calculation from the MySQL source code
  • Detailed explanation of mysql operation buffer usage in php
  • Two important parameters in Mysql optimization and tuning: table_cache and key_buffer
  • Optimization setting of mysql key_buffer_size parameter
  • Research on Buffer Pool Pollution Caused by mysqldump
  • MySQL join buffer principle

<<:  About Generics of C++ TpeScript Series

>>:  Detailed tutorial on Apache source code installation and virtual host configuration

Recommend

VMware Workstation Pro 16 License Key with Usage Tutorial

VMware Workstation is a powerful desktop virtual ...

Example code for implementing a QR code scanning box with CSS

We usually have a scanning box when we open the c...

This article will help you understand JavaScript variables and data types

Table of contents Preface: Kind tips: variable 1....

WeChat applet implements countdown for sending SMS verification code

This article shares the specific code for the WeC...

MySQL online log library migration example

Let me tell you about a recent case. A game log l...

WeChat applet canvas implements signature function

In the WeChat applet project, the development mod...

Use Vue3 for data binding and display list data

Table of contents 1. Comparison with Vue2 1. New ...

CSS to achieve horizontal lines on both sides of the middle text

1. The vertical-align property achieves the follo...

A brief talk about calculated properties and property listening in Vue

Table of contents 1. Computed properties Syntax: ...

How to use html css to control div or table to be fixed in a specified position

CSS CodeCopy content to clipboard .bottomTable{ b...

JavaScript to achieve simple tab bar switching case

This article shares the specific code for JavaScr...

How to configure Http, Https, WS, and WSS in Nginx

Written in front In today's Internet field, N...

PyTorch development environment installation tutorial under Windows

Anaconda Installation Anaconda is a software pack...

vitrualBox+ubuntu16.04 install python3.6 latest tutorial and detailed steps

Because I need to use Ubuntu+Python 3.6 version t...