Status message

Maintenant, vous regardez: Enabling MySQL’s Query Cache

Enabling MySQL’s Query Cache

MySQL is the most common database used with Drupal. MySQL has the ability to cache frequent queries
in RAM so that the next time a given query is issued, MySQL will return it instantly from the cache.
However, in most MySQL installations, this feature is disabled by default. To enable it, add the following
lines to your MySQL option file; the file is named my.cnf and specifies the variables and behavior for
your MySQL server In this case,
we’re setting the query cache to 64MB:

First , let's make sure that your installation of MySQL actually has query caching support available. Most distributions do, but you should check anyway.

  1. MariaDB [(none)]> show variables like 'have_query_cache';
  2. +------------------+-------+
  3. | Variable_name | Value |
  4. +------------------+-------+
  5. | have_query_cache | YES |
  6. +------------------+-------+

Next we’ll need to check and see if query caching is enabled. We’ll need to check more than one variable, so we may as well do it all at once by checking for the variable query%

  1. MariaDB [(none)]> show variables like 'query%';
  2. +------------------------------+----------+
  3. | Variable_name | Value |
  4. +------------------------------+----------+
  5. | query_alloc_block_size | 8192 |
  6. | query_cache_limit | 1048576 |
  7. | query_cache_min_res_unit | 4096 |
  8. | query_cache_size | 16777216 |
  9. | query_cache_strip_comments | OFF |
  10. | query_cache_type | ON |
  11. | query_cache_wlock_invalidate | OFF |
  12. | query_prealloc_size | 8192 |
  13. +------------------------------+----------+
  14. 8 rows in set (0.00 sec)

Here’s the important items in the list and what they mean:

query_cache_size – This is the size of the cache in bytes. Setting this value to 0 will effectively disable caching.
query_cache_type – This value must be ON or 1 for query caching to be enabled by default.
query_cache_limit – This is the maximum size query (in bytes) that will be cached.

If the query_cache_size value is set to 0 or you just want to change it, you’ll need to run the following command, keeping in mind that the value is in bytes. For instance, if you wanted to allocate 8MB to the cache we’d use 1024 * 1024 * 8 = 8388608 as the value.

  1. SET GLOBAL query_cache_size = 8388608;
  3. //Similarly, the other options can be set with the same syntax:
  4. SET GLOBAL query_cache_limit = 1048576;
  5. SET GLOBAL query_cache_type = 1;
  1. # The MySQL server
  2. [mysqld]
  3. query_cache_size=64M

The current query cache size can be viewed as output of MySQL’s SHOW VARIABLES command:

  1. mysql>SHOW VARIABLES LIKE 'query_cache%';
  2. ...
  3. | query_cache_size | 67108864
  4. | query_cache_type | ON
  5. ...

Experimenting with the size of the query cache is usually necessary. Too small a cache means
cached queries will be invalidated too often. Too large a cache means a cache search may take a
relatively long time; also, the RAM used for the cache may be better used for other things, like more web
server processes, memcache, or the operating system’s file cache.

Other directives may also need to be done:

1) innodb_buffer_pool_size
2) tmp_table_size
3) max_heap_table_size
4) table_open_cache


Comments most reliable canadian online pharmacies
drugstore online
online pharmacies tech school canadian pharcharmy online
canadian online pharmacies reviews
most reliable canadian online pharmacies canada medication
northwest pharmacies mail order
canada online pharmacies canadian medications by mail
canadian pharmacies that ship to us
canadian medications list good canadian online pharmacies
discount canadian pharmacies
drugstore online canada canadian pharmacies without an rx
online pharmacies tech school
canadian pharmacy online 24 canada medications information
pharmacy onesource
canadian pharmacy viagra brand canada vagra
canadian pharmacies without an rx
canadian pharmacies without an rx online canadian pharmacies
buy viagra online usa
online pharmacies mexico drugs for sale deep web
canadian medications list
online canadian discount pharmacies drugstore online shopping reviews
no 1 canadian pharcharmy online
canada medication canada pharmaceuticals online
canada online pharmacies medication
trust pharmacy canada reviews canadian government approved pharmacies
online pharmacies in usa
cialis canadian pharmacy canada online pharmacies for men
canada pharmacies online prescriptions
buy viagrow safe canadian online pharmacies
canadian online pharmacies legal
canadian pharmacy uk delivery canadian pharmacies-24h
aarp recommended canadian pharmacies
canadian drug

I got this web site from my buddy who shared with me regarding this web site and now this time I am visiting

this website and reading very informative articles here.

Also visit my web-site; hosting services rx from canada
northwest pharmacies in canada
top rated canadian pharmacies online canada pharmacies
online canadian discount pharmacies
canadian discount pharmacies in canada canadian pharmacy viagra
canadian pharcharmy online24
reputable canadian prescriptions online northwest pharmacies mail order
pharmacy canada
the best canadian online pharmacies canada medication
canadian government approved pharmacies
canadian pharmacies online prescriptions canadian pharmacy viagra
canada medications cheap
no 1 canadian pharcharmy online online pharmacies in usa
rx from canada
aarp recommended canadian online pharmacies canada online pharmacies medication
canada medications information
online pharmacies of canada canadian government approved pharmacies
canadian drug store
canada medications cheap


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
2 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.