抢鲜体验 PolarDB PG 15 开源版

unsetunsetPolarDB 商业版unsetunset

8 月,PolarDB PostgreSQL 版兼容 PostgreSQL 15 版本(商业版)正式发布上线。

alt

当前版本主要增强优化了以下方面:

  • 改进排序功能:改进内存和磁盘排序算法。
  • 增强SQL功能:支持SQL标准的MERGE命令。增加使用正则表达式的新函数,用于检查字符串。
  • 改进逻辑复制功能:支持复制2PC事务,发布内容可以使用WHERE进行过滤,支持一次性发布Schema下所有的表。
  • 优化数据库性能:降低内存占用。崩溃恢复加速等。

在社区PostgreSQL 15的基础上,PolarDB还支持一些独有的功能,例如Ganos时空引擎,全局执行计划缓存,GBK/GB18030字符集等。在PolarDB PostgreSQL版 15的第一个发布版本中支持以下插件:hll、hypopg、log_fdw、pase、pg_bigm、pg_cron、pg_jieba、pg_repack、pg_similarity、pgtap、pgvector、pldebugger、prefix、roaringbitmap、rum、varbitx、zhparser、ganos。

同时PolarDB进行了深入的性能优化,例如优化SIMD指令集和原子操作指令集的使用,并在事务处理等模块中使能。使用 PGO、BOLT、LTO、代码段大页等系统级优化手段。支持批量读取、扩展,优化IO性能,并进行了深入的参数调优,提供了极致性能。

详情参阅:

https://help.aliyun.com/zh/polardb/polardb-for-postgresql/polardb-postgresql-version-15-officially-released

unsetunsetPolarDB 开源版unsetunset

9 月初,开源 PolarDB PostgreSQL 15 兼容版本正式发布。

开源云原生数据库 PolarDB PostgreSQL 15 兼容版正式发布上线,该版本 100% 兼容开源 PostgreSQL 15。PolarDB 是阿里云自研云原生关系型数据库,基于共享存储的存算分离架构使其具备灵活弹性和高性价比的特性,在开源 PostgreSQL 很好的性能表现的基础上极大增强了可扩展性和弹性。

alt

开源代码仓库:

https://github.com/ApsaraDB/PolarDB-for-PostgreSQL/tree/POLARDB_15_STABLE

PolarDB PG 15 有诸多值得关注的特性,具体参阅:

开源云原生数据库 PolarDB PostgreSQL 15 兼容版本正式发布

unsetunset开源 PolarDB PG 15 编译安装unsetunset

依赖安装

服务器操作系统为:Rocky Linux 8.10 (Green Obsidian)

除一般 PG 所需依赖包之外,PolarDB PG 15 还需安装如下依赖。

dnf install readline-devel llvm-toolset cmake libuuid-devel perl-IPC-Run perl-Test-Simple

如缺失,可能会遇到如下报错。

  1. 报错: configure: error: library 'uuid' is required for E2FS UUID,需安装: libuuid-devel
  2. 报错: configure: error: library 'unwind' is required for backtrace support,需安装: libunwind-devel
  3. 报错: configure: error: Additional Perl modules are required to run TAP tests,需安装: perl-IPC-Run perl-Test-Simple

编译安装

开源代码中已提供编译脚本,直接运行即可。

[shawnyan@rl8 PolarDB-for-PostgreSQL-POLARDB_15_STABLE]$ ./build.sh
Begin stop and clean existing cluster, may raising errors, ignore them
Begin clean existing installation, may raising errors, ignore them
Begin configure, flag: --enable-depend --with-uuid=e2fs --disable-rpath --with-segsize=128 --enable-debug --enable-cassert --enable-tap-tests --enable-fault-injector --with-openssl --enable-nls --with-libxml --with-libxslt --with-icu --with-pam --with-gssapi --with-ldap --with-perl --with-python --with-tcl --with-llvm --with-lz4 --with-zstd --with-system-tzdata=/usr/share/zoneinfo --with-libunwind -q --prefix=/home/shawnyan/tmp_polardb_pg_15_base --with-pgport=55992
Begin compile and install PolarDB
Begin init PolarDB cluster
Begin initdb, flag: -k -A trust -D /home/shawnyan/tmp_polardb_pg_15_primary
Following command can be used to connect to PolarDB:
export PATH=/home/shawnyan/tmp_polardb_pg_15_base/bin:$PATH
psql -h127.0.0.1 -p55992 postgres #primary

查看版本

安装完成后,已自动运行单实例节点,可连接到 PolarDB 查看基础信息。

psql (PostgreSQL 15.8-ShawnYan (PolarDB 15.8.2.0 build unknown debug) on x86_64-linux-gnu)
Type "help" for help.

postgres=# select version();
                                       version
-------------------------------------------------------------------------------------
 PostgreSQL 15.8-ShawnYan (PolarDB 15.8.2.0 build unknown debug) on x86_64-linux-gnu
(1 row)

postgres=# \l
                                                   List of databases
     Name      |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges
---------------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
 polardb_admin | shawnyan | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =T/shawnyan          +
               |          |          |             |             |            |                 | shawnyan=CTc/shawnyan
 postgres      | shawnyan | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            |
 template0     | shawnyan | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/shawnyan          +
               |          |          |             |             |            |                 | shawnyan=CTc/shawnyan
 template1     | shawnyan | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | =c/shawnyan          +
               |          |          |             |             |            |                 | shawnyan=CTc/shawnyan
(4 rows)

unsetunset也值得关注的改动 -- pg_walinspectunsetunset

在诸多变更中,有一项也值得关注:

  • 增加内置扩展 pg_walinspect ,允许您直接从 SQL 接口检查 WAL 日志文件内容。

pg_walinspect

pg_walinspect 模块提供了一系列 SQL 函数,允许用户探究 Write-Ahead Log(WAL)中的内容。这个模块的出现改变了之前只能通过外部工具查看 WAL 日志信息的做法,比如 pg_waldump,使得在数据库内部直接查看 WAL 日志成为可能,从而提高了操作性和便利性。

该模块的所有功能将使用当前服务器的时间线ID提供WAL信息。此模块的所有函数都将尝试查找位于给定或之后的第一个有效 WAL 记录,in_lsn如果start_lsn没有这样的记录可用,则会发出错误。同样,end_lsn必须可用,如果它位于记录中间,则整个记录必须可用。

默认情况下,这些功能的使用仅限于超级用户和角色成员 pg_read_server_files。超级用户可以使用 GRANT 向其他人授予访问权限。

通过执行下面命令,用户可以激活这个扩展。

postgres=# CREATE EXTENSION pg_walinspect;
CREATE EXTENSION
postgres=# \dx pg_walinspect
                                  List of installed extensions
     Name      | Version | Schema |                         Description
---------------+---------+--------+-------------------------------------------------------------
 pg_walinspect | 1.0     | public | functions to inspect contents of PostgreSQL Write-Ahead Log
(1 row)

pg_walinspect 模块提供的功能包括:

  • pg_get_wal_record_info(pg_lsn)

获取给定 LSN 的 WAL 记录信息。

  • pg_get_wal_records_info(pg_lsn,pg_lsn)

获取 start_lsn 和 end_lsn 之间的所有有效 WAL 记录的信息。每个 WAL 记录返回一行。

  • pg_get_wal_records_info_till_end_of_wal(pg_lsn)

此函数与 pg_get_wal_records_info() 相同,不同之处在于它获取从 start_lsn 到 WAL 结束的所有有效 WAL 记录的信息。

  • pg_get_wal_stats(pg_lsn,pg_lsn,boolean)

获取 start_lsn 和 end_lsn 之间所有有效 WAL 记录的统计信息。

  • pg_get_wal_stats_till_end_of_wal(pg_lsn,boolean)

此函数与 pg_get_wal_stats() 相同,不同之处在于它获取从 start_lsn 到 WAL 结束的所有有效 WAL 记录的统计信息。

pg_walinspect 模块的使用示例:

  • 创建测试表
postgres=# SELECT pg_current_wal_lsn();
 pg_current_wal_lsn
--------------------
 0/40C012A0
(1 row)

postgres=# create table t (id int, name varchar(10));
CREATE TABLE
postgres=# insert into t select 1,'S';
INSERT 0 1
postgres=# SELECT pg_current_wal_lsn();
 pg_current_wal_lsn
--------------------
 0/40C02680
(1 row)
  • 执行 pg_get_wal_records_info
postgres=# SELECT * FROM pg_get_wal_records_info('0/40C012A0','0/40C02680') where resource_manager not in ('Btree', 'Heap2');
 start_lsn  |  end_lsn   |  prev_lsn  | xid | resource_manager |  record_type  | record_length | main_data_length | fpi_length |
                  description                                                                                                                                                           |                  block_ref
------------+------------+------------+-----+------------------+---------------+---------------+------------------+------------+-----------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------
 0/40C012A0 | 0/40C012D0 | 0/40C01268 |   0 | XLOG             | FPI_FOR_HINT  |            44 |                0 |          0 |
                                                                                                                                                                                        | blkref #0: rel 1663/5/2663 fork main blk 2
 0/40C012D0 | 0/40C01300 | 0/40C012A0 |   0 | XLOG             | FPI_FOR_HINT  |            44 |                0 |          0 |
                                                                                                                                                                                        | blkref #0: rel 1663/5/2704 fork main blk 2
 0/40C01300 | 0/40C01330 | 0/40C012D0 | 742 | Standby          | LOCK          |            42 |               16 |          0 | xid 742 db 5 rel 16396
                                                                                                                                                                                        |
 0/40C01330 | 0/40C01360 | 0/40C01300 | 742 | Storage          | CREATE        |            42 |               16 |          0 | file-dio:///home/shawnyan/tmp_polardb_pg_15_data/base/5/16396
                                                                                                                                                                                        |
 0/40C01360 | 0/40C01438 | 0/40C01330 | 742 | Heap             | INSERT        |           211 |                3 |          0 | off 14 flags 0x00
                                                                                                                                                                                        | blkref #0: rel 1663/5/1247 fork main blk 14
 0/40C015A0 | 0/40C015D0 | 0/40C01558 | 742 | XLOG             | FPI_FOR_HINT  |            44 |                0 |          0 |
                                                                                                                                                                                        | blkref #0: rel 1663/5/2704 fork main blk 4
 0/40C015D0 | 0/40C016A8 | 0/40C015A0 | 742 | Heap             | INSERT        |           211 |                3 |          0 | off 15 flags 0x00
                                                                                                                                                                                        | blkref #0: rel 1663/5/1247 fork main blk 14
 0/40C01810 | 0/40C018E0 | 0/40C017C8 | 742 | Heap             | INSERT        |           203 |                3 |          0 | off 3 flags 0x00
                                                                                                                                                                                        | blkref #0: rel 1663/5/1259 fork main blk 0
 0/40C01D98 | 0/40C01DC8 | 0/40C01BE0 | 742 | XLOG             | FPI_FOR_HINT  |            44 |                0 |          0 |
                                                                                                                                                                                        | blkref #0: rel 1663/5/1249 fork fsm blk 2
 0/40C01DC8 | 0/40C01DF8 | 0/40C01D98 |   0 | Standby          | LOCK          |            42 |               16 |          0 | xid 742 db 5 rel 16396
                                                                                                                                                                                        |
 0/40C01DF8 | 0/40C01E30 | 0/40C01DC8 |   0 | Standby          | RUNNING_XACTS |            54 |               28 |          0 | nextXid 743 latestCompletedXid 741 oldestRunningXid 742; 1 xacts: 742
                                                                                                                                                                                        |
 0/40C02460 | 0/40C02618 | 0/40C02418 | 742 | Transaction      | COMMIT        |           437 |              408 |          0 | 2024-09-05 20:32:49.189678+09; inval msgs: catcache 80 catcache 79 catcache 80 catcache 79 catcache 55 catcache 54 catcache 7 catcache 6
 catcache 7 catcache 6 catcache 7 catcache 6 catcache 7 catcache 6 catcache 7 catcache 6 catcache 7 catcache 6 catcache 7 catcache 6 catcache 7 catcache 6 snapshot 2608 relcache 16396 |
 0/40C02618 | 0/40C02658 | 0/40C02460 | 743 | Heap             | INSERT+INIT   |            61 |                3 |          0 | off 1 flags 0x00
                                                                                                                                                                                        | blkref #0: rel 1663/5/16396 fork main blk 0
 0/40C02658 | 0/40C02680 | 0/40C02618 | 743 | Transaction      | COMMIT        |            34 |                8 |          0 | 2024-09-05 20:32:53.92087+09
                                                                                                                                                                                        |
(14 rows)
  • 执行 pg_get_wal_stats
postgres=# SELECT * FROM pg_get_wal_stats('0/40C012A0','0/40C02680') where record_size != 0;
 resource_manager/record_type | count | count_percentage | record_size | record_size_percentage | fpi_size | fpi_size_percentage | combined_size | combined_size_percentage
------------------------------+-------+------------------+-------------+------------------------+----------+---------------------+---------------+--------------------------
 XLOG                         |     4 |                8 |         176 |     3.5284683239775463 |        0 |                   0 |           176 |       3.5284683239775463
 Transaction                  |     2 |                4 |         471 |      9.442662389735364 |        0 |                   0 |           471 |        9.442662389735364
 Storage                      |     1 |                2 |          42 |     0.8420208500400962 |        0 |                   0 |            42 |       0.8420208500400962
 Standby                      |     3 |                6 |         138 |     2.7666399358460305 |        0 |                   0 |           138 |       2.7666399358460305
 Heap2                        |     7 |               14 |        1515 |       30.3728949478749 |        0 |                   0 |          1515 |         30.3728949478749
 Heap                         |     4 |                8 |         686 |     13.753007217321572 |        0 |                   0 |           686 |       13.753007217321572
 Btree                        |    29 |               58 |        1960 |      39.29430633520449 |        0 |                   0 |          1960 |        39.29430633520449
(7 rows)

unsetunset引用说明unsetunset

[1] https://openpolardb.com/document?type=PolarDB-X [2] https://www.postgresql.org/docs/15/pgwalinspect.html

unsetunset新书推荐unsetunset

推荐两本新书:

《DBA实战手记》(薛晓刚)

本书是一本指导DBA进行数据库开发和运维的实用手册,本书共9章,包括漫谈数据库、如何提升数据库性能、如何运维好数据库、如何进行数据库设计、如何做好数据库之间的数据同步、认识HTAP技术、认识数据库的功能原理、认识数据库中的数学(逻辑与算法),以及DBA的日常:数据库管理及开发的最佳实践。

内容特色:

  1. 精彩的实战案例。本书为数据库实践经验集,将为广大数据库从业人员带来巨大的帮助和启发,也为企业的信息化和智能化建设提供坚实的技术支持。

  2. 丰富的扩展阅读。本书附录:DBA杂谈,分享了包括DBA的职业规划等的六个话题。并以在线的扩展阅读方式呈现类型数据库的应用场景等实践案例。

  3. 全彩印刷,提供优质阅读体验。

薛老师及其团队奉献给广大同仁的数据库实践经验集《DBA实战手记》一经出版便收到了广泛好评,盖国强、白鳝(徐戟)、贺仁龙为这本书倾情作序,周正中(德哥)、侯圣文、耿航、吴洋鼎力推荐。

《快速掌握PostgreSQL版本新特性》(彭冲)

本书对PostgreSQL的7个大版本:从PostgreSQL 10到PostgreSQL 16,根据公开的新特性实验手册、新特性相关的文章、邮件列表、社区核心提交者相关的博客,以及官方Release Notes等素材进行精加工,并从主要性能、可靠性、运维管理、开发易用性、系统层5个方面进行介绍。

推荐理由:

  1. 素材丰富。本书吸取了大量国内外资料,我们不断学习这些新特性,就如农民伯伯烧荒播种,为日后的故障案例分析打下基础。

  2. 特性关联。PG数据库里的一些新特性,有来自其他数据库的应用场景,也有同步实现其他接口协议的功能,还有各版本不断演进的特性。本书对有关联的一些特性,将其前幕背景进行了铺垫及关联陈述。

  3. 先知后验。大家看到的一些新特性文章可能基于某个dev开发快照版本,亦或是beta测试版本,而版本正式发布时,某些特性可能会有变化。本书新特性的示例代码均以正式版为基准,先知而后验,对一些功能进行了修订。

获取方式:

  1. 通过PGFans问答社区积分兑换。https://www.modb.pro/point/mall
  2. 通过PGFans问答社区积分兑换。https://pgfans.cn/shop
  3. 网购。

本文由 mdnice 多平台发布

  • 14
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值