Resolve Mysql Cache How to use memory _mysql

Source: Internet
Author: User

Let's say 2.
Opening the cache also brings overhead, mainly in terms of
Read cache must be checked before the query starts
If the query is cached, but not in the result set, saving the data after the result produces a certain amount of overhead
Writing to the cache as data can also incur overhead

Some cases query cache will not be cached, even if you use Sql_cache can not cache
Mainly a few
User-defined functions are referenced
User-defined variables are referenced
To use the survival process.
The query contains some real-time system functions, such as now
A temporary table is referenced

Although it says that caching brings some overhead,
But caching is still important for MySQL.
There are more advantages than disadvantages

Here's how the MySQL cache uses memory
query-Cached memory pools are divided into variable sized blocks, each of which is quick to know its own size, pointing to the previous and last logical block and the physical block pointer, The physical memory that the query cache uses when the server starts up, the memory pool starts how Hi wants a quick, her size is configured to cache size minus the 40KB size it needs. Each time the query results are cached, a cache block is allocated for the query results, but the server cannot estimate the size of the result that needs to be cached, at least greater than or equal to Query_cache_min_res_unit, and the server does not cache the resulting final results once it is allocated, and then the cache is sent to the client , it creates a cache so that the cache is not wasted or inadequate when allocated. Allocating memory blocks is slower because the server needs to check the list of available memory and find the right size to fit quickly, as a result, the server minimizes the number of allocations, and when caching results is needed, he constructs a block of at least the smallest size and places the result in a block if the block is full, but the data is not fully saved. Then a new block is generated and the data is saved, and when the data is saved, the server clips the data block if there are gaps in the data block, and merges the space into the remaining space, where it can produce fragments. By tightening, the fragmentation space can be incorporated into an effective data space.

for things like InnoDB, things can affect caching, because dirty data can invalidate other caches that reference this piece of data. This data will not be cached until the thing is committed or rolled back.
Query_cache_min_res_unit:the minimum size (in bytes) for blocks allocated by the query cache. The default value is 4096 (4KB)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.