标签

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的稳定性也是远近闻名的。

参考

https://commitfest.postgresql.org/13/1058/

https://www.postgresql.org/message-id/flat/20170228142509.GA19777@e733.localdomain#20170228142509.GA19777@e733.localdomain

PostgreSQL 10.0 preview 性能增强 - 分区表性能增强(plan阶段加速)的更多相关文章

  1. PostgreSQL 10.0 preview 功能增强

    https://yq.aliyun.com/users/1384833841157402?spm=5176.100239.blogrightarea51131.3.yI7e9d

  2. PostgreSQL 10.0 压缩版的 pgAdmin 不能用的问题

    PostgreSQL终于发布10.0正式版了!下载压缩版的更新了一下本机的版本,然后打开pgAdmin的时候总是报错“The application server could not be conta ...

  3. VMWare Workstation 10.0 Preview CN

    What's New in the VMware Workstation Technology Preview July 2013 The VMware Workstation team is exc ...

  4. mono 3.10.0 正式发布:性能进一步改进

    Mono是Xamarin资助的一个项目,是微软的.NET框架的开源实现.它使得使用C#.F#和其他.NET语言进行跨平台开发成为可能.Xamarin在Mono之上构建了跨平台开发工具以及像Xamari ...

  5. PHP从PHP5.0到PHP7.1的性能全评测

    本文是最初是来自国外的这篇:PHP Performance Evolution 2016, 感谢高可用架构公众号翻译成了中文版, 此处是转载的高可用架构翻译后的文章从PHP 5到PHP 7性能全评测( ...

  6. PHP的性能演进(从PHP5.0到PHP7.1的性能全评测)

    本文是最初是来自国外的这篇:PHP Performance Evolution 2016, 感谢高可用架构公众号翻译成了中文版, 此处是转载的高可用架构翻译后的文章从PHP 5到PHP 7性能全评测( ...

  7. 从PHP5.0到PHP7.1的性能全评测

    本文是最初是来自国外的这篇:PHP Performance Evolution 2016, 感谢高可用架构公众号翻译成了中文版, 此处是转载的高可用架构翻译后的文章从PHP 5到PHP 7性能全评测( ...

  8. mysql分区表之四:分区表性能

    一,      分区概念  分区允许根据指定的规则,跨文件系统分配单个表的多个部分.表的不同部分在不同的位置被存储为单独的表.MySQL从5.1.3开始支持Partition. 分区和手动分表对比 手 ...

  9. 高性能Linux服务器 第10章 基于Linux服务器的性能分析与优化

    高性能Linux服务器 第10章    基于Linux服务器的性能分析与优化 作为一名Linux系统管理员,最主要的工作是优化系统配置,使应用在系统上以最优的状态运行.但硬件问题.软件问题.网络环境等 ...

随机推荐

  1. 页面静态化--Thymeleaf

    1.Thymeleaf简介 官方网站:https://www.thymeleaf.org/index.html Thymeleaf是用来开发Web和独立环境项目的现代服务器端Java模板引擎. Thy ...

  2. hadoop(学习)

                                                                                hadoop Hadoop是一个用于海量数据统计 ...

  3. 创建一个tar备份包

                                                                 创建一个tar备份包 2.1问题 本例要求使用tar工具完成以下备份任务: 创 ...

  4. Mysql大数据量问题与解决

    今日格言:了解了为什么,问题就解决了一半. Mysql 单表适合的最大数据量是多少? 我们说 Mysql 单表适合存储的最大数据量,自然不是说能够存储的最大数据量,如果是说能够存储的最大量,那么,如果 ...

  5. JAVA中的==和queals()的区别

    一.先来说说Java的基本数据类型和引用类型 八大基本数据类型:Byte,short,int,long,double,folat,boolean,char,其中占一个字节的是byte,short和ch ...

  6. ThinkPHP3.2.3发送微信模板消息

    一.开通模板消息功能 所有服务号都可以在功能->添加功能插件处看到申请模板消息功能的入口,但只有认证后的服务号才可以申请模板消息的使用权限并获得该权限:需要选择公众账号服务所处的2个行业,每月可 ...

  7. 30 HashSet

    /* * 使用HashSet存储字符串并遍历 * * Set的特点: * 无序(存储和读取的顺序可能不一样) * 不允许重复 * 没有整数索引 于List正好相反 */ public class Ha ...

  8. Spire.Cloud 私有化部署教程(二)- Ubuntu 18.04 系统

    本教程主要介绍如何在Ubuntu 18.04系统上实现Spire.Cloud私有化部署.CentOS 7系统部署请参考 这篇教程. 详细步骤如下: 一.环境配置 1.关闭防火墙 1)首先查看防火墙状态 ...

  9. c++缓冲区 vBufferChar.hpp

    //vbuffer_char.hpp //vov #ifndef V_BUFFER_CHAR_HPP #define V_BUFFER_CHAR_HPP #include <iostream&g ...

  10. ffmpeg 交叉编译 版本4.0.4

    touch run.sh chmod 755 run.sh ./run.sh run.sh #!/bin/sh ./configure \ --arch=aarch64 \ --cpu=armv8-a ...