MYSQL Query Cache

Source: Internet
Author: User

Query cache:

The result of a SELECT statement is cached, and the next time the same SELECT statement is run, the data can be returned directly, skipping parsing, execution, and optimization phases.

1, the query cache will track the tables involved in the query, if the table changes, the relevant cache will be invalidated.

2, query slow whether hit, is based on the SELECT statement or according to the hash value of the select to be determined.

Example:

(1) Select X from Table_a; ---hash----> 5

(2) Select X

from Table_a; ---hash-----> 9

These two SELECT statements seem to have the same logic in humans, but MySQL doesn't think so, and it thinks the two are different.

The reason is that the first statement has only one row and the second has two rows. Even one more space it will say is not the same, it is the same or not

In terms of the hash value. The hash value is also associated with the location of the cache table, so the second select does not have a way to use the first cache.

A consistent writing style speeds up the query.

3. When the query includes any indeterminate data, it will not be cached. If the inclusion of new (), current_date ();

4, the cache is based on the SELECT statement, and only just received the SQL statement to check if there is a corresponding cache.

So the stored procedure and subquery are out of the way.

Summarize:

It is not a ' silver bullet ', for example, if the table is updated or inserted, the previous cache is useless. Oh, hell, yes. A table corresponding to the cache general

More than one. Even if this is the case, most of the data can improve performance.

MYSQL Query Cache

Related Article

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.