透过postgrespro看PostgreSQL的附加功能

4 minute read

背景

Postgrespro是俄罗斯的一家数据库公司,创始人OLEG是PostgreSQL社区的核心成员之一,一名在俄罗斯莫斯科国立大学,斯特恩伯格天文研究所做科学研究的天文学家。同时也担任Postgres Professional公司的首席执行官。也是一位登顶过珠峰的人。

pic

这里是他的专访

https://yq.aliyun.com/articles/60800

postgrespro企业版本加了很多新的功能,postgrespro本身也是非常开放的一家公司,期待这些功能会加入到社区版本中。

https://github.com/postgrespro/

另一家俄罗斯的公司ispras也放出过非常前沿的产品,Postgres-LLVM,目前JIT已经集成到PostgreSQL社区版本了。

感谢所有为PostgreSQL社区付出的人们。

Postgrespro vs PostgreSQL

Postgres Pro Enterprise is the most actual PostgreSQL version with some additional patches applied and extensions added. Mostly, these are patches already accepted by the PostgreSQL community and committed into PostgreSQL. Also there some patches and extensions developed by Postgres Professional. Users of Postgres Pro Enterprise thus have early access to some important features and fixes.

Currently the difference between Postgres Pro Enterprise and PostgreSQL is the following:

  • Performance improvement on multicore systems (buffer manager and locks optimization)
    多核性能增强(BUFFER管理和锁管理优化)

  • Full text search improvements: phrase search, hunspell morphology, some dictionaries are bundled with distribution and can be enabled by a single SQL statement, shared_ispell allowing to store dictionaries in shared memory
    全文检索增强,支持phrase搜索等。

  • Covering indexes
    《PostgreSQL 10.0 preview 功能增强 - 唯一约束+附加字段组合功能索引》

  • libicu support on all platforms, providing platform-independent sort for various locales
    《PostgreSQL 10.0 preview 功能增强 - 国际化功能增强,支持ICU(International Components for Unicode)》

  • pg_trgm module supporting fuzzy string comparison and substring search
    支持fuzzy字符串搜索,substring搜索。(模糊、正则)

  • Improved pageinspect module provides access to internal data storage structure
    增强:支持观测gin, sp-gist, gist等索引内部内容

  • sr_plan module allows to save and restore query plans
    支持执行计划的存储和还原。通过这个可以改写SQL的执行计划,甚至可以把SELECT改写成INSERT等或者完全不相关的SQL。
    《PostgreSQL Oracle 兼容性之 - SQL OUTLINE插件sr_plan (保存、篡改、固定 执行计划)》

  • dump_stat module allowing to save and restore database statistics when dumping/restoring the database
    允许导出和还原统计信息,相当于将统计信息和数据分开了,这样做的好处是做迁移可以更快。
    例如pg_upgrade升级版本,可以通过这种方法直接导入统计信息。对于超级大库,这个效率高很多。
    又比如逻辑备份和还原,可以关闭autovacuum,然后通过这种方式导入统计信息。

  • jsquery module provides a specific language for effective index-supported querying of JSONB data
    jsonb的扩展函数、操作符。

  • pg_variables module provides functions to work with variables of various types
    内存表。
    《PostgreSQL 内存表》

  • pg_pathman module provides optimized partitioning mechanism and functions to manage partitions
    分区表插件,支持range,list,hash等分区方法,而且对性能损耗极小。
    《PostgreSQL 9.5+ 高效分区表实现 - pg_pathman》

  • pg_query_state module provides a facility to know the current state of query execution on working backend
    《官人要杯咖啡吗? - PostgreSQL实时监测PLAN tree的执行进度 - pg_query_state》

  • pg_probackup is a backup and recovery manager
    支持块级增量备份、备份集的管理、恢复。类似Oracle RMAN。

  • mchar module provides additional data type to compatibility with Microsoft SQL Server
    兼容SQL Server的数据类型。

  • fulleq module provides additional equivalence operator to compatibility with Microsoft SQL Server
    兼容SQL Server的等于操作符。

  • fasttrun module provides transaction unsafe function to truncate temporary tables without growing pg_class size
    outer temp table,不造成pg_class, pg_attribute的变更。
    目前PG的temp table是会话级,每次使用都会擦写pg_class, pg_attribute,产生系统表垃圾。需要autovacuum自动回收这些垃圾。

  • online_analyze module provides set of changes, which immediately update stats after INSERT, UPDATE, DELETE or SELECT INTO operations applied for affected tables
    和autovacuumm的analyze工作差不多。

  • plantuner module provides hits for planner, which can do disable or enable indexes for query execution
    sql hint,类似Oracle hint功能。强制设置SQL的执行计划。

  • Added k-nearest neighbors algorithm (KNN) for SP-GiST and B-tree (See Chapter 61)
    sp-gist,btree索引的KNN检索支持。例如通过sp-gist,btree索引求某个点附近的对象,某个数值、字符串最近的对象。等。

  • Added RUM index, based on GIN, as separate module (See Section F.53)
    RUM索引接口,用于多值类型、全文检索等。支持全文检索的附加列搜索。类似多级树。
    《PostgreSQL 全文检索加速 快到没有朋友 - RUM索引接口(潘多拉魔盒)》

  • WAL size has been reduced on CREATE INDEX operation in the GiST, GIN, SP-GiST

  • Added timeout for idle sessions on the server side (See idle_session_timeout)
    会话超时功能。

  • Added SHA-2 algorithm for password encryption (See Section 20.3.2)
    一种新的认证机制,已经添加到10的版本,认证过程更加安全。以往的版本泄露用户密码的md5是有问题的。
    《PostgreSQL 10.0 preview 安全增强 - SASL认证方法 之 scram-sha-256 安全认证机制》
    《PostgreSQL md5 对比 MySQL - 秘钥认证》

  • Added page level compression (CFS) (See Chapter 32)
    页级压缩。
    《PostgreSQL 透明加密(TDE,FDE) - 块级加密》

  • Added support of autonomous transactions (See Chapter 16)
    支持匿名事务,以往需要通过dblink来支持类似的功能。

  • Added new optional background worker to schedule tasks by rules (See pgpro_scheduler)
    支持数据库任务调度。类似Oracle的JOB或scheduler功能。
    以往需要通过pgagent来实现,或者通过系统的调度如crontab来实现。

  • Added support for relocatable tables (See pg_transfer)
    文件级表传输特性。例如需要将一个表拷贝到其他数据库实例,不需要导出导入,直接拷贝文件。
    《PostgreSQL 的表传输功能》
    如果能做到库级,那么就类似Oracle 12C的PDB了,可以热插拔数据库。
    加上库级物理恢复,则可以做到更强的插拔体验。

  • Extension pg_hint_plan has been added
    同样是一个SQL HINT插件。
    《关键时刻HINT出彩 - PG优化器的参数优化、执行计划固化CASE》

  • Transaction IDs on 64-bit platforms use 64-bit data type
    终于支持64位xid了,不再需要freeze了。虽然PG 10的freeze在静态表层面已经基本不耗费资源了。

  • Lazy placement of temporary tables on disk
    支持全局临时表,社区版本只做了会话级临时表,每次都需要重新定义。

  • Consistent read on slaves (wait for WAL apply, see WAITLSN)
    备库lsn栅栏,可以做到备库的读一致性。
    《PostgreSQL 10.0 preview 功能增强 - slave支持WAITLSN ‘lsn’, time;用于设置安全replay栅栏》

  • Utility pg_repack has been added
    收缩空间的工具,比vacuum full的锁时间更短,类似mysql online ddl.
    《PostgreSQL 收缩膨胀表或索引 - pg_squeeze or pg_repack》

  • Added multimaster extension
    multi master,无需多言,很牛逼的功能。

  • Added failover algorithm for libpq connections
    libpq支持配置多主机,以及failover算法。

  • Added aqo extension for adaptive query optimization
    基于机器学习算法的优化器功能。
    《数据库优化器原理 - 如何治疗选择综合症》

  • Implemented declarative syntax for partitioning. (See Section F.38.2.6.)
    支持创建分区表,相比社区版本分区的性能有非常明显的提升,当分区较多时,社区版本在catalog search,LOCK上耗费较大。

  • Added mamonsu monitoring service, which is implemented as a Zabbix agent. (See mamonsu.)
    支持zabbix agent。

  • Added pg_wait_sampling extension for sampling-based statistics of wait events. With this extension, you can get an insight into the server activity, including the current wait events for all processes and background workers.
    支持等待事件的采样分析。

  • pg_tsparser module is an alternative text search parser.
    新增一个全文检索parser: pg_tsparser。

  • pg_shardman module is an experimental extension that enables sharding, aiming for scalability and fault tolerance with transaction support. It provides best results for OLTP workloads.
    通过pg_shardman,支持PostgreSQL sharding。

  • in-memory module enables you to store data in Postgres Pro shared memory.
    提供内存表的支持。

  • vops module enables vertical data model for Postgres Pro Enterprise. It can speed up OLAP queries with filtering and aggregation by times.
    提供向量计算插件,提高OLAP性能。

  • stream replication支持rdma
    RT降低,使得QUORUM BASED 多副本的性能下降更低。

Postgres Pro Enterprise releases are following the PostgreSQL releases, though sometimes occur more frequently. The Postgres Pro Enterprise versioning scheme is based on the PostgreSQL one and has an additional decimal place.

roadmap

https://postgrespro.com/roadmap

postgrespro 企业版与pro版差异

https://postgrespro.com/products/postgrespro/enterprise

postgrespro git - 其他功能

https://github.com/postgrespro

1、区块链插件

https://github.com/postgrespro/pg_credereum

2、PG 内置连接池版本

https://github.com/postgrespro/postgresql.builtin_pool

3、图像相似搜索

https://github.com/postgrespro/imgsmlr

4、PG 线程版本

https://github.com/postgrespro/postgresql.pthreads

5、压缩版本JSON

https://github.com/postgrespro/jsonbd

https://github.com/postgrespro/zson

6、执行计划PROFILE

https://github.com/postgrespro/sr_plan

7、mongo兼容协议版 PG

https://github.com/postgrespro/monq

8、PG Raft协议插件

https://github.com/postgrespro/raft

9、PG memcontext stat插件

https://github.com/postgrespro/memstat

10、基于时间戳的分布式事务管理插件

https://github.com/postgrespro/pg_tsdtm

11、PG workload 统计插件

https://github.com/postgrespro/pg_grab_statement

12、smlar

http://www.sigaev.ru/git/gitweb.cgi?p=smlar.git;a=summary

postgrespro 核心成员之一 sigaev

http://www.sigaev.ru/

参考

https://github.com/ispras

https://postgrespro.com/docs/enterprise/10/intro-pgpro-vs-pg

Flag Counter

digoal’s 大量PostgreSQL文章入口