首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >PG/GP排序中的abbreviated key

PG/GP排序中的abbreviated key

作者头像
yzsDBA
发布2022-04-27 15:30:28
4470
发布2022-04-27 15:30:28
举报

PG/GP排序私有状态结构Tuplesortstate中有一个成员SortSupport sortKeys;而sortKeys中有这么几个成员abbreviate、abbrev***:

"abbreviate" concerns whether or not the abbreviated key optimization is applicable in principle。也就是说可以使用此进行一个缩写key优化。那么这个优化是什么呢?

这个是9.6引入的新特性,看下它的patch介绍:

Add sort support routine for the UUID data type. This introduces a simple encoding scheme to produce abbreviated keys: pack as many bytes of each UUID as will fit into a Datum. On little-endian machines, a byteswap is also performed; the abbreviated comparator can therefore just consist of a simple 3-way unsigned integer comparison.The purpose of this change is to speed up sorting data on a column of type UUID.

Make abbreviated key comparisons for text a bit cheaper.If we do some byte-swapping while abbreviating, we can do comparisons using integer arithmetic rather than memcmp.

也就是对uuid,bytea,char(n)的排序性能增强,使用abb keys, 整型比较算法取代memcmp。

Patch地址:

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

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

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-04-20,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 yanzongshuaiDBA 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档