PostgreSQL 10.0 preview sharding增强 - 支持异步, 多节点并行

简介:

标签

PostgreSQL , 10.0 , sharding 增强


背景

PostgreSQL 10.0的sharding增强,比如聚合函数的下推算一个。

现在又带来了一个核武器级别的增强,postgres_fdw的异步化调用。

为什么说是核武器级别的呢,比如你有16个sharding节点(对应postgres_fdw的16个库),10.0以前,如果我需要执行一个QUERY涉及到所有的sharding节点时,每个sharding节点是串行执行的然后append结果。

10.0开始,会变成异步化执行,也就是可以并行执行,然后append结果再往下个NODE走。

这样效率会大大提高。

+Asynchronous Execution  
+----------------------  
+  
+In certain cases, it's desirable for a node to indicate that it cannot  
+return any tuple immediately but may be able to do at a later time.  This  
+might either because the node is waiting on an event external to the  
+database system, such as a ForeignScan awaiting network I/O, or because  
+the node is waiting for an event internal to the database system - e.g.  
+one process involved in a parallel query may find that it cannot progress  
+a certain parallel operation until some other process reaches a certain  
+point in the computation.  A process which discovers this type of situation  
+can always handle it simply by blocking, but this may waste time that could  
+be spent executing some other part of the plan where progress could be  
+made immediately.  This is particularly likely to occur when the plan  
+contains an Append node.  
+  
+To use asynchronous execution, a node must first request a tuple from an  
+async-capable child node using ExecAsyncRequest.  Next, it must execute  
+the asynchronous event loop using ExecAsyncEventLoop; it can avoid giving  
+up control indefinitely by passing a timeout to this function, even passing  
+-1 to poll for events without blocking.  Eventually, when a node to which an  
+asynchronous request has been made produces a tuple, the requesting node  
+will receive a callback from the event loop via ExecAsyncResponse. Typically,  
+the ExecAsyncResponse callback is the only one required for nodes that wish  
+to request tuples asynchronously.  
+  
+On the other hand, nodes that wish to produce tuples asynchronously  
+generally need to implement three methods:  
+  
+1. When an asynchronous request is made, the node's ExecAsyncRequest callback  
+will be invoked; it should use ExecAsyncSetRequiredEvents to indicate the  
+number of file descriptor events for which it wishes to wait and whether it  
+wishes to receive a callback when the process latch is set. Alternatively,  
+it can instead use ExecAsyncRequestDone if a result is available immediately.  
+  
+2. When the event loop wishes to wait or poll for file descriptor events and  
+the process latch, the ExecAsyncConfigureWait callback is invoked to configure  
+the file descriptor wait events for which the node wishes to wait.  This  
+callback isn't needed if the node only cares about the process latch.  
+  
+3. When file descriptors or the process latch become ready, the node's  
+ExecAsyncNotify callback is invoked.  

这个patch的讨论,详见邮件组,本文末尾URL。

PostgreSQL社区的作风非常严谨,一个patch可能在邮件组中讨论几个月甚至几年,根据大家的意见反复的修正,patch合并到master已经非常成熟,所以PostgreSQL的稳定性也是远近闻名的。

参考

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

https://www.postgresql.org/message-id/flat/CA+TgmoaXQEt4tZ03FtQhnzeDEMzBck+Lrni0UWHVVgOTnA6C1w@mail.gmail.com#CA+TgmoaXQEt4tZ03FtQhnzeDEMzBck+Lrni0UWHVVgOTnA6C1w@mail.gmail.com

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍如何基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
消息中间件 存储 关系型数据库
PostgreSQL技术大讲堂 - 第33讲:并行查询管理
PostgreSQL从小白到专家,技术大讲堂 - 第33讲:并行查询管理
947 1
|
关系型数据库 大数据 PostgreSQL
PostgreSQL16-新特性-并行聚合
PostgreSQL16-新特性-并行聚合
537 0
|
SQL 弹性计算 关系型数据库
PostgreSQL 12 preview - CTE 增强,支持用户语法层控制 materialized 优化
标签 PostgreSQL , CTE , materialized , not materialized , push down 背景 PostgreSQL with 语法,能跑非常复杂的SQL逻辑,包括递归,多语句物化计算等。 在12以前的版本中,WITH中的每一个CTE(common table express),都是直接进行物化的,也就是说外层的条件不会推到CTE(物化节点)里
1515 0
|
存储 SQL Oracle
AnalyticDB PostgreSQL 7.0 支持存储过程(CREATE PROCEDURE)特性
AnalyticDB PostgreSQL 7.0 新增了存储过程功能的支持,让用户在使用ADB PG时能够更方便高效地开发业务,并能够更好地兼容Oracle等传统数仓的业务。
894 1
AnalyticDB PostgreSQL 7.0 支持存储过程(CREATE PROCEDURE)特性
|
SQL 存储 算法
PostgreSQL并行HashJoin解读
PostgreSQL并行HashJoin解读
PostgreSQL并行HashJoin解读
|
存储 SQL Oracle
10 PostgreSQL 表级复制-物化视图篇, 支持异地,异构如 Oracle 到 pg 的物化视图|学习笔记
快速学习10 PostgreSQL 表级复制-物化视图篇,支持异地,异构如 Oracle 到 pg 的物化视图
10 PostgreSQL 表级复制-物化视图篇, 支持异地,异构如 Oracle 到 pg 的物化视图|学习笔记
|
SQL 并行计算 关系型数据库
Citus 分布式 PostgreSQL 集群 - SQL Reference(SQL支持和变通方案)
Citus 分布式 PostgreSQL 集群 - SQL Reference(SQL支持和变通方案)
409 0
|
弹性计算 关系型数据库 数据库
PostgreSQL 如何让心跳永远不死,支持半同步自动同步、异步升降级 - udf 心跳
标签 PostgreSQL , 同步 , 半同步 , 流复制 , 心跳 , 自动降级 , 自动升级 , dblink , 异步调用 背景 在心跳时,通过自定义UDF,实现心跳永远不被堵塞,并且支持更加当前的配置自动的进行同步、异步模式的升降级。实现半同步的功能。 UDF输入 1、优先模式(同步、异步) 2、同步等待超时时间 当优先为同步模式时,假设当前为同步配置,如果备库异常导致
2326 0
|
弹性计算 关系型数据库 数据库连接
PostgreSQL 12 preview - Move max_wal_senders out of max_connections for connection slot handling
标签 PostgreSQL , max_wal_senders , max_connections , sorry, too many clients already 背景 如果你需要使用PG的流复制,上游节点的max_wal_senders参数,用来限制这个节点同时最多可以有多少个wal sender进程。 包括逻辑复制、物理复制、pg_basebackup备份等,只要是使用stre
554 0
|
弹性计算 安全 关系型数据库
PostgreSQL 12 preview - 可靠性提升 - data_sync_retry 消除os层write back failed status不可靠的问题
标签 PostgreSQL , data_sync_retry , write back , retry , failed status 背景 有些OS系统,对fsync的二次调用不敏感,因为OS层可能有自己的CACHE,如果使用了buffer write,并且出现write back failed的情况,有些OS可能在下次fsync时并不能正确的反馈fsync的可靠性与否。(因为这个B
798 0

相关产品

  • 云原生数据库 PolarDB
  • 云数据库 RDS PostgreSQL 版
  • 推荐镜像

    更多