PostgreSQL 10.0 preview 功能增强 - 串行隔离级别 预加锁阈值可控

本文涉及的产品
云原生数据库 PolarDB 分布式版,标准版 2核8GB
云数据库 RDS SQL Server,独享型 2核4GB
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
简介:

标签

PostgreSQL , 10.0 , 串行隔离级别 , max_pred_locks_per_relation , 预加锁


背景

PostgreSQL 串行隔离级别中一个重要的概念是预加锁,在事务结束时,检测预加锁是否冲突。

10.0增加了三个控制参数,可以控制预加锁的上限。避免内存过度使用。

1. 控制每个事务的对象预加锁数量。

max_pred_locks_per_transaction (integer)

The shared predicate lock table tracks locks on max_pred_locks_per_transaction * (max_connections + max_prepared_transactions) objects (e.g., tables);

hence, no more than this many distinct objects can be locked at any one time.

This parameter controls the average number of object locks allocated for each transaction;

individual transactions can lock more objects as long as the locks of all transactions fit in the lock table.

This is not the number of rows that can be locked; that value is unlimited.

The default, 64, has generally been sufficient in testing, but you might need to raise this value if you have clients that touch many different tables in a single serializable transaction.
This parameter can only be set at server start.

2. 当单个对象的行或者页预加锁数量达到阈值时,升级为对象预加锁。减少内存开销。

max_pred_locks_per_relation (integer)

This controls how many pages or tuples of a single relation can be predicate-locked before the lock is promoted to covering the whole relation.

Values greater than or equal to zero mean an absolute limit, while negative values mean max_pred_locks_per_transaction divided by the absolute value of this setting.

The default is -2, which keeps the behaviour from previous versions of PostgreSQL.

This parameter can only be set in the postgresql.conf file or on the server command line.

3. 当单个页内多少条记录被加预加锁时,升级为页预加锁。减少内存开销。

max_pred_locks_per_page (integer)

This controls how many rows on a single page can be predicate-locked before the lock is promoted to covering the whole page.

The default is 2. This parameter can only be set in the postgresql.conf file or on the server command line.

关于串行隔离级别的概念,您可以参考

《PostgreSQL SERIALIZABLE ISOLATION LEVEL introduce》

patch 信息如下

Add GUCs for predicate lock promotion thresholds.  
  
author	Kevin Grittner <kgrittn@postgresql.org>	  
Sat, 8 Apr 2017 10:38:05 +0800 (21:38 -0500)  
committer	Kevin Grittner <kgrittn@postgresql.org>	  
Sat, 8 Apr 2017 10:38:05 +0800 (21:38 -0500)  
commit	c63172d60f242ad3581c83723a5b315bbe547a0e  
tree	0a98686f027aacecb01869bfb269ebd486ea3ba7	tree | snapshot  
parent	9c7f5229ad68d7e0e4dd149e3f80257893e404d4	commit | diff  
Add GUCs for predicate lock promotion thresholds.  
  
Defaults match the fixed behavior of prior releases, but now DBAs  
have better options to tune serializable workloads.  
  
It might be nice to be able to set this per relation, but that part  
will need to wait for another release.  
  
Author: Dagfinn Ilmari Mannsåker  

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

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

参考

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

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
3月前
|
关系型数据库 Serverless 分布式数据库
【公测】PolarDB PostgreSQL版Serverless功能免费使用​!
【公测】PolarDB PostgreSQL版Serverless功能免费使用​,公测于2024年3月28日开始,持续三个月,公测期间可以免费使用!
|
10月前
|
存储 关系型数据库 数据库
深入了解 PostgreSQL:功能、特性和部署
PostgreSQL,通常简称为Postgres,是一款强大且开源的关系型数据库管理系统(RDBMS),它在数据存储和处理方面提供了广泛的功能和灵活性。本文将详细介绍 PostgreSQL 的功能、特性以及如何部署和使用它。
536 1
深入了解 PostgreSQL:功能、特性和部署
|
3月前
|
关系型数据库 Serverless 分布式数据库
PolarDB PostgreSQL版Serverless功能上线公测啦,公测期间免费使用!
Serverless数据库能够使得数据库集群资源随客户业务负载动态弹性扩缩,将客户从复杂的业务资源评估和运维工作中解放出来。PolarDB PostgreSQL版 Serverless提供了CPU、内存、存储、网络资源的实时弹性能力,构建计算与存储分离架构下的 PolarDB PostgreSQL版产品新形态。
|
3月前
|
SQL 关系型数据库 分布式数据库
在PolarDB for PostgreSQL中,你可以使用LIKE运算符来实现类似的查询功能,而不是使用IF函数
在PolarDB for PostgreSQL中,你可以使用LIKE运算符来实现类似的查询功能,而不是使用IF函数
71 7
|
3月前
|
SQL 关系型数据库 分布式数据库
在PolarDB for PostgreSQL中,你可以使用LIKE运算符来实现类似的查询功能
在PolarDB for PostgreSQL中,你可以使用LIKE运算符来实现类似的查询功能【1月更文挑战第13天】【1月更文挑战第65篇】
49 2
|
3月前
|
关系型数据库 Linux Shell
Centos系统上安装PostgreSQL和常用PostgreSQL功能
Centos系统上安装PostgreSQL和常用PostgreSQL功能
|
11月前
|
SQL 关系型数据库 MySQL
功能强大的PostgreSQL没有MySQL流行的10个原因
本篇文章总结了为什么功能强大的PostgreSQL没有像MySQL一样流行的10个原因。玖章算术CEO叶正盛从产品功能、技术架构、生态、品牌商业等多个方面进行了分析,并指出了MySQL在流行度上的优势。文章还讨论了数据库在不同领域的竞争力和展望,并提到了PostgreSQL在中国信创产业发展中可能迎来新的机会。总体而言,这篇文章提供了关于MySQL和PostgreSQL的综合比较和评估。
128 0
功能强大的PostgreSQL没有MySQL流行的10个原因
|
Oracle 关系型数据库 数据库
PostgreSQL技术大讲堂 - 第20讲:事务概述与隔离级别
PostgreSQL从小白到专家,技术大讲堂 - 第20讲:事务概述与隔离级别
228 2
|
存储 SQL NoSQL
PostgreSQL列存增加更新和删除功能
PostgreSQL列存增加更新和删除功能
267 0
|
SQL 存储 运维
《阿里云认证的解析与实战-数据仓库ACP认证》——云原生数据仓库AnalyticDB PostgreSQL版解析与实践(上)——四、核心功能解析与实践
《阿里云认证的解析与实战-数据仓库ACP认证》——云原生数据仓库AnalyticDB PostgreSQL版解析与实践(上)——四、核心功能解析与实践

相关产品

  • 云原生数据库 PolarDB
  • 云数据库 RDS PostgreSQL 版