博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
安装postgresQL Query Cache
阅读量:2395 次
发布时间:2019-05-10

本文共 1694 字,大约阅读时间需要 5 分钟。

 为了提高公司postgreSQL的读能力,需要加一个Query Cache,目前网上有一个安装资料,这总结下安装和使用的简单方式。

这里给出网上已有的架构图:

现在都是扩展名为rpm的文件,我是在linux(64位)的机器上装,下载了4个相关包如下:

uqc-libevent-1.4.14b-1.x86_64.rpm

uqc-libmemcached-0.43-1.x86_64.rpm
uqc-memcached-1.4.5-1.x86_64.rpm
uqc-querycache-20110223-1.x86_64.rpm

安装是有顺序的,uqc-libmemcached-0.43-1.x86_64.rpm依赖于uqc-memcached-1.4.5-1.x86_64.rpm的。

使用命令:

rpm -ivh *.rpm

安装,默认的安装目录如图:

 进入到etc目录下,有两个文件:pqcd.conf 和pqcd_hba.conf。前者是Query Cache的配置信息,后者是设置远程登录验证配置信息。

启动pqcd:

/opt/uptime/querycache/bin/pqcd

关闭pqcd:

/opt/uptime/querycache/bin/pqcd stop

 

如何使用Query Cache,登录命令就是:

psql -U postgres test -p 9999

注意:登录时需要加上端口号(9999是Query Cache的默认端口号,在配置文件pqcd.conf里),这样才使用到Query Cache的功能。

然后,按照官方的例子操作,相关SQL语句即可。为了方便我转过来了。

Add as a comment at the beginning of SELECT statements

/* cache:refresh */ select * from ……

-<slash> <asterrisk> <space> <hint> <space> <asterisk> <slash>

 

cache:on (default in Active cache mode)

--Looks at the cache first. If not found, then executes on the backend, and puts the result into the cache.

 

cache:off(default in Passive cache mode)

--Doesn't  look at the cache first. Executes on the backend, and doesn't puts the result into the cache.

 

cache:refresh

--Doesn't look at the cache first. Executes on the backend,and puts the result into the cache.

 

cache:expire

--Invalidates query cache for specified statement.(Not implemented yet)

 

cache:expireall

--Invalidates all query cache.(Not implemented yet)

 

这里使用cache的时候要注意就是查询的结果已经缓存在Cache了,这时数据库里的数据被更新后,不会与Query Cache同步(即still an old value in the cache)。

这时如果是需要实时同步的话,是需要主动使用cache:refresh的select方式,重新将数据加载到cache里。

不过在pqcd.conf里,也有一个属性query_cache_expiration表示The timeout value for query cache expiration (in seconds, default is 30).

 

转载地址:http://cpzob.baihongyu.com/

你可能感兴趣的文章
UVA100 The 3n + 1 problem
查看>>
hdu1754 I Hate It
查看>>
hdu 1166 敌兵布阵(求区间的和,单节点更新)
查看>>
hiho一下 第四十四周 题目1 : 博弈游戏·Nim游戏
查看>>
poj2299 Ultra-QuickSort(线段树计数问题)
查看>>
hdu4565 So Easy!(矩阵快速幂)
查看>>
poj2528 Mayor's posters(线段树,离散化)
查看>>
线段树多lazy-tag(两个)
查看>>
hdu4578(三个更新操作,三个求值操作)
查看>>
并查集(初级)小结
查看>>
Treap
查看>>
相似图片搜索——感知哈希算法
查看>>
编译原理 词法分析
查看>>
计算机系统结构 计算机指令集结构
查看>>
计算机系统结构 输入/输出系统
查看>>
信息安全技术及应用 常规加密技术
查看>>
02-线性结构1 两个有序链表序列的合并
查看>>
HDU 1080 DP LCS
查看>>
HDU 3308 线段树+区间合并
查看>>
ASP.NET 入手页面控件及事件触发
查看>>