本文主要是介绍PG/GP排序中的abbreviated key,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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
这篇关于PG/GP排序中的abbreviated key的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!