PostgreSQL 11 preview - Logical replication support for TRUNCATE

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
云原生数据库 PolarDB 分布式版,标准版 2核8GB
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

标签

PostgreSQL , 逻辑订阅 , TRUNCATE


背景

PostgreSQL 11 逻辑订阅支持insert, update, delete, truncate。

后期可能还会增加对DDL的支持,目前的DDL(包括对已有订阅表的结构修改,新增,删除表等操作)通过如下方法来支持:

《PostgreSQL 逻辑订阅 - DDL 订阅 实现方法》

支持TRUNCATE的PATCH如下

Logical replication support for TRUNCATE  
  
author	Peter Eisentraut <peter_e@gmx.net>	  
Sat, 7 Apr 2018 23:24:53 +0800 (11:24 -0400)  
committer	Peter Eisentraut <peter_e@gmx.net>	  
Sat, 7 Apr 2018 23:34:11 +0800 (11:34 -0400)  
commit	039eb6e92f20499ac36cc74f8a5cef7430b706f6  
tree	2cf52aeafb59917d5c7ed396acb6d86325b4a8b0	tree | snapshot  
parent	5dfd1e5a6696b271a2cdee54143fbc209c88c02f	commit | diff  
  
Logical replication support for TRUNCATE  
  
Update the built-in logical replication system to make use of the  
previously added logical decoding for TRUNCATE support.  Add the  
required truncate callback to pgoutput and a new logical replication  
protocol message.  
  
Publications get a new attribute to determine whether to replicate  
truncate actions.  When updating a publication via pg_dump from an older  
version, this is not set, thus preserving the previous behavior.  
  
Author: Simon Riggs <simon@2ndquadrant.com>  
Author: Marco Nenciarini <marco.nenciarini@2ndquadrant.it>  
Author: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>  
Reviewed-by: Petr Jelinek <petr.jelinek@2ndquadrant.com>  
Reviewed-by: Andres Freund <andres@anarazel.de>  
Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>  
WITH ( publication_parameter [= value] [, ... ] )  
  
This clause specifies optional parameters for a publication. The following parameters are supported:  
  
publish (string)  
  
This parameter determines which DML operations will be published by the new publication to the subscribers. The value is comma-separated list of operations. The allowed operations are insert, update, delete, and truncate. The default is to publish all actions, and so the default value for this option is 'insert, update, delete, truncate'.  
CREATE PUBLICATION insert_only FOR TABLE mydata  
    WITH (publish = 'insert');  
+                                         List of publications  
+        Name        |          Owner           | All tables | Inserts | Updates | Deletes | Truncates   
+--------------------+--------------------------+------------+---------+---------+---------+-----------  
+ testpib_ins_trunct | regress_publication_user | f          | t       | f       | f       | f  
+ testpub_default    | regress_publication_user | f          | f       | t       | f       | f  
 (2 rows)  
  
  
+                                         List of publications  
+        Name        |          Owner           | All tables | Inserts | Updates | Deletes | Truncates   
+--------------------+--------------------------+------------+---------+---------+---------+-----------  
+ testpib_ins_trunct | regress_publication_user | f          | t       | f       | f       | f  
+ testpub_default    | regress_publication_user | f          | t       | t       | t       | f  
 (2 rows)  
  
  
+                        Publication testpub_foralltables  
+          Owner           | All tables | Inserts | Updates | Deletes | Truncates   
+--------------------------+------------+---------+---------+---------+-----------  
+ regress_publication_user | t          | t       | t       | f       | f  
 (1 row)  
  
  
+                              Publication testpub3  
+          Owner           | All tables | Inserts | Updates | Deletes | Truncates   
+--------------------------+------------+---------+---------+---------+-----------  
+ regress_publication_user | f          | t       | t       | t       | t  
  
  
+                              Publication testpub4  
+          Owner           | All tables | Inserts | Updates | Deletes | Truncates   
+--------------------------+------------+---------+---------+---------+-----------  
+ regress_publication_user | f          | t       | t       | t       | t  

参考

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=039eb6e92f20499ac36cc74f8a5cef7430b706f6

https://www.postgresql.org/docs/devel/static/sql-createpublication.html

https://www.postgresql.org/docs/devel/static/sql-alterpublication.html

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
26天前
|
关系型数据库 分布式数据库 数据库
成都晨云信息技术完成阿里云PolarDB数据库产品生态集成认证
近日,成都晨云信息技术有限责任公司(以下简称晨云信息)与阿里云PolarDB PostgreSQL版数据库产品展开产品集成认证。测试结果表明,晨云信息旗下晨云-站群管理系统(V1.0)与阿里云以下产品:开源云原生数据库PolarDB PostgreSQL版(V11),完全满足产品兼容认证要求,兼容性良好,系统运行稳定。
|
1月前
|
关系型数据库 分布式数据库 数据库
PolarDB常见问题之数据库不能自己减少节点如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
1月前
|
缓存 关系型数据库 分布式数据库
PolarDB常见问题之数据库cpu突然飙高如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
2月前
|
关系型数据库 分布式数据库 数据库
阿里云PolarDB登顶2024中国数据库流行榜:技术实力与开发者影响力
近日,阿里云旗下的自研云原生数据库PolarDB在2024年中国数据库流行度排行榜中夺冠,并刷新了榜单总分纪录,这一成就引起了技术圈的广泛关注。这一成就源于PolarDB在数据库技术上的突破与创新,以及对开发者和用户的实际需求的深入了解体会。那么本文就来分享一下关于数据库流行度排行榜的影响力以及对数据库选型的影响,讨论PolarDB登顶的关键因素,以及PolarDB“三层分离”新版本对开发者使用数据库的影响。
74 3
阿里云PolarDB登顶2024中国数据库流行榜:技术实力与开发者影响力
|
1月前
|
关系型数据库 分布式数据库 数据库
PolarDB PostgreSQL版:Oracle兼容的高性能数据库
PolarDB PostgreSQL版是一款高性能的数据库,具有与Oracle兼容的特性。它采用了分布式架构,可以轻松处理大量的数据,同时还支持多种数据类型和函数,具有高可用性和可扩展性。它还提供了丰富的管理工具和性能优化功能,为企业提供了可靠的数据存储和处理解决方案。PolarDB PostgreSQL版在数据库领域具有很高的竞争力,可以满足各种企业的需求。
|
11天前
|
运维 关系型数据库 分布式数据库
「合肥 * 讯飞」4 月 19 日 PolarDB 开源数据库沙龙,报名中!
4月19日周五,PolarDB开源社区联合科大讯飞共同举办开源数据库技术沙龙,本次沙龙我们邀请了众多数据库领域的专家,期待大家的参与!
「合肥 * 讯飞」4 月 19 日 PolarDB 开源数据库沙龙,报名中!
|
1月前
|
存储 关系型数据库 分布式数据库
PolarDB常见问题之PolarDB突然有大量服务连不上数据库如何解决
PolarDB是阿里云推出的下一代关系型数据库,具有高性能、高可用性和弹性伸缩能力,适用于大规模数据处理场景。本汇总囊括了PolarDB使用中用户可能遭遇的一系列常见问题及解答,旨在为数据库管理员和开发者提供全面的问题指导,确保数据库平稳运行和优化使用体验。
|
1月前
|
存储 关系型数据库 MySQL
TiDB与MySQL、PostgreSQL等数据库的比较分析
【2月更文挑战第25天】本文将对TiDB、MySQL和PostgreSQL等数据库进行详细的比较分析,探讨它们各自的优势和劣势。TiDB作为一款分布式关系型数据库,在扩展性、并发性能等方面表现突出;MySQL以其易用性和成熟性受到广泛应用;PostgreSQL则在数据完整性、扩展性等方面具有优势。通过对比这些数据库的特点和适用场景,帮助企业更好地选择适合自己业务需求的数据库系统。
|
1月前
|
Cloud Native 关系型数据库 分布式数据库
**PolarDB IMCI:云原生时代的智能数据库新选择**
**PolarDB IMCI:云原生时代的智能数据库新选择**
26 4

相关产品

  • 云原生数据库 PolarDB