天天看點

PostgreSQL 9.6 核心優化 - sort 性能增強

digoal

2016-10-09

postgresql , sort , 核心優化

postgresql 9.6在排序這塊做了一些性能增強,前面一篇主要講了排序算法的變更。

<a href="https://github.com/digoal/blog/blob/master/201610/20161008_02.md">《postgresql 9.6 核心優化 - sort性能增強(batch化quicksort代替replacement selection when work_mem small)》</a>

本文針對另外幾個sort增強的點再簡單介紹一下。

1. 文本排序性能增強,當相同的文本多次出現時,性能有所增強。

speed up text sorts where the same string occurs multiple times (peter geoghegan)

<a href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=0e57b4d8bd9674adaf5747421b3255b85e385534">https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=0e57b4d8bd9674adaf5747421b3255b85e385534</a>

2. 對uuid,bytea,char(n)的排序性能增強,使用abb keys, 整型比較算法取代memcmp。

speed up sorting of uuid, bytea, and char(n) fields by using "abbreviated" keys (peter geoghegan)

support for abbreviated keys has also been added to the non-default operator classes text_pattern_ops, varchar_pattern_ops, and bpchar_pattern_ops.

processing of ordered-set aggregates can also now exploit abbreviated keys.

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

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

3. 并行建立索引(非堵塞式)的性能增強

speed up create index concurrently by treating tids as 64-bit integers during sorting (peter geoghegan)

<a href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=b648b70342fbe712383e8cd76dc8f7feaba9aaa3">https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=b648b70342fbe712383e8cd76dc8f7feaba9aaa3</a>

1. 高度重複文本排序

1000萬記錄

1.1 postgresql 9.5

排序耗時7.9秒

1.2 postgresql 9.6

排序耗時6.9秒

2. 離散文本排序

2.1 postgresql 9.5

排序耗時19.9秒

2.2 postgresql 9.6

排序耗時15秒

3. char(n)排序

3.1 postgresql 9.5

排序耗時27.8秒

3.2 postgresql 9.6

排序耗時16.2秒

4. 非堵塞式建立索引

5000萬随機資料

4.1 postgresql 9.5

4.2 postgresql 9.6

5. 堵塞式建立索引

5.1 postgresql 9.5

5.2 postgresql 9.6

1. 高度重複文本排序(1000萬記錄)

postgresql 9.5 排序耗時7.9秒

postgresql 9.6 排序耗時6.9秒

2. 離散文本排序(1000萬記錄),quicksort的優化

postgresql 9.5 排序耗時19.9秒

postgresql 9.6 排序耗時15秒

3. char(n)排序(1000萬記錄)

postgresql 9.5 排序耗時27.8秒

postgresql 9.6 排序耗時16.2秒

4. 非堵塞式建立索引(5000萬記錄)

postgresql 9.5 排序耗時92.6秒

postgresql 9.6 排序耗時56.5秒

5. 堵塞式建立索引(5000萬記錄)

postgresql 9.5 排序耗時40.7秒

postgresql 9.6 排序耗時40.7秒

<a href="http://info.flagcounter.com/h9v1">count</a>

繼續閱讀