启用查询缓存的正确方法是什么? [英] What is the correct way to enable query cache?

查看:102
本文介绍了启用查询缓存的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于文档,不支持超级特权,这意味着那下面的查询:

Based on the documentation, the super privilege is not supported, which means that the following query:

SET GLOBAL query_cache_size = 1000000;

产生错误消息

访问被拒绝;您需要(至少其中一种)SUPER权限才能进行此操作

Access denied; you need (at least one of) the SUPER privilege(s) for this operation

,并且不允许我们设置查询缓存的大小.

and does not allow us to set the query cache size.

完成任务的正确方法是什么?

What's the correct way to accomplish the task?

推荐答案

正如mhalt所暗示的,有充分的理由不使用查询缓存:

As mhalt hints at, there is a good reason not to use the query cache:

  • 您应该使用InnoDB而不是MyISAM,因为MyISAM对于云环境而言不够健壮.
  • InnoDB已将缓存内置为缓冲池的一部分.这会缓存单个数据页面,而不是整个结果集.
  • 缓冲池通常为查询缓存提供高级缓存:1)写入后不会刷新该缓存2)可以使用相同的缓存条目来服务多个不同的查询3)如果活动集大于,它支持部分缓存可用的内存.
  • 查询缓存优越的唯一工作负载是非常的写入率很低,并且几乎所有查询都是完全相同的.
  • 因此,通过最大化分配给缓冲池而不是查询缓存的RAM来优化Cloud SQL.
  • You should be using InnoDB rather than MyISAM, as MyISAM is not robust enough for the cloud environment.
  • InnoDB has built in caching as part of it's buffer pool. This caches individual pages of data, rather than entire result sets.
  • The buffer pool generally provides superior caching to the query cache: 1) it does not get flushed after writes 2) multiple different queries can be served using the same cache entries 3) it supports partial caching if the active set is larger than available ram.
  • The only workload where the query cache is superior is if you have a very low write rate and almost all your queries are exactly the same.
  • For this reason Cloud SQL is optimized by maximizing RAM allocated to the buffer pool instead of having a query cache.

这篇关于启用查询缓存的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆