Learn Mysql

Basic Tutorials

Query cache in Mysql

Last Updated : Aug 16th 2017 00:12
  • If Query_cache_type = 0 then query cache disable.
  • If Query_cache_type = 1 then all queries in cache .
  • If Query_cache_type = 2 then query cache on DEMAND.

How to set cache type in mysql:

SET  query_cache_type =2

How to set query cache size means how much data mysql store n cache :

SET GLOBAL query_cache_size = 268435456;

How to Use Query Cache:

SELECT SQL_CACHE user_id FROM ge_draw_ticket_cancel_2.

How to check How many queries are hit from cache:

SHOW STATUS LIKE 'Qcache%';

  1. If the query cache size is greater than 0, the query_cache_type variable influences how it works. This variable can be set to the following values:
  2. A value of 0 or OFF prevents caching or retrieval of cached results.
  3. A value of 1 or ON enables caching except of those statements that begin with SELECT SQL_NO_CACHE.
  4. A value of 2 or DEMAND causes caching of only those statements that begin with SELECT SQL_CACHE.
  5. To control the maximum size of individual query results that can be cached, set the query_cache_limit system variable. The default value is 1MB.

Query cache in Mysql

How to set cache type in mysql:

SET  query_cache_type =2

How to set query cache size means how much data mysql store n cache :

SET GLOBAL query_cache_size = 268435456;

How to Use Query Cache:

SELECT SQL_CACHE user_id FROM ge_draw_ticket_cancel_2.

How to check How many queries are hit from cache:

SHOW STATUS LIKE 'Qcache%';

  1. If the query cache size is greater than 0, the query_cache_type variable influences how it works. This variable can be set to the following values:
  2. A value of 0 or OFF prevents caching or retrieval of cached results.
  3. A value of 1 or ON enables caching except of those statements that begin with SELECT SQL_NO_CACHE.
  4. A value of 2 or DEMAND causes caching of only those statements that begin with SELECT SQL_CACHE.
  5. To control the maximum size of individual query results that can be cached, set the query_cache_limit system variable. The default value is 1MB.
Copyright © 2016, Solutionbell, All Rights Reserved