Skip to content

mariaDB cache 설정

2019.08.04 16:59

WHRIA 조회 수:271

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

번호 제목 글쓴이 날짜 조회 수
1686 Mediainfo 를 이용해서 날짜 알아내기 WHRIA 2012.12.20 10405
1685 마음이 편해지는 그림 file WHRIA 2007.02.18 10356
1684 마음의 결정이 끝났습니다. WHRIA 2009.11.20 10334
1683 애드센스 수입금 - 48만원 WHRIA 2010.12.28 10277
1682 MedicalPhoto moved to http://medicalphoto.org WHRIA 2008.06.20 10104
1681 rAthena [1] file WHRIA 2016.06.26 10074
1680 어려운 결정 WHRIA 2008.10.11 10019
1679 피얼룩 지우기 WHRIA 2012.05.26 9956
1678 Trader file WHRIA 2009.11.17 9882
1677 승석이 홈페이지입니다. 한승석 2000.05.29 9874
1676 피부과 홈페이지 제작중 WHRIA 2009.11.11 9712
1675 일본으로 workshop 초청이 왔는데 못가게 되었다. [1] WHRIA 2009.11.23 9632
1674 간판 제작 업체 WHRIA 2009.10.31 9558
1673 인플레이션인가 디플레이션인가 WHRIA 2009.06.21 9546
1672 돌사진 WHRIA 2011.03.21 9446

Powered by Xpress Engine / Designed by Sketchbook

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소