mariaDB cache 설정
2019.08.04 16:59
https://easyengine.io/tutorials/mysql/query-cache/
안하면 엄청 느리다.
Important Note: From MySQL 5.6.8,query_cache_type
is set to OFF by default. So if you haven’t explicitly turned it ON on old version, it may not work anymore!
Check current status of query_cache
mysql -e "show variables like 'query_cache_%'"
Will output something like:
+------------------------------+-----------+ | Variable_name | Value | +------------------------------+-----------+ | query_cache_limit | 2097152 | | query_cache_min_res_unit | 4096 | | query_cache_size | 268435456 | | query_cache_strip_comments | ON | | query_cache_type | ON | | query_cache_wlock_invalidate | OFF | +------------------------------+-----------+
Query Cache Config
Add something like below following to your /etc/my/my.cnf
query_cache_type = 1 query_cache_size = 256M query_cache_limit = 2M query_cache_strip_comments =1
Please note that query_cache_strip_comments
variable is available on Percona & MariaDB mysql variants as of now.
Meaning of variables
query_cache_type
Just turn it ON. From mysql 5.6.8 its OFF by default.
If this is OFF, you will see error “[!!] Query cache is disabled” when running mysqltuner.
Earlier mysql version used to setquery_cache_type
= 1 butquery_cache_size
= 0. If either ofquery_cache_type
andquery_cache_size
is set to 0, query_cache gets disabled.
query_cache_size
Default is 1MB. You can set it upto 4GB but very high values are not recommend for sites where tables are modified quite frequently.
In WordPress scenario, if you have a multi-author blog, or some other custom post types, then query cache prunes might be frequent. Query cache is invalidated for entire table even if a small value is modified.
query_cache_limit
Default is 1MB. You can set it upto 4GB. Again very high values are not recommended.
Better optimize your codes to not fetch too much data in one query. If you need 10 rows, add pagination, WHERE conditions rather than fetching all rows from mysql and then using only 10 rows out of them!
InnoDB Buffer & Query Cache
Many references on Internet will tell you that query cache is useless if InnoDB is being used.
Well if you are using InnoDB only and have limited RAM, InnoDB buffer pool without a doubt should get first priority.
If you have some spare RAM, it is highly recommended to use query_cache for WordPress sites. Even for big WordPress sites, most likely percentage of SELECT queries will be much higher as compared to INSERT or UPDATE.
Best way is to monitor query cache efficiency using mysqltuner. Look for a line like:
[OK] Query cache efficiency: 71.5% (8K cached / 11K selects)
100% Query cache efficiency may not be possible for 100% read-only sites but try to stay above 50%.
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
1716 | 이건 비밀글이얍 | J | 2004.04.23 | 2 |
1715 | 아저씨에게 [1] | ^&^ | 2004.04.25 | 3 |
1714 | 아저씨~ [1] | ^&^ | 2004.05.15 | 5 |
1713 | 다시 이곳으로... | WHRIA | 2024.03.02 | 6 |
1712 | 모든 연구 자료를 정리. 이것으로 마무리 짓기로. | WHRIA | 2024.03.03 | 14 |
1711 | MedicalPhoto MSVC 2015 와 최신 boost 로... | WHRIA | 2016.08.26 | 17 |
1710 | Visual Studio 설치후 Excel 2002 (XP) 종료시 에러 문제 | WHRIA | 2015.11.20 | 21 |
1709 | headless PC 를 위한 dummy plug in 을 구입해서 달다. | WHRIA | 2015.11.22 | 21 |
1708 | XP shutdown 시 강제종료 시키기 | WHRIA | 2016.08.16 | 21 |
1707 | XE 에 tinymce 에디터를 달다. | WHRIA | 2015.11.22 | 22 |
1706 | USB 에뮬레이션 램디스트 imdisk | WHRIA | 2016.09.02 | 27 |
1705 | 학술저널 받는법 | WHRIA | 2015.11.30 | 28 |
1704 | imbalanced dataset | WHRIA | 2018.12.26 | 28 |
1703 | raid monitor | WHRIA | 2019.12.15 | 31 |
1702 | 지급명세서 | WHRIA | 2015.10.14 | 32 |