PostgreSQL 10.0 preview 性能增强 - 分区表性能增强(plan阶段加速)
标签
PostgreSQL , 10.0 , 分区表 , 子表 , 元信息搜索性能增强
背景
PostgreSQL 10.0 增强了分区表的子表搜索性能,对于涉及分区表包含子表特别多的QUERY,可以提升性能。
性能分析
get_tabstat_entry, find_all_inheritors成为主要瓶颈。
Hello.
I decided to figure out whether current implementation of declarative
partitioning has any bottlenecks when there is a lot of partitions. Here
is what I did [1].
-- init schema
\timing on
CREATE TABLE part_test (pk int not null, k int, v varchar(128)) PARTITION BY RANGE(pk);
do $$
declare
i integer;
begin
for i in 1 .. 10000
loop
raise notice 'i = %', i;
execute ('CREATE TABLE part_test_' || i ||
' PARTITION OF part_test FOR VALUES FROM (' ||
(1 + (i-1)*1000) || ') to (' || ( (i * 1000) + 1) || ');'
);
end loop;
end $$;
-- fill tables with some data
do $$
declare
i integer;
begin
for i in 1 .. 100*1000
loop
raise notice 'i = %', i;
execute ('insert into part_test values ( ceil(random()*(10000-1)*1000), ceil(random()*10000*1000), '''' || ceil(random()*10000*1000) );');
end loop;
end $$;
Then:
# 2580 is some pk that exists
echo 'select * from part_test where pk = 2580;' > t.sql
pgbench -j 7 -c 7 -f t.sql -P 1 -T 300 eax
`perf top` showed to bottlenecks [2]. A stacktrace for the first one
looks like this [3]:
0x00000000007a42e2 in get_tabstat_entry (rel_id=25696, isshared=0 '\000') at pgstat.c:1689
1689 if (entry->t_id == rel_id)
#0 0x00000000007a42e2 in get_tabstat_entry (rel_id=25696, isshared=0 '\000') at pgstat.c:1689
#1 0x00000000007a4275 in pgstat_initstats (rel=0x7f4af3fd41f8) at pgstat.c:1666
#2 0x00000000004c7090 in relation_open (relationId=25696, lockmode=0) at heapam.c:1137
#3 0x00000000004c72c9 in heap_open (relationId=25696, lockmode=0) at heapam.c:1291
(skipped)
And here is a stacktrace for the second bottleneck [4]:
0x0000000000584fb1 in find_all_inheritors (parentrelId=16393, lockmode=1, numparents=0x0) at pg_inherits.c:199
199 forboth(lo, rels_list, li, rel_numparents)
#0 0x0000000000584fb1 in find_all_inheritors (parentrelId=16393, lockmode=1, numparents=0x0) at pg_inherits.c:199
#1 0x000000000077fc9f in expand_inherited_rtentry (root=0x1badcb8, rte=0x1b630b8, rti=1) at prepunion.c:1408
#2 0x000000000077fb67 in expand_inherited_tables (root=0x1badcb8) at prepunion.c:1335
#3 0x0000000000767526 in subquery_planner (glob=0x1b63cc0, parse=0x1b62fa0, parent_root=0x0, hasRecursion=0 '\000', tuple_fraction=0) at planner.c:568
(skipped)
The first one could be easily fixed by introducing a hash table
(rel_id -> pgStatList entry). Perhaps hash table should be used only
after some threshold. Unless there are any objections I will send a
corresponding patch shortly.
I didn't explored the second bottleneck closely yet but at first glance
it doesn't look much more complicated.
Please don't hesitate to share your thoughts regarding this matter.
[1] http://afiskon.ru/s/e3/5f47af9102_benchmark.txt
[2] http://afiskon.ru/s/00/2008c4ae66_temp.png
[3] http://afiskon.ru/s/23/650f0afc89_stack.txt
[4] http://afiskon.ru/s/03/a7e685a4db_stack2.txt
--
Best regards,
Aleksander Alekseev
这个patch的讨论,详见邮件组,本文末尾URL。
PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。
参考
PostgreSQL 10.0 preview 性能增强 - 分区表性能增强(plan阶段加速)的更多相关文章
- PostgreSQL 10.0 preview 功能增强
https://yq.aliyun.com/users/1384833841157402?spm=5176.100239.blogrightarea51131.3.yI7e9d
- PostgreSQL 10.0 压缩版的 pgAdmin 不能用的问题
PostgreSQL终于发布10.0正式版了!下载压缩版的更新了一下本机的版本,然后打开pgAdmin的时候总是报错“The application server could not be conta ...
- VMWare Workstation 10.0 Preview CN
What's New in the VMware Workstation Technology Preview July 2013 The VMware Workstation team is exc ...
- mono 3.10.0 正式发布:性能进一步改进
Mono是Xamarin资助的一个项目,是微软的.NET框架的开源实现.它使得使用C#.F#和其他.NET语言进行跨平台开发成为可能.Xamarin在Mono之上构建了跨平台开发工具以及像Xamari ...
- PHP从PHP5.0到PHP7.1的性能全评测
本文是最初是来自国外的这篇:PHP Performance Evolution 2016, 感谢高可用架构公众号翻译成了中文版, 此处是转载的高可用架构翻译后的文章从PHP 5到PHP 7性能全评测( ...
- PHP的性能演进(从PHP5.0到PHP7.1的性能全评测)
本文是最初是来自国外的这篇:PHP Performance Evolution 2016, 感谢高可用架构公众号翻译成了中文版, 此处是转载的高可用架构翻译后的文章从PHP 5到PHP 7性能全评测( ...
- 从PHP5.0到PHP7.1的性能全评测
本文是最初是来自国外的这篇:PHP Performance Evolution 2016, 感谢高可用架构公众号翻译成了中文版, 此处是转载的高可用架构翻译后的文章从PHP 5到PHP 7性能全评测( ...
- mysql分区表之四:分区表性能
一, 分区概念 分区允许根据指定的规则,跨文件系统分配单个表的多个部分.表的不同部分在不同的位置被存储为单独的表.MySQL从5.1.3开始支持Partition. 分区和手动分表对比 手 ...
- 高性能Linux服务器 第10章 基于Linux服务器的性能分析与优化
高性能Linux服务器 第10章 基于Linux服务器的性能分析与优化 作为一名Linux系统管理员,最主要的工作是优化系统配置,使应用在系统上以最优的状态运行.但硬件问题.软件问题.网络环境等 ...
随机推荐
- 为什么要学习Oracle技术?
为什么要学习Oracle技术? 众所周知,Oracle占据着企业数据库领域超过48.1%的市场份额,成为高端企业数据库软件的绝对领导者.随着时间的推移,企业数据库的规模不断扩大,富有经验的资深Orac ...
- 1007 Maximum Subsequence Sum (25 分)
1007 Maximum Subsequence Sum (25 分) Given a sequence of K integers { N1, N2, ..., NK }. A ...
- LinkedHashMap 与 HashMap 实现的区别
阅读前最好对 HashMap 的内部实现方式有一定了解 LinkedHashMap 继承自 HashMap 主要重写了一个节点类 LinkedHashMap.Entry,并维护一个头结点和尾节点 以及 ...
- SpringCloud(一)之我学 Eureka
1.常用注册中心 1).zookeeper:高一致性(多个节点的数据保持一致): 2).eureka:高可用(系统不能访问的时间很少): 3).consul:上诉两个方案的折中. 高可用:消灭单点故障 ...
- Git常用命令(二)
git clone + URL 获取该项目源代码 $ git log 回顾提交历史 $ git log -p -(数字) 用来显示每次提交的内容差异+(数字)表示看最近几条 $ git log --s ...
- 听说这个 IP 和子网掩码异常难算
IP地址格式 每个Internet主机或路由器都有IP地址.所有的IP地址包括网络号和主机号(就像是手机号,前几位是区号,后几位是序列号). 说明如下 A类地址用于主机数目非常多的网络.A类地址允许有 ...
- 通过简单的ajax验证是否存在已有的用户名
首先来说说我对ajax的理解:简单地来说就是在不重新刷新页面的情况下,实现数据的调用获得更新. 我在这里介绍的是要过jquery封装好的ajax,大家可以去了解一下使用原生的XMLHttpReques ...
- Linux网络安全篇,配置Yum源(一),本地Yum源
1.创建挂载目录 mkdir /mnt/cdrom 2.挂载软件源cdrom mount /dev/cdrom /mnt/cdrom/ 3.建立本地yum源资源文件夹 mkdir /usr/local ...
- Mybatis对象关系映射 one2one,one2many,many2many
MyBatis中的高级映射一般要借助select元素中的resultMap属性进行实现,通过此属性配置实现一对一,一对多等关系映射的实现 一对一映射:association 一对多映射:collect ...
- Python爬取抖音高颜值小视频
前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 有趣的python PS:如有需要Python学习资料的小伙伴可以加 ...