Skip to content

Commit 9f984ba

Browse files
committedApr 7, 2021
Add sortsupport for gist_btree opclasses, for faster index builds.
Commit 16fa9b2 introduced a faster way to build GiST indexes, by sorting all the data. This commit adds the sortsupport functions needed to make use of that feature for btree_gist. Author: Andrey Borodin Discussion: https://www.postgresql.org/message-id/2F3F7265-0D22-44DB-AD71-8554C743D943@yandex-team.ru
1 parent dd13ad9 commit 9f984ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1530
-3
lines changed
 

‎contrib/btree_gist/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ EXTENSION = btree_gist
3232
DATA = btree_gist--1.0--1.1.sql \
3333
btree_gist--1.1--1.2.sql btree_gist--1.2.sql btree_gist--1.2--1.3.sql \
3434
btree_gist--1.3--1.4.sql btree_gist--1.4--1.5.sql \
35-
btree_gist--1.5--1.6.sql
35+
btree_gist--1.5--1.6.sql btree_gist--1.6--1.7.sql
3636
PGFILEDESC = "btree_gist - B-tree equivalent GiST operator classes"
3737

3838
REGRESS = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz \

‎contrib/btree_gist/btree_bit.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ PG_FUNCTION_INFO_V1(gbt_bit_picksplit);
1919
PG_FUNCTION_INFO_V1(gbt_bit_consistent);
2020
PG_FUNCTION_INFO_V1(gbt_bit_penalty);
2121
PG_FUNCTION_INFO_V1(gbt_bit_same);
22+
PG_FUNCTION_INFO_V1(gbt_bit_sortsupport);
2223

2324

2425
/* define for comparison */
@@ -209,3 +210,27 @@ gbt_bit_penalty(PG_FUNCTION_ARGS)
209210
PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
210211
&tinfo, fcinfo->flinfo));
211212
}
213+
214+
static int
215+
gbt_bit_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
216+
{
217+
/* Use byteacmp(), like gbt_bitcmp() does */
218+
return DatumGetInt32(DirectFunctionCall2(byteacmp,
219+
PointerGetDatum(a),
220+
PointerGetDatum(b)));
221+
}
222+
223+
/*
224+
* Sort support routine for fast GiST index build by sorting.
225+
*/
226+
Datum
227+
gbt_bit_sortsupport(PG_FUNCTION_ARGS)
228+
{
229+
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
230+
231+
ssup->comparator = gbt_bit_sort_build_cmp;
232+
ssup->abbrev_converter = NULL;
233+
ssup->abbrev_abort = NULL;
234+
ssup->abbrev_full_comparator = NULL;
235+
PG_RETURN_VOID();
236+
}

0 commit comments

Comments
 (0)