MySQL Query cache mechanism (2) _ MySQL

Source: Internet
Author: User
MySQL Query cache mechanism (2) bitsCN.com

+ --------------- + ------- +
8 rows in set (0.00 sec)

Mysql> select count (*) from animals;
+ ---------- +
| Count (*) |
+ ---------- +
| 6 |
+ ---------- +
1 row in set (0.00 sec)

Mysql> show status like 'qcache % ';
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Qcache_hits | 1 | -- indicates that the SQL statement is directly obtained in the cache and does not need to be parsed.
+ --------------- + ------- +
8 rows in set (0.00 sec)

Mysql> select count (*) from animals;
+ ---------- +
| Count (*) |
+ ---------- +
| 6 |
+ ---------- +
1 row in set (0.00 sec)

Mysql> select count (*) from animals;
+ ---------- +
| Count (*) |
+ ---------- +
| 6 |
+ ---------- +
1 row in set (0.00 sec)

Mysql> show status like 'qcache _ hits ';
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Qcache_hits | 3 | -- the preceding SQL statement is obtained directly from the cache.
+ --------------- + ------- +
1 row in set (0.00 sec)

Mysql> insert into animals select 9, 'testsds '; -- after data is inserted, all SQL caches related to the table will be cleared.
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

Mysql> select count (*) from animals;
+ ---------- +
| Count (*) |
+ ---------- +
| 7 |
+ ---------- +
1 row in set (0.00 sec)

Mysql> show status like 'qcache _ hits ';
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Qcache_hits | 3 | -- or equal to 3, indicating that the previous SQL statement was not directly obtained from the cache.
+ --------------- + ------- +
1 row in set (0.00 sec)

Mysql> select count (*) from animals;
+ ---------- +
| Count (*) |
+ ---------- +
| 7 |
+ ---------- +
1 row in set (0.00 sec)

Mysql> show status like 'qcache _ hits ';
+ --------------- + ------- +
| Variable_name | Value |
+ --------------- + ------- +
| Qcache_hits | 4 |
+ --------------- + ------- +
1 row in set (0.00 sec)

BitsCN.com

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.