![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
postgres
yibei8811
这个作者很懒,什么都没留下…
展开
-
postgresql中position函数相关性能探究~
起因: postgresql中position函数提供,从头查找返回第一个匹配到字符串的下标。 而我需要返回从后向前查找第一个匹配到的坐标,但是postgressql并未提供相关函数,所以自己写了如下代码提供相关功能:CREATE OR REPLACE FUNCTION lastindexof(text, character) RETURNS i原创 2015-01-14 15:17:31 · 8998 阅读 · 0 评论 -
工作总结数据库集群
我使用数据库集群的时间并不算太长,我尽量将自己的一些感悟和心得总结下来。首先数据库集群解决TB级的数据量就不得了,上了PB级,理论上还是nosql更好。基于postgres常用的集群解决方案有以下几种postgres-xc,postgres-xl,pl/proxy,greenplum和postgres-x2postgres-xc:浙江移动在用,貌似bug有不少,据传把postgres-xc原创 2015-10-05 18:10:05 · 429 阅读 · 0 评论 -
postgres base目录实践性分析
postgres安装后下面有个base目录,目录下的文件通常是一串数字组成,这串数字是什么呢?他是如何和表对应关联起来的?SQL操作create table test(c int4);select oid,* from pg_class where relname ='test'"oid";"relname";"relnamespace";"reltype";"reloftype"原创 2015-08-06 16:09:53 · 1655 阅读 · 0 评论 -
postgres row_number()分析
今天看唐成书看到一段语句不明白什么意思select row_number() over (partition by id),ctid from t以前依稀记得 见过 over( partiontion by xxx) 类似的语法,但是工作中还未发现有什么sql会写不出来,以为自己用不到,居然没太关注。不过书上别人这么写了,要是看不懂还是显得略微丢人了。所以细细分析如下。执行脚本原创 2015-06-15 14:14:19 · 1746 阅读 · 0 评论 -
postgres 引起oom问题的 explain 分析。
work_mem设置为2G!一共16张表采用Merge join方式。Sort Method: 一共使用到3种分别为 并分别统计他们的width!Sort Method: quicksort Memory:93,37,77,61,101,45,61,53Sort Method: external sort Disk: 117,125,125,117Sort Method原创 2015-06-10 14:43:09 · 900 阅读 · 0 评论 -
postgres OOM相关问题
测试一组copy数据数据量比较大,调整work_mem为8G连续失败多次。查找原因一直没找到。结果是触发linux的机制Jun 9 15:54:04 R720 kernel: Out of memory: Kill process 21275 (postgres) score 647 or sacrifice childJun 9 15:54:04 R720 kerne原创 2015-06-09 18:09:21 · 370 阅读 · 0 评论 -
centos下postgres源码编译
基于唐成的postgresSQL相同操作不在累述。选择CentOS-7.0-1406-x86_64-Everything.iso。安装版本选择最后一个加上开发工具包。安装完成配置ip网络后cd /etc/sysconfig/network-scriptsvi ifcfg-enp2s0 ONBOOT=yes【编辑为此内容 保证开机连接网卡】安装postgres原创 2015-06-09 14:52:40 · 294 阅读 · 0 评论 -
postgresql 异步流复制
上篇http://blog.csdn.net/yibei8811/article/details/46650925主库配置wal_level必须为hot_standby其他至pg_basebackup 没有区别备库配置修改postgresql.confhot_standby=onrecovery.conf 默认生成的就可以用,从配置文件中看出,上一步的归档估原创 2015-06-26 16:29:34 · 330 阅读 · 0 评论 -
postgresql归档备份
主库配置修改pg_hba.conflocal replication postgres trusthost replication postgres 127.0.0.1/32 trusthost replication postgres :原创 2015-06-26 16:11:06 · 1079 阅读 · 0 评论 -
postgres中pg_depend表实验性分析
名字类型引用描述classidoidpg_class.oid有倚赖对象所在系统表的 OIDobjidoid任意 OID 属性指定的依赖对象的 OIDobjsubidint4 对于表字段,这个是该属性的字段数(objid和classid 引用表本身)原创 2015-06-24 16:17:09 · 832 阅读 · 0 评论 -
一次有关pg_depend 错误处理
http://blog.csdn.net/yibei8811/article/details/46623253上篇算是比较详细的说明了pg_depend表的含义。本篇记录一次有关的问题处理。执行:drop schema public cascade出错返回:ERROR: cache lookup failed for relation 24662********** 错误 **原创 2015-06-24 17:19:53 · 1875 阅读 · 1 评论 -
postgresql pg_dump备份测试
pg_dump postgres --备份postgres库输出内容到屏幕pg_dump postgres -f 1.sql -- -f参数表示输出到1.sqlpg_dump postgres > 1.sql -- 使用shell ‘>’符号等效上面一行命令由于没有指定备份方式,原创 2015-06-23 17:49:03 · 521 阅读 · 0 评论 -
centos7下开机启动 postgres开机启动
#!/bin/bash# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES## It is highly advisable to create own systemd services or udev rules# to run scripts during boot instead of using this file.## In cons原创 2015-06-22 17:16:05 · 2543 阅读 · 0 评论 -
Centos7下systemctl status postgresql 命令相关研究
postgres有源码安装,yum安装,或者下载包自己rpm,安装方法众多。以前一台yum安装postgres的机器设置了 systemctl enable postgresql 这样postgresql就可以开机自启动了。我测试了源码安装,并不支持这个命令。可见,yum安装包偷偷的对systemctl命令进行了一些注册相关的操作?那么研究一下,执行[root@db222原创 2015-06-22 14:17:44 · 4424 阅读 · 0 评论 -
postgresql 日志配置
log_destination = 'csvlog' --csv模式输出logging_collector = on --收集日志打开log_directory = 'pg_log' --输出日期的陌路log_filename = 'postgresql-%u.log'原创 2015-06-18 16:09:55 · 436 阅读 · 0 评论 -
postgres执行计划 seqscan,indexscan,bitmapscan实验性分析
执行以下代码create table t1(c1 int4);insert into t1 select generate_series(1,10);explain analyze select * from t1 where c1 =4显示为"Seq Scan on t1 (cost=0.00..40.00 rows=12 width=4) (actual time=0.007.原创 2015-06-16 13:09:55 · 9932 阅读 · 2 评论 -
postgres 递归测试
一次偶然和别人交流问题,需要用到递归函数,做一次blog记录。准备数据如下:create table tt( t1 text, t2 text, t3 text, t4 text ) insert into tt values('JS1','JS4','三通','直线'); insert into tt values('JS1','JS2','三通','阀门'); ins原创 2015-01-15 17:12:27 · 359 阅读 · 0 评论 -
mysql 实现 generate_series()
我需要生成一个序列,postgresql的generate_series()非常方便。mysql却没有对应的函数。检索相关资料,有篇文章引起了我的注意,老外们的思维还是很厉害的。http://stackoverflow.com/questions/6870499/generate-series-equivalent-in-mysql通过以上思路,改写了一下,生成了我需要的序列。原创 2016-03-31 14:38:11 · 5028 阅读 · 0 评论