热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

PostgreSQL10.0preview功能增强OLAP增强向量聚集索引(列存储扩展)

digoal德哥专栏PostgreSQL10.0preview功能增强-OLAP增强向量聚
TAG 13 , TAG 16

作者

digoal


日期

2017-03-13


标签

PostgreSQL , 10.0 , Vertical Clustered Index (columnar store extension) , 列存储 , 向量聚集索引




背景

未来数据库OLTP+OLAP逐渐模糊化,需求逐渐融合是一个大的趋势,如果你的数据库只支持OLTP的场景,未来可能会成为业务的绊脚石。

在这方面PostgreSQL每年发布的新版本,都给用户很大的惊喜,OLTP已经具备非常强大的竞争力(性能、功能、稳定性、成熟度、案例、跨行业应用等),而OLAP方面,新增的feature也是层出不穷。

《PostgreSQL 10.0 preview 性能增强 - OLAP提速框架, Faster Expression Evaluation Framework(含JIT)》

《分析加速引擎黑科技 - LLVM、列存、多核并行、算子复用 大联姻 - 一起来开启PostgreSQL的百宝箱》

《PostgreSQL 向量化执行插件(瓦片式实现) 10x提速OLAP》

PostgreSQL 10.0将要整合的一个功能:

Vertical Clustered Index (columnar store extension) , 列存储 , 向量聚集索引。

这个模块是Fujitsu实验室提供的,一种新增的VCI索引访问接口,这么做可以最小化数据库的改动。

用户仅需要在原来的堆表上创建VCI即可(向量聚集索引),索引将以向量聚集形式组织,提升查询性能。

VCI有两方面的优化,索引数据分为两个部分:

1. 写优化部分(WOS)

行格式存储(类似堆表),同时携带xmin/xmax标记(事务号),所以如果更新WOS中的数据,和更新PostgreSQL原有的堆表一样效率很高。

PostgreSQL backend process或者autovacuum会持续自动的将WOS中已经frozen的记录(即对所有事务可见的记录),转移到ROS(读优化部分)存储。

ROS存储中,没有版本信息(XMIN/XMAX),有tuple id,可以通过tuple id访问ROS中的记录。(没有版本信息,如何判断可见性呢?后面讲)

2. 读优化部分(ROS)

ROS为列存储,每列一个或一批文件,在ROS中,记录是以extent来组织的,每个extent存储262,144行记录,可以方便的建立堆表TID to ROS CRID的映射关系。

插入vci记录,与插入索引一样。(插入WOS,后台自动将frozen记录合并到ROS)

删除vci记录,如果数据只在WOS中,删除和删堆表记录一样,做标记,如果数据已经从WOS合并到ROS,那么需要维护一个向量,这个向量中包含被删除的记录在ROS中的tuple id, 以及删除该记录的事务的xact id等。读取ROS时,根据这个向量,过滤ros中对应的tuple id.

更新vci记录,与删除类似。

目前提供的性能测试数据

pic

pic

pic

讨论

```

Hi All,

Fujitsu was interested in developing a columnar storage extension with

minimal

changes the server backend.

The columnar store is implemented as an extension using index access

methods.

This can be easily enhanced with pluggable storage methods once they are

available.

A new index method (VCI) is added to create columnar index on the table.

The following is the basic design idea of the columnar extension,

This has the on-disk columnar representation. So, even after crash,

the columnar format is recovered to the state when it was crashed.

To provide performance benefit for both read and write operations,

the data is stored in two formats

1) write optimized storage (WOS)

2) read optimized storage (ROS).

This is useful for the users where there is a great chance of data

modification

that is newly added instead of the old data.


WOS

write optimized storage is the data of all columns that are part of VCI are

stored in a row wise format. All the newly added data is stored in WOS

relation with xmin/xmax information also. If user wants to update/delete the

newly added data, it doesn't affect the performance much compared to

deleting the data from columnar storage.

The tuples which don't have multiple copies or frozen data will be moved

from WOS to ROS periodically by the background worker process or autovauum

process. Every column data is stored separately in it's relation file. There

is no transaction information is present in ROS. The data in ROS can be

referred with tuple ID.

In this approach, the column data is present in both heap and columnar

storage.


ROS

This is the place, where all the column data is stored in columnar format.

The data from WOS to ROS is converted by background workers continously

based

on the tuple visibility check. Whenever the tuple is frozen and it gets

moved

from WOS to ROS.

The Data in ROS is stored in extents. One extent contains of 262,144 rows.

Because

of fixed number of records in an extent it is easy to map the heap record

to the columnar

record with TID to CRID map.


Insert

The insert operation is just like inserting a data into an index.


Select

Because of two storage formats, during the select operation, the data in WOS

is converted into Local ROS for the statement to be executed. The conversion

cost depends upon the number of tuples present in the WOS file. This

may add some performance overhead for select statements. The life of the

Local

ROS is till the end of query context.


Delete

During the delete operation, whenever the data is deleted in heap at the

same

time the data in WOS file is marked as deleted similar like heap. But in

case

if the data is already migrated from WOS to ROS, then we will maintain some

delete vector to store the details of tuple id, transaction information and

etc.

During the data read from ROS file, it is verified against delete vector

and

confirms whether the record is visible or not? All the delete vectors

data is applied to ROS periodically.

More details of internal relations and their usage is available in the

README.

Still it needs more updates to explain full details of the columnar index

design.

The concept of Vertical clustered index columnar extension is from Fujitsu

Labs, Japan.

Following is the brief schedule of patches that are required

for a better performing columnar store.



  1. Minimal server changes (new relkind "CSTORE" option)

  2. Base storage patch

  3. Support for moving data from WOS to ROS

  4. Local ROS support

  5. Custom scan support to read the data from ROS and Local ROS

  6. Background worker support for data movement

  7. Expression state support in VCI

  8. Aggregation support in VCI

  9. Pg_dump support for the new type of relations

  10. psql \d command support for CSTORE relations

  11. Parallelism support

  12. Compression support

  13. In-memory support with dynamic shared memory

Currently I attached only patches for 1 and 2. These will provide the

basic changes that are required in PostgreSQL core to the extension

to work.

I have to rebase/rewrite the rest of the patches to the latest master,

and share them with community.

Any Comments on the approach?

Regards,

Hari Babu

Fujitsu Australia

```

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

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


参考

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

https://www.postgresql.org/message-id/flat/CAJrrPGfaC7WC9NK6PTTy6YN-NN+hCy8xOLAh2doYhVg5d6HsAA@mail.gmail.com#CAJrrPGfaC7WC9NK6PTTy6YN-NN+hCy8xOLAh2doYhVg5d6HsAA@mail.gmail.com

《分析加速引擎黑科技 - LLVM、列存、多核并行、算子复用 大联姻 - 一起来开启PostgreSQL的百宝箱》

《PostgreSQL 向量化执行插件(瓦片式实现) 10x提速OLAP》

《PostgreSQL 10.0 preview 性能增强 - OLAP提速框架, Faster Expression Evaluation Framework(含JIT)》


PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.


9.9元购买3个月阿里云RDS PostgreSQL实例


PostgreSQL 解决方案集合


德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat


推荐阅读
  • 31.项目部署
    目录1一些概念1.1项目部署1.2WSGI1.3uWSGI1.4Nginx2安装环境与迁移项目2.1项目内容2.2项目配置2.2.1DEBUG2.2.2STAT ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • 解决Cydia数据库错误:could not open file /var/lib/dpkg/status 的方法
    本文介绍了解决iOS系统中Cydia数据库错误的方法。通过使用苹果电脑上的Impactor工具和NewTerm软件,以及ifunbox工具和终端命令,可以解决该问题。具体步骤包括下载所需工具、连接手机到电脑、安装NewTerm、下载ifunbox并注册Dropbox账号、下载并解压lib.zip文件、将lib文件夹拖入Books文件夹中,并将lib文件夹拷贝到/var/目录下。以上方法适用于已经越狱且出现Cydia数据库错误的iPhone手机。 ... [详细]
  • Oracle seg,V$TEMPSEG_USAGE与Oracle排序的关系及使用方法
    本文介绍了Oracle seg,V$TEMPSEG_USAGE与Oracle排序之间的关系,V$TEMPSEG_USAGE是V_$SORT_USAGE的同义词,通过查询dba_objects和dba_synonyms视图可以了解到它们的详细信息。同时,还探讨了V$TEMPSEG_USAGE的使用方法。 ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
  • LVS实现负载均衡的原理LVS负载均衡负载均衡集群是LoadBalance集群。是一种将网络上的访问流量分布于各个节点,以降低服务器压力,更好的向客户端 ... [详细]
  • 1.官网下载了mysql-5.7.17-win64.zip包,配置遇到很多麻烦,记录一下;2.解压后放到指定的文件夹,修改mysql-5.7.17的配置文件my-default.i ... [详细]
  • Nginx使用(server参数配置)
    本文介绍了Nginx的使用,重点讲解了server参数配置,包括端口号、主机名、根目录等内容。同时,还介绍了Nginx的反向代理功能。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 如何使用Java获取服务器硬件信息和磁盘负载率
    本文介绍了使用Java编程语言获取服务器硬件信息和磁盘负载率的方法。首先在远程服务器上搭建一个支持服务端语言的HTTP服务,并获取服务器的磁盘信息,并将结果输出。然后在本地使用JS编写一个AJAX脚本,远程请求服务端的程序,得到结果并展示给用户。其中还介绍了如何提取硬盘序列号的方法。 ... [详细]
  • Go语言实现堆排序的详细教程
    本文主要介绍了Go语言实现堆排序的详细教程,包括大根堆的定义和完全二叉树的概念。通过图解和算法描述,详细介绍了堆排序的实现过程。堆排序是一种效率很高的排序算法,时间复杂度为O(nlgn)。阅读本文大约需要15分钟。 ... [详细]
author-avatar
CC周兵价_667
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有