Skip to content

Latest commit

 

History

History
79 lines (48 loc) · 3.32 KB

20220819_01.md

File metadata and controls

79 lines (48 loc) · 3.32 KB

PostgreSQL 15 preview - create database wal-logged 时支持批量扩展数据块, 提升基于模板创建数据库性能, SaaS场景

作者

digoal

日期

2022-08-19

标签

PostgreSQL , smgrextend , create database , saas


背景

saas场景可能一个客户一个database, database基于模板库, 一个实例里面可能有很多database. 创建database可能也是比较频繁的操作.

例如sap, odoo, ToB类的云端软件服务(钉钉、云协同等).

标准动作: 模板统一, 新增客户时, 使用模板创建数据库.

PostgreSQL 15 preview - create database wal-logged 时支持批量扩展数据块, 提升基于模板创建数据库性能, SaaS场景

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

When using the WAL-logged CREATE DATABASE strategy, bulk extend.  
author	Robert Haas <rhaas@postgresql.org>	  
Thu, 18 Aug 2022 15:09:39 +0000 (11:09 -0400)  
committer	Robert Haas <rhaas@postgresql.org>	  
Thu, 18 Aug 2022 15:26:34 +0000 (11:26 -0400)  
commit	3e63e8462f31657c8ae1c541c92daf43ede8f038  
tree	22b363ee3d8343b88a9cd8a167be0b1ea61eb551	tree  
parent	27f1774aac1f8ffe642b55e78dbe0b64ed082cc6	commit | diff  
When using the WAL-logged CREATE DATABASE strategy, bulk extend.  
  
This should improve performance, and was suggested by Andres Freund.  
Back-patch to v15 to keep the code consistent across branches.  
  
Dilip Kumar  
  
Discussion: http://postgr.es/m/C3458199-FEDD-4356-865A-08DFAA5D4065@anarazel.de  
Discussion: http://postgr.es/m/CAFiTN-sJ0vVpJrZ=R5M+g7Tr8=NN4wKOtrqOcDEsfFfnZgivVA@mail.gmail.com  
+   /*  
+    * Bulk extend the destination relation of the same size as the source  
+    * relation before starting to copy block by block.  
+    */  
+   memset(buf.data, 0, BLCKSZ);  
+   smgrextend(smgropen(dstlocator, InvalidBackendId), forkNum, nblocks - 1,  
+              buf.data, true);  
+  

digoal's wechat