-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Is your feature request related to a problem? Please describe.
- Server Result Cache Concepts
The server result cache is a memory pool . This memory pool consists of the SQL query result cache—which stores results of SQL queries—and the SQL function result cache, which stores values returned by SQL functions.
Describe the solution you'd like
The benefits of using the server result cache depend on the application. OLAP applications can benefit significantly from its use. Good candidates for caching are queries that access a high number of rows but return a small number, such as those in a data warehouse.
Understanding How the Server Result Cache Works
When a query executes, the database searches the cache memory to determine whether the result exists in the result cache. If the result exists, then the database retrieves the result from memory instead of executing the query. If the result is not cached, then the database executes the query, returns the result as output, and stores the result in the result cache.
When users execute queries and functions repeatedly, the database retrieves rows from the cache, decreasing response time. Cached results become invalid when data in dependent database objects is modified.
MySQL [(none)]> show global variables where Variable_name like "enable_result_cache";
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| enable_result_cache | false |
+---------------------+-------+
47 rows in set (0.00 sec)
MySQL [(none)]> set global enable_result_cache = true;
Query OK, 0 rows affected (0.00 sec)
MySQL [(none)]> show global variables where Variable_name like "enable_result_cache";
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| enable_result_cache | true |
+---------------------+-------+
1 row in set (0.00 sec)