Should I sacrifice my innodb_buufer_pool _size/RAM

2019-03-01 02:44发布

I have a 16GB dedicated Mysql server database.My innodb_buffer_pool_size is set to around 11GB ,i am implementing query cache in my system ,which has a size of 80mb. From where should i make this space ,innodb_buffer_pool_size or RAM ?

2条回答
叛逆
2楼-- · 2019-03-01 03:20

NO. The Query cache runs out of steam after perhaps 80MB -- it spends more an more time pruning entries.

I would suggest that over 90% of production systems do (or should) turn off the QC completely.

Keep in mind that every write to a table purges all entries in the QC for that table.

11G on a 16GB dedicated server is a good number for innodb_buffer_pool_size.

查看更多
狗以群分
3楼-- · 2019-03-01 03:27

Back in Jun 2014 I answered https://dba.stackexchange.com/questions/66774/why-query-cache-type-is-disabled-by-default-start-from-mysql-5-6/66796#66796

In that post, I discussed how InnoDB micromanages changes between the InnoDB Buffer Pool and the Query Cache.

NOT USING THE QUERY CACHE

The simplest answer would be to just disable the query cache, but there is a catch: You must set both query_cache_size and query_cache_type to zero(0).

If you don't set query_cache_type to zero(0), the micromanagement of changes still occurs. This is verified by what the Paragraph 8 of the MySQL Documentation "Query Cache Configuration" says

If query_cache_size is 0, you should also set query_cache_type variable to 0. In this case, the server does not acquire the query cache mutex at all, which means that the query cache cannot be enabled at runtime and there is reduced overhead in query execution.

USING THE QUERY CACHE

If you really wish to use the Query Cache, then you need to study your data. Basically, you need to know the size of your results. You would then set query_cache_limit and query_cache_min_res_unit to accommodate the average size result set as well as the maximum size result set.

As an alternative, you can enable the Query Cache globally but disable its use from your DB Session as stated in Paragraph 9:

Setting the GLOBAL query_cache_type value determines query cache behavior for all clients that connect after the change is made. Individual clients can control cache behavior for their own connection by setting the SESSION query_cache_type value. For example, a client can disable use of the query cache for its own queries like this:

mysql> SET SESSION query_cache_type = OFF;

YOUR ACTUAL QUESTION

The Query Cache, InnoDB Buffer Pool, Per Connection Threads (See my post https://dba.stackexchange.com/questions/16969/how-costly-is-opening-and-closing-of-a-db-connection/16973#16973), and OS all compete for RAM.

When looking at just the Query Cache and the InnoDB Buffer Pool, you need to see how much space is free in the InnoDB Buffer Pool after MySQL has been running for days or weeks.

You can run this the query

SELECT variable_value / 64 free_mb
FROM information_schema.global_status
WHERE variable_name='Innodb_buffer_pool_pages_free';

This will tell you how much you can lower the InnoDB Buffer Pool. You could then increase the Query Cache by that size. If this query returns less that 1024, it is probably not worth the effort. You will either have get the additional space from RAM or just go with disabling the Query Cache.

查看更多
登录 后发表回答