T086ѧϰ�� | վ��ѧԺ | �����ĵ� | ���� | Ъ���� | IP��ַ��ѯ | �������� | ���ջ��� | �����ֵ� | ���ù��� | ������Ϣ��ѯ

MySQL Query Cache Ч�ʵļ���

�� �������ߣ������� ����ʱ�䣺2009-03-04 | ���壺�� �� С��
[����]Query Cache ���������ݿ����ܷ������зdz���Ҫ�����á� ���趨Ҳ�dz��򵥣�����Ҫ�������ļ�д�����У� query_cache_type �� query_cache _size������ MySQL �� query cache �dz��죡����һ�����У���ֱ�ӷ��͸��ͻ�...

Query Cache ���������ݿ����ܷ������зdz���Ҫ�����á�

���趨Ҳ�dz��򵥣�����Ҫ�������ļ�д�����У� query_cache_type �� query_cache _size������ MySQL �� query cache �dz��죡����һ�����У���ֱ�ӷ��͸��ͻ��ˣ���Լ������ CPU ʱ�䡣

��Ȼ���� SELECT �����Ի�������Ӱ���ģ����ǿ���ʹ�����е����ݹ��ڡ�һ�� UPDATE ���������IJ��ֱ��޸ģ������¶Ըñ����еĻ�������ʧЧ������ MySQL Ϊ��ƽ�����ܶ�û�в�ȡ�Ĵ�ʩ����Ϊ������ÿ�� UPDATE ��Ҫ�����޸ĵ����ݣ�Ȼ�󳷳����ֻ��彫���´����ĸ��Ӷ����ӡ�

 

query_cache_type 0 ������ʹ�û��壬 1 ����ʹ�û��壬2 ����������Ҫʹ�á�

���� 1 ����������Զ��Ч����������Ҫ���壬����Ҫʹ���������䣺

SELECT SQL_NO_CACHE * FROM my_table WHERE ...

��������Ϊ 2 ����Ҫ�������壬�������������䣺

SELECT SQL_CACHE * FROM my_table WHERE ...

�� SHOW STATUS ���Բ鿴������������

mysql> show status like 'Qca%';
+-------------------------+----------+
| Variable_name | Value |
+-------------------------+----------+
| Qcache_queries_in_cache | 8 |
| Qcache_inserts | 545875 |
| Qcache_hits | 83951 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 2343256 |
| Qcache_free_memory | 33508248 |
| Qcache_free_blocks | 1 |
| Qcache_total_blocks | 18 |
+-------------------------+----------+
8 rows in set (0.00 sec)

������Ҫ���������ʣ���Ҫ֪��������ִ���˶��� SELECT ���䣺

mysql> show status like 'Com_sel%';
+---------------+---------+
| Variable_name | Value |
+---------------+---------+
| Com_select | 2889628 |
+---------------+---------+
1 row in set (0.01 sec)

�ڱ����У� MySQL ������ 2,889,628 ����ѯ�е� 83,951 �������� INSERT ����ֻ�� 545,875 �������ˣ��������ߵĺͺ�280�����ܲ�ѯ�����кܴ����࣬���ˣ�����֪������ʹ�õĻ��������� 2 ��


���������� 1 �������У� Qcache_hits ����ֵ��ԶԶ���� Com_select ��

  • ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
  • �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
������ѯ Health Check Gulangyu
© 2017 T086ѧϰ�� - T086.com(ԭitlearner.com)
RunTime:5.84ms QueryTime:7