暂无图片
暂无图片
2
暂无图片
暂无图片
暂无图片

未来数据库方向 - PostgreSQL 有价值的插件、可改进功能、开放接口 (202005)

原创 digoal 2020-05-28
8353

作者
digoal

日期
2020-05-27

标签
PostgreSQL , 插件 , 功能 , 开放接口

背景

过去几年中人类制造的数据占整个人类历史数据量的95%,换言之,大数据时代已经真正降临. 赫拉利的《未来简史》观点, 信数据得永生. 如何抓住数据, 挖掘数据本身的价值? 数据库这么多, 未来怎么选择?

数据的本质:

  • 存储

  • 计算
    围绕这两点展开, 未来的数据库是什么样的?

  • 存储要求: 写入快, 更新快, 擦除快, 省成本, 存储格式灵活度高适合不同侧重点(写入、读取、更新、压缩效率等方面, 不同场景、阶段的需求都不一样), 空间可扩展性, 存储格式可塑性

    • 未来的存储能力核心是“可塑性”. 因为万物互联, 你要处理的数据是什么样的, 要处理成什么样, 根本是不可想像, 固定的存储模型无法满足未来的需求.
  • 计算要求: 计算快, 搜索快, 计算算法灵活, 搜索算法灵活, 算力可扩展性, 算法可塑性

    • 未来的计算能力核心也是“可塑性”. 因为万物互联, 你要处理的数据是什么样的, 要处理成什么样, 根本是不可想像, 固定的计算模型无法满足未来的需求.
      传统要求的衍存: 根据不同业务, 要求也不尽相同, 例如: 并发性, 容错性, 安全性, 稳定性, 可用性等

王东岳的《物演通论》核心思想, 递弱代偿表明: 衍存时空递减率,从时间上来说,越往后出现的物种,灭绝速度越快。同时越原始的东西越稳定,越具备决定性,例如尽管互联网如此发达,充满无数信息, 但是所有流量基本都与人类的感性情绪有关,此外情色内容一直牢牢保持着互联网的流量高地,这是因为感性的稳定度远远高于理性。越早期的感应属性,对越后来的感应属性决定性越大。参考

为什么PG是未来?

  • 由于PG拥有强大的基盘、扩展接口, 代表未来的基因.
    • 拥有类似bsd的开源许可基因, 代表开放|自由,
    • 核心committer由大量超大型用户、服务商、厂商组成的社区化基因, 代表用户|厂商|服务商,
    • 伯克利大学的学院派基因, 代表前沿学术研究,
      以 PG 作为基础, 通过PG的扩展接口衍生出来的插件或数据库产品会越来越多, 应对特定(垂直化)的场景, 而PG将长存.

衍生数据库
https://wiki.postgresql.org/wiki/PostgreSQL_derived_databases
内置插件
https://www.postgresql.org/docs/current/contrib.html
外围插件
https://download.postgresql.org/pub/projects/pgFoundry/
https://api.pgxn.org/src/
https://www.postgresql.org/download/product-categories/
https://www.postgresql.org/docs/current/external-extensions.html
https://github.com/topics/postgresql-extension
https://github.com/search?l=C&o=desc&q=postgresql&s=stars&type=Repositories
https://osdn.net/softwaremap/trove_list.php?form_cat=66
https://github.com/topics/postgresql?l=C&o=desc&s=stars
了解本文, 从数据库应用、管理到内核你都会有所得.

一、已有插件

1 存储引擎

一般围绕这几个点: 写入快, 更新快, 查询快, 更新垃圾少, 并发能力强, 压缩率高, 锁等待少, 支持行宽度宽, 支持列数多, 支持索引方法多

zedstore, 行列混合存储, 更好的支持分析场景(cpu vector 批量计算, 列存储, 压缩效率)
https://github.com/greenplum-db/postgres/tree/zedstore/src/backend/access/zedstore

undam, UNDO存储引擎, 更好的支持update, 减轻膨胀
https://github.com/postgrespro/undam

zheap, UNDO存储引擎, 更好的支持update, 减轻膨胀
https://github.com/EnterpriseDB/zheap

PostgreSQL appendonly 压缩 存储引擎 - pg_cryogen, 更好的支持分析场景(cpu vector 批量计算, 列存储, 压缩效率)
https://github.com/digoal/blog/blob/master/202003/20200324_10.md

PostgreSQL LSM-tree 引擎 - VidarDB (baseon rocksdb) , 更高的插入效率, 牺牲查询效率
https://github.com/digoal/blog/blob/master/202003/20200324_03.md
https://en.wikipedia.org/wiki/Log-structured_merge-tree

2 存储插件

类似存储引擎, 但是可能不是使用am接口扩展的, 使用的可能是fdw接口扩展的

cstore_fdw, ORC存储格式, 更好的压缩效率, 列级别查询效率
https://github.com/citusdata/cstore_fdw

PostgreSQL parquet fdw, 更好的压缩效率, 列级别查询效率
https://github.com/digoal/blog/blob/master/202005/20200527_04.md

vops, 向量+瓦片存储, 大数据分析效率非常高, 提高1个数量级
https://github.com/postgrespro/vops

imcs, 内存列存
https://github.com/knizhnik/imcs

zstd 压缩接口, 提高压缩效率
https://github.com/digoal/blog/blob/master/202003/20200324_38.md

3 扩展索引

rum, 加强版倒排索引, 多值类型(数组、文本向量等)检索加速, 任意字段组合搜索索引过滤
https://github.com/postgrespro/rum
https://github.com/digoal/blog/blob/master/201907/20190706_01.md

zombodb: 创建基于es的索引, 加速搜索, 一种全新解决方案, 降低用户开发成本, 简化应用架构, 解决搜索数据同步问题、延迟等痛点.
https://github.com/zombodb/zombodb
https://github.com/digoal/blog/blob/master/201710/20171001_06.md

pase, 图像识别, 向量检索, 相似特征圈选. 千万级别毫秒响应
https://github.com/digoal/blog/blob/master/202004/20200424_01.md

unknown, 支持自定义距离算法函数的插件, 阿里云, 暂时未发布

4 sharding

plproxy
https://plproxy.github.io/

citus
https://github.com/citusdata/citus

pg_shardman
https://github.com/postgrespro/pg_shardman

sharding 产品级
antdb
https://github.com/ADBSQL/AntDB

pg-xl
https://www.postgres-xl.org/download/

greenplum
https://github.com/greenplum-db/gpdb

hawq
http://hawq.incubator.apache.org/

sharding sphere
https://shardingsphere.apache.org/

5 读写分离

pgpool
http://www.pgpool.org/
《阿里云RDS PostgreSQL 12 + pgpool 的读写分离配置》

《PostgreSQL druid 多个读节点的jdbc loadbalance负载均衡连接串配置》
https://github.com/digoal/blog/blob/master/202002/20200214_03.md

《PostgreSQL libpq|jdbc 驱动层 load balance 与 failover》
https://github.com/digoal/blog/blob/master/201910/20191027_01.md

《PostgreSQL jdbc multi-host 配置与简单HA、Load Balance实现》
https://github.com/digoal/blog/blob/master/201806/20180614_02.md

6 应用扩展功能

pase, 图像识别, 向量检索, 相似特征圈选
https://github.com/digoal/blog/blob/master/202004/20200424_01.md

imgsmlr, 图像识别
https://github.com/digoal/blog/blob/master/201811/20181129_01.md
https://github.com/postgrespro/imgsmlr

pg_roaringbitmap, 用户圈选、实时画像、相似用户扩选功能 . 分析场景功能插件,应用于实时精准营销系统
https://github.com/digoal/blog/blob/master/201911/20191118_01.md

图计算, 图式搜索, 兼容neo4j, 兼容SQL, 降低用户开发成本, 简化应用架构. 支持插件形式, 也支持独立包的形式.
https://github.com/bitnine-oss/agensgraph-ext
https://github.com/bitnine-oss/agensgraph
https://github.com/digoal/blog/blob/master/202003/20200324_01.md
https://github.com/digoal/blog/blob/master/201711/20171103_03.md

流计算, IoT行业常用功能. 利用PG的全栈功能, 既有DBMS能力同时具备流计算能力, 简化IoT应用架构, 建议在被集成场景输出.
https://github.com/pipelinedb/pipelinedb
https://github.com/digoal/blog/blob/master/201811/20181120_02.md

timescaledb 时序数据库引擎
https://github.com/digoal/blog/blob/master/201804/20180420_01.md
https://github.com/timescale/timescaledb

pg_prometheus, IoT常用, 监控产品集成到timescaledb和prometheus
https://github.com/timescale/pg_prometheus

GIS相关
VagueGeometry vague spatial data - VASA (Vague Spatial Algebra) for PG
https://github.com/digoal/blog/blob/master/202003/20200326_02.md

pgsphere
https://pgsphere.github.io/

q3c
https://github.com/segasai/q3c

postgis , 全球最流行的GIS扩展功能模块
http://postgis.org/

h3模块
https://github.com/dlr-eoc/pgh3

pgrouting, 图路由功能
https://pgrouting.org/

《PostgreSQL MOD数据库 MobilityDB - GIS 移动对象处理数据库》
https://github.com/digoal/blog/blob/master/202003/20200324_24.md

《PostgreSQL z-order , morton 排序插件 - GIS常用》
https://github.com/digoal/blog/blob/master/202003/20200324_11.md

《GIS 完整开源解决方案 - Crunchy Spatial - API, Web, GIS, database, 动态矢量瓦片》
https://github.com/digoal/blog/blob/master/202003/20200320_04.md

机器学习 madlib
http://madlib.apache.org/

机器学习 GSL GNU Scientific Library (GSL)
https://github.com/digoal/blog/blob/master/202003/20200326_01.md

文本处理插件 pg_bigm, PGroonga. 任意内容模糊搜索(包括单字和双字的模糊查询)
https://github.com/digoal/blog/blob/master/202003/20200330_01.md

pg_trgm, 实时模糊查询、相似文本查询
https://github.com/digoal/blog/blob/master/201809/20180904_01.md

pg_jieba 中文分词
https://github.com/digoal/blog/blob/master/201607/20160725_02.md

pg_scws 中文分词
https://github.com/jaiminpan/pg_scws

zhparser 中文分词
https://github.com/digoal/blog/blob/master/201603/20160310_01.md

《PostgreSQL 一种高性能中文分词器 - friso》
https://github.com/digoal/blog/blob/master/202003/20200324_17.md

按海明距离高速搜索, 海明距离排序索引
https://github.com/digoal/blog/blob/master/202003/20200326_08.md
https://github.com/digoal/blog/blob/master/202003/20200324_29.md

smlar, 多值类型相似查询, 支持cosine, overlap等相似算法, 例如 标签交叉率相似度, 用户画像相似圈选
http://sigaev.ru/git/gitweb.cgi?p=smlar.git;a=summary

hll, 近似HASH值, 高效UNIQUE近似比对、计算, 滑窗分析. 思想上类似bloom算法, 每个value映射到hash值的某些bit上, 用若干bit位的占位是否为1表示这个value是否存在.
https://github.com/citusdata/postgresql-hll

近似算法库
https://github.com/apache/incubator-datasketches-postgresql

pg_similarity, 17种相似算法
https://github.com/digoal/blog/blob/master/201705/20170524_01.md

rdkit 化学插件, 化学分析行业应用
https://github.com/digoal/blog/blob/master/202003/20200326_06.md
https://github.com/digoal/blog/blob/master/201911/20191125_01.md

orafce, 常用Oracle兼容类型、函数、包
https://github.com/digoal/blog/blob/master/201603/20160324_01.md

pgcrypto, 数据加密模块
https://www.postgresql.org/docs/current/pgcrypto.html

采样查询, 随机数据查询, 比offset random性能提升1万倍
tsm_system_rows
tsm_system_time
https://github.com/digoal/blog/blob/master/202005/20200509_01.md

plv8 , V8存储过程语言
https://github.com/plv8/plv8

《PostgreSQL uids 短hash生成器 - pg_hashids, generate short unique ids from integers》
https://github.com/digoal/blog/blob/master/202003/20200324_22.md

《PostgreSQL period record插件 - 记录的超期设定 , 自动清理记录 , 自动过期 , 生命周期 , 类似redis》
https://github.com/digoal/blog/blob/master/202003/20200324_15.md

《PostgreSQL Unsigned integer types for PostgreSQL》
https://github.com/digoal/blog/blob/master/202003/20200324_14.md

orange3, 可视化分析
https://github.com/digoal/blog/blob/master/202004/20200412_02.md

7 逻辑订阅, decoder

decoder汇总, 用于将PG的增量redo解析成业务想要的格式, 例如json格式, mongo语法格式等.
https://wiki.postgresql.org/wiki/Logical_Decoding_Plugins

wal2json
https://github.com/eulerto/wal2json

decoderbufs
https://github.com/debezium/postgres-decoderbufs

wal2mongo
https://github.com/digoal/blog/blob/master/202004/20200423_02.md

8 逻辑复制、迁移、比较

slony-I, 跨版本的表级别增量同步
https://slony.info/

《使用Londiste3 增量同步 线下PostgreSQL 到 阿里云RDS PG》
https://github.com/digoal/blog/blob/master/201605/20160525_01.md

《MySQL 不落地迁移、导入 PostgreSQL - 推荐 rds_dbsync》
https://github.com/digoal/blog/blob/master/201808/20180815_01.md

《[未完待续] PostgreSQL pglogical 逻辑复制实现跨版本升级、迁移》
https://github.com/digoal/blog/blob/master/201806/20180619_01.md

9 连接池

pgbouncer
http://www.pgbouncer.org/

《PostgreSQL 多线程连接池 - Scalable PostgreSQL connection pooler odyssey》
https://github.com/digoal/blog/blob/master/201906/20190624_01.md

pgagroal
https://github.com/digoal/blog/blob/master/202003/20200320_02.md

内置线程池
https://github.com/digoal/blog/blob/master/201805/20180521_03.md

10 外部表
外部表汇总
https://wiki.postgresql.org/wiki/Foreign_data_wrappers

oracle_fdw
https://github.com/digoal/blog/blob/master/201903/20190311_01.md

mysql_fdw
https://github.com/digoal/blog/blob/master/201112/20111212_01.md

mongo_fdw
https://github.com/digoal/blog/blob/master/201303/20130319_01.md

sqlserver_fdw
https://github.com/tds-fdw/tds_fdw

ogr_fdw
https://github.com/pramsey/pgsql-ogr-fdw

oss_fdw
https://github.com/digoal/blog/blob/master/202001/20200108_01.md

《PostgreSQL clickhousedb外部表 - clickhousedb_fdw》
https://github.com/digoal/blog/blob/master/202003/20200324_27.md

11 外部数据源访问 dblink
pg, oracle, mysql, sqlite dblink plus 打通多种数据库, 解决大型企业跨数据源访问问题(传统企业尤为普遍)
https://github.com/digoal/blog/blob/master/202003/20200324_07.md

12 外部数据访问 udf, 直接使用sql操作其他数据库
memcached
https://github.com/ohmu/pgmemcache

redis
https://github.com/digoal/blog/blob/master/202003/20200326_09.md

kdb+
https://github.com/digoal/blog/blob/master/202003/20200326_11.md

13 灾难恢复

pg_waldump
https://github.com/digoal/blog/blob/master/201512/20151210_01.md

filedump
https://github.com/digoal/blog/blob/master/201703/20170310_03.md

walminer
https://github.com/digoal/blog/blob/master/201902/20190211_01.md

直接修改文件内容
https://github.com/petergeoghegan/pg_hexedit

脏读
https://github.com/df7cb/pg_dirtyread

《PostgreSQL hex edit datafile - 直接打开数据文件并修改》
https://github.com/digoal/blog/blob/master/202003/20200324_26.md

14 安全

sql防火墙
https://github.com/digoal/blog/blob/master/202003/20200320_01.md

ddl回收站
https://github.com/digoal/blog/blob/master/201404/20140403_01.md

sql审计sql audit
https://github.com/digoal/blog/blob/master/201505/20150515_01.md

acl控制
https://github.com/eulerto/pg_restrict

PostgreSQL 权限控制(acl)增强插件 - set_user
https://github.com/digoal/blog/blob/master/202003/20200324_39.md

login hook, 例如审计、发送邮件、profile
https://github.com/digoal/blog/blob/master/202003/20200326_13.md

15 监控、统计类

pgmetrics
https://github.com/digoal/blog/blob/master/201810/20181001_03.md

csvlog 分析, pgbadger
http://pgbadger.darold.net/]()

pgstatsinfo
http://pgstatsinfo.sourceforge.net/]()

pg_stat_statements
https://www.postgresql.org/docs/current/pgstatstatements.html

PostgreSQL-Dashboard
http://daamien.github.io/PostgreSQL-Dashboard/]()

postgrestats
https://www.postgrestats.com/demo/

《PostgreSQL 监控插件 bg_mon - 内置 WEB 服务》
https://github.com/digoal/blog/blob/master/202005/20200527_02.md

pg_logging, log buffer read
价值: 读pip管道中的log内容, 不需要写双份日志
https://github.com/digoal/blog/blob/master/202004/20200403_02.md

16 异构迁移

oracle 2 pg
http://www.ora2pg.com/]()

《PostgreSQL pgloader - 一键迁移 MySQL SQLite MS SQL Redshift, csv dbf ixf archive》
https://github.com/digoal/blog/blob/master/202003/20200324_02.md

17 管理、备份、恢复、诊断、优化类

《PostgreSQL DBA最常用SQL》

《PostgreSQL 活跃会话历史记录插件 - pgsentinel 类似performance insight》
https://github.com/digoal/blog/blob/master/202003/20200324_25.md
https://github.com/digoal/blog/blob/master/201901/20190125_02.md

pg_awr
https://github.com/digoal/blog/blob/master/201611/20161123_01.md

pg_show_plans, 当前query正在使用的执行计划
https://github.com/digoal/blog/blob/master/202004/20200403_04.md

《PostgreSQL long query progress 进度评估》
https://github.com/digoal/blog/blob/master/202003/20200324_12.md

pg_hint_plan, 执行计划hint
http://pghintplan.osdn.jp/pg_hint_plan.html]()

sr_plan, 篡改、固定执行计划
https://github.com/postgrespro/sr_plan

自动执行计划优化, pg_plan_advsr
https://github.com/digoal/blog/blob/master/202003/20200324_33.md

bad plan记录器
https://github.com/digoal/blog/blob/master/202003/20200324_32.md

索引推荐
[https://github.com/powa-team/pg_qualstats
https://github.com/digoal/blog/blob/master/201908/20190804_02.md

并行创建索引 pg_parallizator
https://github.com/digoal/blog/blob/master/202004/20200403_03.md

ha管理插件
https://github.com/digoal/blog/blob/master/202003/20200324_35.md

《PostgreSQL auto failover - PAF - PG高可用集群套件》
https://github.com/digoal/blog/blob/master/202003/20200320_03.md

《[转载] PostgreSQL HA patroni》
https://github.com/digoal/blog/blob/master/201901/20190105_02.md

文件系统级别压缩, 快照备份, 快照克隆, 容灾, zfs
https://github.com/digoal/blog/blob/master/202003/20200321_02.md

《PostgreSQL 最佳实践 - 块级别增量备份(pg_rman baseon LSN)源码浅析与使用》
https://github.com/digoal/blog/blob/master/201608/20160826_01.md

块级别增量备份, ptrack, pg_RMAN
https://github.com/digoal/blog/blob/master/202003/20200326_14.md

多租户, cgroup
https://github.com/MasahikoSawada/pg_cgroup
https://github.com/digoal/blog/blob/master/201905/20190514_01.md

《PostgreSQL 用户进程优先级调度插件 - task schedule - pg_prioritize》
https://github.com/digoal/blog/blob/master/202003/20200324_05.md

《PostgreSQL 磁盘配额功能插件 - diskquota》
https://github.com/digoal/blog/blob/master/202003/20200324_04.md

PostgreSQL dba常用扩展函数库 - pg_cheat_funcs
https://github.com/digoal/blog/blob/master/202003/20200324_41.md

pg_stat_kcache: dba常用功能, 通过sql直接监测实例实时cpu,mem,blockdev等资源消耗.
https://github.com/digoal/blog/blob/master/202003/20200324_28.md

数据库job功能 pg_cron
https://github.com/digoal/blog/blob/master/201305/20130531_01.md

在线垃圾回收, pg_repack
https://github.com/reorg/pg_repack/

《PostgreSQL SQL审计日志回放工具 pgreplay》
https://github.com/digoal/blog/blob/master/202003/20200324_23.md

os pagecache 内存使用标签, pg_fincore 内存标签功能. 热数据可以持久化, 非热数据可以尽快释放内存. 提高内存使用效率.
https://github.com/klando/pgfincore

真实IO统计(不包括os page cache hit) 《PostgreSQL pg_stat_kcache - Gathers statistics about real reads and writes done by the filesystem layer.》
https://github.com/digoal/blog/blob/master/202003/20200324_28.md

icu_ext
https://github.com/dverite/icu_ext

plprofiler, 存储过程profile统计
https://github.com/digoal/blog/blob/master/201611/20161121_02.md

pg_pathman, 分区表性能提升, 自动分区, 自动增加分区等
https://github.com/postgrespro/pg_pathman

log精细化配置, 支持sqlstate code过滤
https://github.com/digoal/blog/blob/master/202003/20200326_16.md

《PostgreSQL 数据结构比对工具 pgquarrel - pg diff》
https://github.com/digoal/blog/blob/master/202003/20200324_18.md

《PostgreSQL pg_top pgcenter - 实时top类工具》
https://github.com/digoal/blog/blob/master/201810/20181003_01.md

通用gpu加速功能
https://github.com/digoal/blog/blob/master/201806/20180602_02.md

《PostgreSQL 数据结构比对工具 pgquarrel - pg diff》
https://github.com/digoal/blog/blob/master/202003/20200324_18.md

18 扩展开发

《PostgreSQL 外围 SQL parser lib库》
https://github.com/digoal/blog/blob/master/202003/20200324_16.md

pgmasq: 只读库实现写功能, 扩展只读库的使用边界.
https://github.com/digoal/blog/blob/master/202003/20200326_12.md

wal 流计算hook,
https://github.com/digoal/blog/blob/master/202003/20200326_24.md

shared buffer 老化算法插件,
https://github.com/digoal/blog/blob/master/202003/20200326_22.md

ctid scan支持block范围搜索
https://github.com/digoal/blog/blob/master/202003/20200326_04.md

aqo优化器
https://github.com/digoal/blog/blob/master/201803/20180322_04.md
[https://github.com/postgrespro/aqo

《PostgreSQL mongodb query 语法兼容插件 - monq》
https://github.com/digoal/blog/blob/master/202003/20200324_08.md

19 内置插件

https://www.postgresql.org/docs/current/contrib.html

用得比较多的插件:

auth_delay, 防止暴力破解
auto_explain, 将慢sql的执行计划写入日志
btree_gin, 普通字段支持gin倒排索引
btree_gist, 普通字段支持gist索引
citext, 忽略大小写的数据类型
dblink, 不解释
earthdistance, 轻量化地球模型类型
file_fdw, 以外部表的形式读写文件
fuzzystrmatch, 语音模糊搜索
intagg, 整型聚合功能扩展
intarray, 整型数组GIST索引扩展功能
lo, 大对象处理
pageinspect, 内窥数据库BLOCK的内容
passwordcheck, 密码复杂度检测
pg_buffercache, 统计数据库shared buffer的内容
pgcrypto, 加密插件
pg_freespacemap, 观察数据库fsm文件内容
pgrowlocks, 行锁统计
pgstattuple, 记录级别统计信息观察
pg_trgm, 模糊查询, 相似文本查询
pg_visibility, 观察数据库block的vm标签值(all visibility, frozen, dirty等)
postgres_fdw, postgresql外部表
spi, 一些常用的跟踪触发器函数, 例如最后变更事件跟踪
test_decoding, 逻辑复制decoder
tsm_system_rows, 采样扩展模块
tsm_system_time, 采样扩展模块
uuid-ossp, UUID生成模块
xml2, XML类型模块
pg_stat_statements, 观察数据库的sql运行统计信息, 例如top sql
cube, cube类型, 支持多种距离排序算法, 也可以用于相似向量搜索
ltree, 树类型
pg_prewarm, buffer预热功能
tablefunc, 行列变换插件

二、可改进点

1 开发者功能

delete|update limit , 适合批量操作
update|delete skip locked , 提升批量并发操作(当前需要select for update skip locked, 然后update. 需要交互几次)
index skip scan optimizer, 目前需要cte递归模拟

2 内核功能

1、数据块级别压缩,
2、undo 引擎, 减少膨胀
3、垃圾回收改进, 只保留需要的版本, 精细化vacuum,目前只有oldest xid一个判断维度。很多可以回收的垃圾并没有回收。
4、global cache , 在大量分区表、或者PaaS用户场景中, 对象特别多, 目前使用的是会话级catalog cache, 可能导致大量的对象元数据内存空间占用, 导致内存大量浪费.
5、flashback query
6、flashback instance, instance snapshot
https://github.com/digoal/blog/blob/master/201809/20180909_01.md
7、全局分区索引
8、DIO
https://github.com/digoal/blog/blob/master/202003/20200326_18.md
9、并行写wal日志, 目前大量数据导入, 可能有两个性能瓶颈, datalbock extend exclusive lock, 或者wal insert exclusive lock
10、按db划分wal, 实现db pluggable功能
11、文件级迁移能力, 降低上云门槛, 提高上云速度(跑满带宽). 市面上支持的:
postgrespro: pg_transport
aws: pg_transport
12、支持增量迁移、备份tbs, db.
https://github.com/digoal/blog/blob/master/202003/20200326_25.md
https://github.com/digoal/blog/blob/master/201910/20191012_01.md
13、gin 支持index scan, 目前当一个key的tuples非常多时, index scan要扫描整个tree, 如果用户发起了limit过滤, 实际上也用不上, 需要全扫, 性能问题.
14、index scan sample method , 对应table sample, 这个是索引扫描的随机采样功能.
15、index search condition pushdown, 支持在索引的branch或leaf 节点增加附加column或表达式value, 当where条件有这些column时, 这些value用于提前过滤, 减少索引扫描或减少回表扫描.
https://github.com/digoal/blog/blob/master/202004/20200429_01.md
16、online ddl, 增强pg_repack
17、多租户功能, rsq, resource queue.
18、多租户功能, 分时动态配置quota
多租户能力, quota, 分时, 分域
多租户,存储配额功能(table级、用户级、schema级别、db级)
paas类业务需求,例如一个企业一个schema的场景,不同企业根据等级分配不同的资源限制。
多租户,资源隔离(会话级、用户级、db级、schema级)
19、基于mvlog的物化视图
20、rotate table, 指定表的大小上限, 记录数上限, lilo, fifo等可配置的数据老化.
21、thread pool
22、上游支持通过 restore command 获取wal并发送给下游
23、基于共享存储的读写, 类似oracle rac
24、全局临时表,
25、持久化shared buffer缓存池,
26、内存表 . 支持配置内存表的异步持久化时间间隔(例如覆盖写一个普通表). 启动时可以选择是否自动加载持久化内容.
https://postgrespro.com/docs/enterprise/11/in-memory
27、logical slot failover功能, 主从复制高可用模式下,当主从发生切换时,逻辑订阅slot信息不丢失.
28、SQL翻译功能(oracle|mysql|ms sql to pg)
29、TDE
30、SGX加密
31、只读实例支持写操作, 只读实例支持写临时对象、写主库操作. 解决只读实例用于分析, 多阶段分析需要临时存储的问题.
https://github.com/digoal/blog/blob/master/202003/20200326_12.md
32、query cache, 重复执行大计算量, 且数据未变化大场景. 性能提升比较明显.
33、内置三节点, 自动failover
34、逻辑订阅支持多master, 全球化部署企业,单元化功能。
[https://github.com/timbira/krahodb
35、内置mpp功能
36、优化器增强(复杂sql, 大量join, 大量子查询, 分析场景)
《PostgreSQL merge join 扫描方法实例细说,以及SQL写法注意 或 内核优化建议 - query rewrite》
37、并行vacuum, 并行checkpoint, 并行wal write (解决essd云盘先天缺陷, 单线程打不满IO的问题)
38、主从半同步
39、standby 支持多上游节点, 主从切换不影响只读实例. (开源版本有一部分概率上游节点发生HA切换后可能需要重新搭建只读库)
40、增强自定义视图、函数安全, 解决自定义函数安全陷阱问题. 当高权限账号不小心调用了攻击者编写的陷阱函数时, 间接帮助攻击者实现提权、越权、破坏等操作.
41、密码遮掩, 在审计日志、视图、dblink、FDW外部表中隐藏密码. (社区版本为明文显示, 有安全风险)
42、pase 向量索引, 相似特征推荐, 图像识别
43、向量距离索引支持自定义距离算法, 方便各个行业和场景自定义算法使用
44、审计日志管道优化, 高吞吐QPS提升1倍
45、函数内支持commit,rollback
46、on disk位图索引,
https://github.com/digoal/blog/blob/master/202003/20200326_23.md
47、基于非易失内存的改良存储引擎,
https://github.com/digoal/blog/blob/master/202003/20200326_19.md
48、支持pl/sql存储过程
https://github.com/digoal/blog/blob/master/202003/20200326_17.md
49、统计信息快照, 支持查询过去的统计信息, 回放sql查询过去的执行计划是否正确
50、在线分区表转换, 在线分裂, 在线合并, 在线转换为分区表
51、慢查询支持等待事件输出, 例如等了什么事件, 等了多久, 便于排查慢sql性能问题.
52、pl/pgsql 代码覆盖测试
[https://github.com/funbringer/pg_linegazer
53、fast open, recovery性能改进. 在recovery时立即打开, 当数据库恢复未达到一致时, 如果用户sql访问到不一致block时, 跳过或报错. 但是可以缩短不可用时间.

三、为什么PG扩展能力这么强

1 hook

基于HOOK, 在hook处增加处理逻辑. 例如, 串改执行计划, 统计qps, ddl回收站, sql防火墙等.

grep -i hook src/tools/pgindent/typedefs.list

ClientAuthentication_hook_type
CoerceParamHook
ExecutorCheckPerms_hook_type
ExecutorEnd_hook_type
ExecutorFinish_hook_type
ExecutorRun_hook_type
ExecutorStart_hook_type
ExplainOneQuery_hook_type
FmgrHookEventType
GucBoolAssignHook
GucBoolCheckHook
GucEnumAssignHook
GucEnumCheckHook
GucIntAssignHook
GucIntCheckHook
GucRealAssignHook
GucRealCheckHook
GucShowHook
GucStringAssignHook
GucStringCheckHook
PGNoticeHooks
PQsslKeyPassHook_type
ParamCompileHook
ParamFetchHook
ParseParamRefHook
ParserSetupHook
PostParseColumnRefHook
PreParseColumnRefHook
ProcessUtility_hook_type
VariableAssignHook
VariableSubstituteHook
check_password_hook_type
create_upper_paths_hook_type
emit_log_hook_type
explain_get_index_name_hook_type
fmgr_hook_type
get_attavgwidth_hook_type
get_index_stats_hook_type
get_relation_info_hook_type
get_relation_stats_hook_type
join_search_hook_type
needs_fmgr_hook_type
object_access_hook_type
openssl_tls_init_hook_typ
planner_hook_type
post_parse_analyze_hook_type
row_security_policy_hook_type
set_join_pathlist_hook_type
set_rel_pathlist_hook_type
shmem_startup_hook_type
grep -r -i hook *|grep “.h”

grep -r -i hook *|grep “.h”|grep typedef

2 开放接口

ud function
ud procedure
ud aggregation
ud type
ud operator
index extend
ud AM(index, table)
ud AM(index)
ud language handler
ud fdw handler
table sample method
custom scan provider
wal custom generate
逻辑decode接口
后台工作进程接口
spi 接口
ecpg接口
package io to extension

参考

https://github.com/digoal/blog/blob/master/README.md

《[未完待续] PostgreSQL\Greenplum Customer视角TODO》

内置插件
https://www.postgresql.org/docs/current/contrib.html

外围插件
https://download.postgresql.org/pub/projects/pgFoundry/
https://api.pgxn.org/src/
https://www.postgresql.org/download/product-categories/
https://www.postgresql.org/docs/current/external-extensions.html
https://github.com/topics/postgresql-extension
https://wiki.postgresql.org/wiki/PostgreSQL_derived_databases
https://github.com/search?l=C&o=desc&q=postgresql&s=stars&type=Repositories
https://osdn.net/softwaremap/trove_list.php?form_cat=66
https://github.com/topics/postgresql?l=C&o=desc&s=stars

最后修改时间:2020-05-28 16:24:05
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
1人已赞赏
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论