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;
  2.  
  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

Tags:

Comments

https://canadianhpharmacy.com/ most reliable canadian online pharmacies
drugstore online https://canadianhpharmacy.com/
online pharmacies tech school https://canadianhpharmacy.com/

https://canadianlpharmacy.com/ canadian pharcharmy online
canadian online pharmacies reviews https://canadianlpharmacy.com/
most reliable canadian online pharmacies https://canadianlpharmacy.com/

https://canadianhpharmacy.com/ canada medication
northwest pharmacies mail order https://canadianhpharmacy.com/
canada online pharmacies https://canadianhpharmacy.com/

https://viagracwithoutdoctor.com/ canadian medications by mail
canadian pharmacies that ship to us https://viagracwithoutdoctor.com/
canadian medications list https://viagracwithoutdoctor.com/

https://viagrawwithoutdoctor.com/ good canadian online pharmacies
discount canadian pharmacies https://viagrawwithoutdoctor.com/
drugstore online canada https://viagrawwithoutdoctor.com/

https://viagracwithoutdoctor.com/ canadian pharmacies without an rx
online pharmacies tech school https://viagracwithoutdoctor.com/
canadian pharmacy online 24 https://viagracwithoutdoctor.com/

https://viagrawwithoutdoctor.com/ canada medications information
pharmacy onesource https://viagrawwithoutdoctor.com/
canadian pharmacy viagra brand https://viagrawwithoutdoctor.com/

https://viagrawwithoutdoctor.com/ canada vagra
canadian pharmacies without an rx https://viagrawwithoutdoctor.com/
canadian pharmacies without an rx https://viagrawwithoutdoctor.com/

https://canadianlpharmacy.com/ online canadian pharmacies
buy viagra online usa https://canadianlpharmacy.com/
online pharmacies mexico https://canadianlpharmacy.com/

https://canadianlpharmacy.com/ drugs for sale deep web
canadian medications list https://canadianlpharmacy.com/
online canadian discount pharmacies https://canadianlpharmacy.com/

https://canadianhpharmacy.com/ drugstore online shopping reviews
no 1 canadian pharcharmy online https://canadianhpharmacy.com/
canada medication https://canadianhpharmacy.com/

https://canadianlpharmacy.com/ canada pharmaceuticals online
canada online pharmacies medication https://canadianlpharmacy.com/
trust pharmacy canada reviews https://canadianlpharmacy.com/

https://canadianlpharmacy.com/ canadian government approved pharmacies
online pharmacies in usa https://canadianlpharmacy.com/
cialis canadian pharmacy https://canadianlpharmacy.com/

https://viagrawwithoutdoctor.com/ canada online pharmacies for men
canada pharmacies online prescriptions https://viagrawwithoutdoctor.com/
buy viagrow https://viagrawwithoutdoctor.com/

https://canadianhpharmacy.com/ safe canadian online pharmacies
canadian online pharmacies legal https://canadianhpharmacy.com/
canadian pharmacy uk delivery https://canadianhpharmacy.com/

https://canadianlpharmacy.com/ canadian pharmacies-24h
aarp recommended canadian pharmacies https://canadianlpharmacy.com/
canadian drug https://canadianlpharmacy.com/

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

https://canadianhpharmacy.com/ rx from canada
northwest pharmacies in canada https://canadianhpharmacy.com/
top rated canadian pharmacies online https://canadianhpharmacy.com/

https://canadianhpharmacy.com/ canada pharmacies
online canadian discount pharmacies https://canadianhpharmacy.com/
canadian discount pharmacies in canada https://canadianhpharmacy.com/

https://canadianhpharmacy.com/ canadian pharmacy viagra
canadian pharcharmy online24 https://canadianhpharmacy.com/
reputable canadian prescriptions online https://canadianhpharmacy.com/

https://canadianhpharmacy.com/ northwest pharmacies mail order
pharmacy canada https://canadianhpharmacy.com/
the best canadian online pharmacies https://canadianhpharmacy.com/

https://viagracwithoutdoctor.com/ canada medication
canadian government approved pharmacies https://viagracwithoutdoctor.com/
canadian pharmacies online prescriptions https://viagracwithoutdoctor.com/

https://viagracwithoutdoctor.com/ canadian pharmacy viagra
canada medications cheap https://viagracwithoutdoctor.com/
no 1 canadian pharcharmy online https://viagracwithoutdoctor.com/

https://canadianhpharmacy.com/ online pharmacies in usa
rx from canada https://canadianhpharmacy.com/
aarp recommended canadian online pharmacies https://canadianhpharmacy.com/

https://viagracwithoutdoctor.com/ canada online pharmacies medication
canada medications information https://viagracwithoutdoctor.com/
online pharmacies of canada https://viagracwithoutdoctor.com/

https://canadianhpharmacy.com/ canadian government approved pharmacies
canadian drug store https://canadianhpharmacy.com/
canada medications cheap https://canadianhpharmacy.com/

Pages

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.
CAPTCHA
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.