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

Angular Cookie read and write operation code

Angular Cookie read and write operations, the cod...

MySQL functional index optimization solution

When using MySQL, many developers often perform f...

How to use MySQL DATEDIFF function to get the time interval between two dates

describe Returns the time interval between two da...

HTML uses regular expressions to test table examples

Here is an example code for using regular express...

Detailed tutorial on installing Docker on CentOS 7.5

Introduction to Docker Docker is an open source c...

Design Theory: Hierarchy in Design

<br />Original text: http://andymao.com/andy...

JavaScript implements checkbox selection function

This article example shares the specific code of ...

Best Practices for Developing Amap Applications with Vue

Table of contents Preface Asynchronous loading Pa...

Mysql join query principle knowledge points

Mysql join query 1. Basic concepts Connect each r...

Sample code for deploying Spring-boot project with Docker

1. Basic Spring-boot Quick Start 1.1 Quick start ...

Detailed explanation of Vuex environment

Table of contents Build Vuex environment Summariz...

Installation and use of mysql on Ubuntu (general version)

Regardless of which version of Ubuntu, installing...

Docker uses dockerfile to start node.js application

Writing a Dockerfile Taking the directory automat...

js implements a simple calculator

Use native js to implement a simple calculator (w...

Things to note when migrating MySQL to 8.0 (summary)

Password Mode PDO::__construct(): The server requ...