Magento’s performance enhancement is a priority for the vast majority of Magento developers. To ultimately acquire, expand, maintain, and retain customers for potential growth and development in businesses. In addition, they make some strides to speed up the Magento store to serve the purpose. Magento2 MySQL Query Cache – This is an additional way to accelerate the store.
Magento2 MySQL Query Cache
The MySQL Query Cache is a memory that is stored within the MySQL daemon to store a request result. The result is available immediately whenever a similar request is executed by someone. Instead of calling a new request, we can get the same result from the cache.
Working Mechanism
When a user requests a query, then the MySQL query cache searches the result in the cache memory and if it exists, returns the result from the cache. If there is no result available, then the query is logged. After the query execution, the result is stored in the cache for future use for similar requests.
Implementation
Let’s turn to the execution section, where we learn to Configure or enable the MySQL Query Cache.
- Firstly, log in to the MySQL command prompt and run the below command :
1 |
<code>mysql> SHOW VARIABLES LIKE ‘have_query_cache’;</code> |
As we seen, the value is always YES for the MySQL standard binary irrespective of the cache state of the query.
2. After the above step, find out whether the query cache is operational or not by following the listed command:
1 |
<code>mysql> SHOW VARIABLES LIKE ‘query_cache_size’;</code> |
The image above shows that we have sufficient memory for query cache size means it is enabled. And the below image indicates the disabled state because it depicts the ‘0’ as a query cache size.
3. If you have root access then make the changes to this value by mention these lines in /etc/mysql/my.cnf file and restart the mysql server to enable it.
4. It is prudent to remember a few other parameters too when setting up Magento2 MySQL server.
1 |
<code>mysql> show variables like ‘query_cache_%’;</code> |
If you want to optimize your Magento2 store by Leverage Browser Caching just click.
Do you need optimization for your Magento2 store? Check us out.
Thanks for reading!
We hope it works for you and during this blog you have found something valuable.
In case of any help or query, please contact us or raise a ticket.