PostgreSQL 10.0 preview 功能增强 - 缓存自动预热, 直达性能巅峰

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
云原生数据库 PolarDB 分布式版,标准版 2核8GB
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 标签 PostgreSQL , 10.0 , 自动预热缓存 背景 数据库的shared buffer可以用来存储经常使用的数据块,以提升效率。通过LRU算法老化不常用的数据块。 因此在生成数据库中,SHARED BUFFER中通常是热数据。

标签

PostgreSQL , 10.0 , 自动预热缓存


背景

数据库的shared buffer可以用来存储经常使用的数据块,以提升效率。通过LRU算法老化不常用的数据块。

因此在生产数据库中,SHARED BUFFER中通常是热数据。 

数据库如果重启,或者发生主备切换,缓存中的热数据需要从磁盘(或者OS PAGE CACHE)重新载入数据库的shared buffer。

当这个事情发生在业务高峰期时,由于热数据未在数据库缓存中,访问将会变慢,用户的感觉可能是请求变慢了。

为了提升用户体验,减少请求的响应时间的抖动,PostgreSQL 10.0推出了自动预热缓存的技术。

也就是说shared buffer的block list chain会记录下来,下次启动时,自动载入shared buffer.

# pg_autoprewarm.  

This a PostgreSQL contrib module which automatically dump all of the  
blocknums  
present in buffer pool at the time of server shutdown(smart and fast mode  
only,  
to be enhanced to dump at regular interval.) and load these blocks when  
server restarts.  

Design:  
------  
We have created a BG Worker Auto Pre-warmer which during shutdown dumps all  
the  
blocknum in buffer pool in sorted order.  
Format of each entry is  
<DatabaseId,TableSpaceId,RelationId,Forknum,BlockNum>.  
Auto Pre-warmer is started as soon as the postmaster is started we do not  
wait  
for recovery to finish and database to reach a consistent state. If there  
is a  
"dump_file" to load we start loading each block entry to buffer pool until  
there is a free buffer. This way we do not replace any new blocks which was  
loaded either by recovery process or querying clients. Then it waits until  
it receives  
SIGTERM to dump the block information in buffer pool.  

HOW TO USE:  
-----------  
Build and add the pg_autoprewarm to shared_preload_libraries. Auto  
Pre-warmer  
process automatically do dumping of buffer pool's block info and load them  
when  
restarted.  

TO DO:  
------  
Add functionality to dump based on timer at regular interval.  
And some cleanups.  
--   
Thanks and Regards  
Mithun C Y  
EnterpriseDB: http://www.enterprisedb.com  

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

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

参考

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

https://www.postgresql.org/message-id/flat/CAD__Ougw7Kc+1-cGA8GM0t+FuUHqPYR9Aow6OZX48sbH=V8BWw@mail.gmail.com#CAD__Ougw7Kc+1-cGA8GM0t+FuUHqPYR9Aow6OZX48sbH=V8BWw@mail.gmail.com

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
23天前
|
关系型数据库 Serverless 分布式数据库
【公测】PolarDB PostgreSQL版Serverless功能免费使用​!
【公测】PolarDB PostgreSQL版Serverless功能免费使用​,公测于2024年3月28日开始,持续三个月,公测期间可以免费使用!
|
3月前
|
存储 关系型数据库 MySQL
PolarDB优势功能
PolarDB优势功能
|
4月前
|
存储 SQL 关系型数据库
PolarDB这个sql行存和列存性能差别好大 ,为什么?
PolarDB这个sql行存和列存性能差别好大 ,为什么?
33 0
|
4月前
|
存储 关系型数据库 数据库
postgresql|数据库|提升查询性能的物化视图解析
postgresql|数据库|提升查询性能的物化视图解析
156 0
|
3月前
|
关系型数据库 MySQL Serverless
阿里云云原生数据库 PolarDB MySQL Serverless:卓越的性能与无与伦比的弹性
阿里云原生数据库 PolarDB MySQL Serverless 拥有卓越性能和无与伦比的弹性。通过实验体验,深入了解其基本管理和配置、智能弹性伸缩特性和全局一致性特性。实验包括主节点和只读节点的弹性压测以及全局一致性测试,旨在亲身体验 PolarDB 的强大性能。通过实验,可以更好地在实际业务场景中应用 PolarDB,并根据需求进行性能优化和调整。
679 2
|
1月前
|
关系型数据库 Serverless 分布式数据库
PolarDB PostgreSQL版Serverless功能上线公测啦,公测期间免费使用!
Serverless数据库能够使得数据库集群资源随客户业务负载动态弹性扩缩,将客户从复杂的业务资源评估和运维工作中解放出来。PolarDB PostgreSQL版 Serverless提供了CPU、内存、存储、网络资源的实时弹性能力,构建计算与存储分离架构下的 PolarDB PostgreSQL版产品新形态。
|
2月前
|
SQL 关系型数据库 分布式数据库
在PolarDB for PostgreSQL中,你可以使用LIKE运算符来实现类似的查询功能,而不是使用IF函数
在PolarDB for PostgreSQL中,你可以使用LIKE运算符来实现类似的查询功能,而不是使用IF函数
43 7
|
2月前
|
关系型数据库 Linux Shell
Centos系统上安装PostgreSQL和常用PostgreSQL功能
Centos系统上安装PostgreSQL和常用PostgreSQL功能
|
3月前
|
存储 关系型数据库 分布式数据库
阿里云PolarDB解决乐麦多源数据存储性能问题
乐麦通过使用PolarDB数据库,使整个系统之间的数据查询分析更加高效
390 3
|
3月前
|
关系型数据库 MySQL 分布式数据库
PolarDB MySQL企业版与标准版功能对比:如何选择适合您的版本?
随着数字化时代的到来,企业对于数据处理的需求越来越高,而数据库作为数据处理的核心,其性能和成本成为了企业关注的焦点。阿里云全新推出的PolarDB MySQL企业版和标准版,以全新的架构和优化,为企业提供了高性能、低成本的数据库解决方案。但在功能上,这两个版本有很多差异,我们该如何选择呢?
58 2

相关产品

  • 云原生数据库 PolarDB