Add sortsupport for gist_btree opclasses, for faster index builds.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 7 Apr 2021 10:22:05 +0000 (13:22 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 7 Apr 2021 10:22:05 +0000 (13:22 +0300)
Commit 16fa9b2b30 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

77 files changed:
contrib/btree_gist/Makefile
contrib/btree_gist/btree_bit.c
contrib/btree_gist/btree_bytea.c
contrib/btree_gist/btree_cash.c
contrib/btree_gist/btree_date.c
contrib/btree_gist/btree_enum.c
contrib/btree_gist/btree_float4.c
contrib/btree_gist/btree_float8.c
contrib/btree_gist/btree_gist--1.6--1.7.sql [new file with mode: 0644]
contrib/btree_gist/btree_gist.control
contrib/btree_gist/btree_gist.h
contrib/btree_gist/btree_inet.c
contrib/btree_gist/btree_int2.c
contrib/btree_gist/btree_int4.c
contrib/btree_gist/btree_int8.c
contrib/btree_gist/btree_interval.c
contrib/btree_gist/btree_macaddr.c
contrib/btree_gist/btree_macaddr8.c
contrib/btree_gist/btree_numeric.c
contrib/btree_gist/btree_oid.c
contrib/btree_gist/btree_text.c
contrib/btree_gist/btree_time.c
contrib/btree_gist/btree_ts.c
contrib/btree_gist/btree_uuid.c
contrib/btree_gist/expected/bit.out
contrib/btree_gist/expected/bytea.out
contrib/btree_gist/expected/cash.out
contrib/btree_gist/expected/char.out
contrib/btree_gist/expected/cidr.out
contrib/btree_gist/expected/date.out
contrib/btree_gist/expected/enum.out
contrib/btree_gist/expected/float4.out
contrib/btree_gist/expected/float8.out
contrib/btree_gist/expected/inet.out
contrib/btree_gist/expected/int2.out
contrib/btree_gist/expected/int4.out
contrib/btree_gist/expected/int8.out
contrib/btree_gist/expected/interval.out
contrib/btree_gist/expected/macaddr.out
contrib/btree_gist/expected/macaddr8.out
contrib/btree_gist/expected/numeric.out
contrib/btree_gist/expected/oid.out
contrib/btree_gist/expected/text.out
contrib/btree_gist/expected/time.out
contrib/btree_gist/expected/timestamp.out
contrib/btree_gist/expected/timestamptz.out
contrib/btree_gist/expected/timetz.out
contrib/btree_gist/expected/uuid.out
contrib/btree_gist/expected/varbit.out
contrib/btree_gist/expected/varchar.out
contrib/btree_gist/sql/bit.sql
contrib/btree_gist/sql/bytea.sql
contrib/btree_gist/sql/cash.sql
contrib/btree_gist/sql/char.sql
contrib/btree_gist/sql/cidr.sql
contrib/btree_gist/sql/date.sql
contrib/btree_gist/sql/enum.sql
contrib/btree_gist/sql/float4.sql
contrib/btree_gist/sql/float8.sql
contrib/btree_gist/sql/inet.sql
contrib/btree_gist/sql/int2.sql
contrib/btree_gist/sql/int4.sql
contrib/btree_gist/sql/int8.sql
contrib/btree_gist/sql/interval.sql
contrib/btree_gist/sql/macaddr.sql
contrib/btree_gist/sql/macaddr8.sql
contrib/btree_gist/sql/numeric.sql
contrib/btree_gist/sql/oid.sql
contrib/btree_gist/sql/text.sql
contrib/btree_gist/sql/time.sql
contrib/btree_gist/sql/timestamp.sql
contrib/btree_gist/sql/timestamptz.sql
contrib/btree_gist/sql/timetz.sql
contrib/btree_gist/sql/uuid.sql
contrib/btree_gist/sql/varbit.sql
contrib/btree_gist/sql/varchar.sql
src/backend/access/gist/gistbuild.c

index e92d974a1a3bf77db4b8449e35f29f75a19ba98b..a1f818f71e6ff0b6feff09b17a48dd60829ff0ad 100644 (file)
@@ -32,7 +32,7 @@ EXTENSION = btree_gist
 DATA = btree_gist--1.0--1.1.sql \
        btree_gist--1.1--1.2.sql btree_gist--1.2.sql btree_gist--1.2--1.3.sql \
        btree_gist--1.3--1.4.sql btree_gist--1.4--1.5.sql \
-       btree_gist--1.5--1.6.sql
+       btree_gist--1.5--1.6.sql btree_gist--1.6--1.7.sql
 PGFILEDESC = "btree_gist - B-tree equivalent GiST operator classes"
 
 REGRESS = init int2 int4 int8 float4 float8 cash oid timestamp timestamptz \
index 2225244ded59853141875c439834bd8290048aae..61b2eecfd593bda0c015d6ad674450e09ecfe889 100644 (file)
@@ -19,6 +19,7 @@ PG_FUNCTION_INFO_V1(gbt_bit_picksplit);
 PG_FUNCTION_INFO_V1(gbt_bit_consistent);
 PG_FUNCTION_INFO_V1(gbt_bit_penalty);
 PG_FUNCTION_INFO_V1(gbt_bit_same);
+PG_FUNCTION_INFO_V1(gbt_bit_sortsupport);
 
 
 /* define for comparison */
@@ -209,3 +210,27 @@ gbt_bit_penalty(PG_FUNCTION_ARGS)
    PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
                                      &tinfo, fcinfo->flinfo));
 }
+
+static int
+gbt_bit_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   /* Use byteacmp(), like gbt_bitcmp() does */
+   return DatumGetInt32(DirectFunctionCall2(byteacmp,
+                                            PointerGetDatum(a),
+                                            PointerGetDatum(b)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_bit_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_bit_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index 6b005f0157e29b1e0b059ae636a352b0596f3c04..a2abfb7d7c2726c1cf355e83f7a7e1d1aff6b5f9 100644 (file)
@@ -18,6 +18,7 @@ PG_FUNCTION_INFO_V1(gbt_bytea_picksplit);
 PG_FUNCTION_INFO_V1(gbt_bytea_consistent);
 PG_FUNCTION_INFO_V1(gbt_bytea_penalty);
 PG_FUNCTION_INFO_V1(gbt_bytea_same);
+PG_FUNCTION_INFO_V1(gbt_bytea_sortsupport);
 
 
 /* define for comparison */
@@ -87,7 +88,7 @@ static const gbtree_vinfo tinfo =
 
 
 /**************************************************
- * Text ops
+ * Bytea ops
  **************************************************/
 
 
@@ -168,3 +169,26 @@ gbt_bytea_penalty(PG_FUNCTION_ARGS)
    PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
                                      &tinfo, fcinfo->flinfo));
 }
+
+static int
+gbt_bytea_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   return DatumGetInt32(DirectFunctionCall2(byteacmp,
+                                            PointerGetDatum(a),
+                                            PointerGetDatum(b)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_bytea_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_bytea_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index dfa23224b6f0966346ccbc5e9552760e891cd493..dbd72d3ea08d9abfc10aa21f3237282cc290a56e 100644 (file)
@@ -25,6 +25,7 @@ PG_FUNCTION_INFO_V1(gbt_cash_consistent);
 PG_FUNCTION_INFO_V1(gbt_cash_distance);
 PG_FUNCTION_INFO_V1(gbt_cash_penalty);
 PG_FUNCTION_INFO_V1(gbt_cash_same);
+PG_FUNCTION_INFO_V1(gbt_cash_sortsupport);
 
 static bool
 gbt_cashgt(const void *a, const void *b, FmgrInfo *flinfo)
@@ -216,3 +217,82 @@ gbt_cash_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_cash_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   cashKEY    *ia = (cashKEY *) DatumGetPointer(a);
+   cashKEY    *ib = (cashKEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_cash_abbrev_convert(Datum original, SortSupport ssup)
+{
+   cashKEY    *b1 = (cashKEY *) DatumGetPointer(original);
+   int64       z = b1->lower;
+
+#if SIZEOF_DATUM == 8
+   return Int64GetDatum(z);
+#else
+   return Int32GetDatum(z >> 32);
+#endif
+}
+
+static int
+gbt_cash_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+#if SIZEOF_DATUM == 8
+   int64       a = DatumGetInt64(z1);
+   int64       b = DatumGetInt64(z2);
+#else
+   int32       a = DatumGetInt32(z1);
+   int32       b = DatumGetInt32(z2);
+#endif
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+/*
+ * We never consider aborting the abbreviation.
+ */
+static bool
+gbt_cash_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_cash_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_cash_cmp_abbrev;
+       ssup->abbrev_converter = gbt_cash_abbrev_convert;
+       ssup->abbrev_abort = gbt_cash_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_cash_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_cash_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index 455a265a497538f44c2dbedd8eb603cf945cfc95..3abb6e9c475a0663e33131dcf0bc0d052b85052a 100644 (file)
@@ -25,6 +25,7 @@ PG_FUNCTION_INFO_V1(gbt_date_consistent);
 PG_FUNCTION_INFO_V1(gbt_date_distance);
 PG_FUNCTION_INFO_V1(gbt_date_penalty);
 PG_FUNCTION_INFO_V1(gbt_date_same);
+PG_FUNCTION_INFO_V1(gbt_date_sortsupport);
 
 static bool
 gbt_dategt(const void *a, const void *b, FmgrInfo *flinfo)
@@ -257,3 +258,29 @@ gbt_date_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_date_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   dateKEY    *ia = (dateKEY *) PointerGetDatum(a);
+   dateKEY    *ib = (dateKEY *) PointerGetDatum(b);
+
+   return DatumGetInt32(DirectFunctionCall2(date_cmp,
+                                            DateADTGetDatum(ia->lower),
+                                            DateADTGetDatum(ib->lower)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_date_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_date_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index d4dc38a38e524002e1cb88447aa21ac2f50ee255..e8c5bc5ffe11da10ebd1215ede7955facfe93faa 100644 (file)
@@ -26,6 +26,7 @@ PG_FUNCTION_INFO_V1(gbt_enum_picksplit);
 PG_FUNCTION_INFO_V1(gbt_enum_consistent);
 PG_FUNCTION_INFO_V1(gbt_enum_penalty);
 PG_FUNCTION_INFO_V1(gbt_enum_same);
+PG_FUNCTION_INFO_V1(gbt_enum_sortsupport);
 
 
 static bool
@@ -183,3 +184,72 @@ gbt_enum_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_enum_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   oidKEY     *ia = (oidKEY *) DatumGetPointer(a);
+   oidKEY     *ib = (oidKEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_enum_abbrev_convert(Datum original, SortSupport ssup)
+{
+   oidKEY     *b1 = (oidKEY *) DatumGetPointer(original);
+
+   return ObjectIdGetDatum(b1->lower);
+}
+
+static int
+gbt_enum_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+   Oid         a = DatumGetObjectId(z1);
+   Oid         b = DatumGetObjectId(z2);
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+/*
+ * We never consider aborting the abbreviation.
+ */
+static bool
+gbt_enum_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_enum_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_enum_cmp_abbrev;
+       ssup->abbrev_converter = gbt_enum_abbrev_convert;
+       ssup->abbrev_abort = gbt_enum_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_enum_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_enum_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index 3604c73313a958c3031ca51f31d2c1c86700a8a7..016b2d3d68ffcbfd5f8f70891e0c479f4584ee96 100644 (file)
@@ -23,6 +23,7 @@ PG_FUNCTION_INFO_V1(gbt_float4_consistent);
 PG_FUNCTION_INFO_V1(gbt_float4_distance);
 PG_FUNCTION_INFO_V1(gbt_float4_penalty);
 PG_FUNCTION_INFO_V1(gbt_float4_same);
+PG_FUNCTION_INFO_V1(gbt_float4_sortsupport);
 
 static bool
 gbt_float4gt(const void *a, const void *b, FmgrInfo *flinfo)
@@ -209,3 +210,73 @@ gbt_float4_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+
+static int
+gbt_float4_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   float4KEY  *ia = (float4KEY *) DatumGetPointer(a);
+   float4KEY  *ib = (float4KEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_float4_abbrev_convert(Datum original, SortSupport ssup)
+{
+   float4KEY  *b1 = (float4KEY *) DatumGetPointer(original);
+
+   return Float4GetDatum(b1->lower);
+}
+
+static int
+gbt_float4_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+   float4      a = DatumGetFloat4(z1);
+   float4      b = DatumGetFloat4(z2);
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+/*
+ * We never consider aborting the abbreviation.
+ */
+static bool
+gbt_float4_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_float4_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_float4_cmp_abbrev;
+       ssup->abbrev_converter = gbt_float4_abbrev_convert;
+       ssup->abbrev_abort = gbt_float4_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_float4_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_float4_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index 10a5262aaa7ca98698987fd36b09dae9ce01f347..bee1e4e05e2c70eef36339c1ffcf14e2c1489fc5 100644 (file)
@@ -23,6 +23,7 @@ PG_FUNCTION_INFO_V1(gbt_float8_consistent);
 PG_FUNCTION_INFO_V1(gbt_float8_distance);
 PG_FUNCTION_INFO_V1(gbt_float8_penalty);
 PG_FUNCTION_INFO_V1(gbt_float8_same);
+PG_FUNCTION_INFO_V1(gbt_float8_sortsupport);
 
 
 static bool
@@ -216,3 +217,79 @@ gbt_float8_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_float8_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   float8KEY  *ia = (float8KEY *) DatumGetPointer(a);
+   float8KEY  *ib = (float8KEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_float8_abbrev_convert(Datum original, SortSupport ssup)
+{
+   float8KEY  *b1 = (float8KEY *) DatumGetPointer(original);
+   float8      z = b1->lower;
+
+#if SIZEOF_DATUM == 8
+   return Float8GetDatum(z);
+#else
+   return Float4GetDatum((float4) z);
+#endif
+}
+
+static int
+gbt_float8_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+#if SIZEOF_DATUM == 8
+   float8      a = DatumGetFloat8(z1);
+   float8      b = DatumGetFloat8(z2);
+#else
+   float4      a = DatumGetFloat4(z1);
+   float4      b = DatumGetFloat4(z2);
+#endif
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+static bool
+gbt_float8_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_float8_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_float8_cmp_abbrev;
+       ssup->abbrev_converter = gbt_float8_abbrev_convert;
+       ssup->abbrev_abort = gbt_float8_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_float8_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_float8_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
diff --git a/contrib/btree_gist/btree_gist--1.6--1.7.sql b/contrib/btree_gist/btree_gist--1.6--1.7.sql
new file mode 100644 (file)
index 0000000..abb5b8b
--- /dev/null
@@ -0,0 +1,182 @@
+/* contrib/btree_gist/btree_gist--1.6--1.7.sql */
+
+-- complain if script is sourced in psql, rather than via CREATE EXTENSION
+\echo Use "ALTER EXTENSION btree_gist UPDATE TO '1.7'" to load this file. \quit
+
+
+CREATE FUNCTION gbt_int8_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_int8_ops USING gist ADD
+   FUNCTION    11  (int8, int8) gbt_int8_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_int4_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_int4_ops USING gist ADD
+   FUNCTION    11  (int4, int4) gbt_int4_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_int2_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_int2_ops USING gist ADD
+   FUNCTION    11  (int2, int2) gbt_int2_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_float8_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_float8_ops USING gist ADD
+   FUNCTION    11  (float8, float8) gbt_float8_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_float4_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_float4_ops USING gist ADD
+   FUNCTION    11  (float4, float4) gbt_float4_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_enum_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_enum_ops USING gist ADD
+   FUNCTION    11  (anyenum, anyenum) gbt_enum_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_oid_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_oid_ops USING gist ADD
+   FUNCTION    11  (oid, oid) gbt_oid_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_cash_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_cash_ops USING gist ADD
+   FUNCTION    11  (money, money) gbt_cash_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_inet_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_inet_ops USING gist ADD
+   FUNCTION    11  (inet, inet) gbt_inet_sortsupport (internal) ;
+
+ALTER OPERATOR FAMILY gist_cidr_ops USING gist ADD
+   FUNCTION    11  (cidr, cidr) gbt_inet_sortsupport (internal) ;
+
+
+CREATE FUNCTION gbt_macad_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_macaddr_ops USING gist ADD
+   FUNCTION    11  (macaddr, macaddr) gbt_macad_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_macad8_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_macaddr8_ops USING gist ADD
+   FUNCTION    11  (macaddr8, macaddr8) gbt_macad8_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_numeric_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_numeric_ops USING gist ADD
+   FUNCTION    11  (numeric, numeric) gbt_numeric_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_uuid_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_uuid_ops USING gist ADD
+   FUNCTION    11  (uuid, uuid) gbt_uuid_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_ts_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_timestamp_ops USING gist ADD
+   FUNCTION    11  (timestamp, timestamp) gbt_ts_sortsupport (internal) ;
+
+ALTER OPERATOR FAMILY gist_timestamptz_ops USING gist ADD
+   FUNCTION    11  (timestamptz, timestamptz) gbt_ts_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_text_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_text_ops USING gist ADD
+   FUNCTION    11  (text, text) gbt_text_sortsupport (internal) ;
+
+ALTER OPERATOR FAMILY gist_bpchar_ops USING gist ADD
+   FUNCTION    11  (bpchar, bpchar) gbt_text_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_time_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_time_ops USING gist ADD
+   FUNCTION    11  (time, time) gbt_time_sortsupport (internal) ;
+
+ALTER OPERATOR FAMILY gist_timetz_ops USING gist ADD
+   FUNCTION    11  (timetz, timetz) gbt_time_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_bytea_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_bytea_ops USING gist ADD
+   FUNCTION    11  (bytea, bytea) gbt_bytea_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_date_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_date_ops USING gist ADD
+   FUNCTION    11  (date, date) gbt_date_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_bit_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_bit_ops USING gist ADD
+   FUNCTION    11  (bit, bit) gbt_bit_sortsupport (internal) ;
+
+ALTER OPERATOR FAMILY gist_vbit_ops USING gist ADD
+   FUNCTION    11  (varbit, varbit) gbt_bit_sortsupport (internal) ;
+
+CREATE FUNCTION gbt_intv_sortsupport(internal)
+RETURNS void
+AS 'MODULE_PATHNAME'
+LANGUAGE C IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY gist_interval_ops USING gist ADD
+   FUNCTION    11  (interval, interval) gbt_intv_sortsupport (internal) ;
+
index e5c41fe8f39783247d494d38318bcbb54d672b0b..fa9171a80a2e374866d2b927269c81ab9e1ca3fc 100644 (file)
@@ -1,6 +1,6 @@
 # btree_gist extension
 comment = 'support for indexing common datatypes in GiST'
-default_version = '1.6'
+default_version = '1.7'
 module_pathname = '$libdir/btree_gist'
 relocatable = true
 trusted = true
index 14c7c8ee193a427f4c6c03a754d18ff00f13a8e5..35ad287ed3ddd43b404047ea1b9afa8b0fa67645 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "access/nbtree.h"
 #include "fmgr.h"
+#include "utils/sortsupport.h"
 
 #define BtreeGistNotEqualStrategyNumber 6
 
index e4b3a946b277008c1a9179ef96dbee4fab8faa89..88136128ceeb7861d6b2617b92e92b36b4d20826 100644 (file)
@@ -24,6 +24,7 @@ PG_FUNCTION_INFO_V1(gbt_inet_picksplit);
 PG_FUNCTION_INFO_V1(gbt_inet_consistent);
 PG_FUNCTION_INFO_V1(gbt_inet_penalty);
 PG_FUNCTION_INFO_V1(gbt_inet_same);
+PG_FUNCTION_INFO_V1(gbt_inet_sortsupport);
 
 
 static bool
@@ -186,3 +187,79 @@ gbt_inet_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_inet_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   inetKEY    *ia = (inetKEY *) DatumGetPointer(a);
+   inetKEY    *ib = (inetKEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_inet_abbrev_convert(Datum original, SortSupport ssup)
+{
+   inetKEY    *b1 = (inetKEY *) DatumGetPointer(original);
+   double      z = b1->lower;
+
+#if SIZEOF_DATUM == 8
+   return Float8GetDatum(z);
+#else
+   return Float4GetDatum((float4) z);
+#endif
+}
+
+static int
+gbt_inet_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+#if SIZEOF_DATUM == 8
+   float8      a = DatumGetFloat8(z1);
+   float8      b = DatumGetFloat8(z2);
+#else
+   float4      a = DatumGetFloat4(z1);
+   float4      b = DatumGetFloat4(z2);
+#endif
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+static bool
+gbt_inet_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_inet_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_inet_cmp_abbrev;
+       ssup->abbrev_converter = gbt_inet_abbrev_convert;
+       ssup->abbrev_abort = gbt_inet_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_inet_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_inet_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index a91b95ff3985335bd42f1deb798c7bd377fde26d..38ca3e05da726a74bbdf093f65e986d1d01a6c55 100644 (file)
@@ -24,6 +24,7 @@ PG_FUNCTION_INFO_V1(gbt_int2_consistent);
 PG_FUNCTION_INFO_V1(gbt_int2_distance);
 PG_FUNCTION_INFO_V1(gbt_int2_penalty);
 PG_FUNCTION_INFO_V1(gbt_int2_same);
+PG_FUNCTION_INFO_V1(gbt_int2_sortsupport);
 
 static bool
 gbt_int2gt(const void *a, const void *b, FmgrInfo *flinfo)
@@ -214,3 +215,72 @@ gbt_int2_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_int2_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   int16KEY   *ia = (int16KEY *) DatumGetPointer(a);
+   int16KEY   *ib = (int16KEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_int2_abbrev_convert(Datum original, SortSupport ssup)
+{
+   int16KEY   *b1 = (int16KEY *) DatumGetPointer(original);
+
+   return Int16GetDatum(b1->lower);
+}
+
+static int
+gbt_int2_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+   int16       a = DatumGetInt16(z1);
+   int16       b = DatumGetInt16(z2);
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+/*
+ * We never consider aborting the abbreviation.
+ */
+static bool
+gbt_int2_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_int2_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_int2_cmp_abbrev;
+       ssup->abbrev_converter = gbt_int2_abbrev_convert;
+       ssup->abbrev_abort = gbt_int2_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_int2_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_int2_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index 7ea98c478c73bb33343fabb9f4112f3446c291d5..21bd01ed10dfcf75bcb2f4accbecbfea6b9218f0 100644 (file)
@@ -24,6 +24,7 @@ PG_FUNCTION_INFO_V1(gbt_int4_consistent);
 PG_FUNCTION_INFO_V1(gbt_int4_distance);
 PG_FUNCTION_INFO_V1(gbt_int4_penalty);
 PG_FUNCTION_INFO_V1(gbt_int4_same);
+PG_FUNCTION_INFO_V1(gbt_int4_sortsupport);
 
 
 static bool
@@ -215,3 +216,72 @@ gbt_int4_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_int4_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   int32KEY   *ia = (int32KEY *) DatumGetPointer(a);
+   int32KEY   *ib = (int32KEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_int4_abbrev_convert(Datum original, SortSupport ssup)
+{
+   int32KEY   *b1 = (int32KEY *) DatumGetPointer(original);
+
+   return Int32GetDatum(b1->lower);
+}
+
+static int
+gbt_int4_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+   int32       a = DatumGetInt32(z1);
+   int32       b = DatumGetInt32(z2);
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+/*
+ * We never consider aborting the abbreviation.
+ */
+static bool
+gbt_int4_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_int4_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_int4_cmp_abbrev;
+       ssup->abbrev_converter = gbt_int4_abbrev_convert;
+       ssup->abbrev_abort = gbt_int4_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_int4_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_int4_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index df2b0d174b965fc96baf1cb1467372aa999f6229..b6e7fe68742cbe68d2b133804024d24d20cd0f73 100644 (file)
@@ -24,6 +24,7 @@ PG_FUNCTION_INFO_V1(gbt_int8_consistent);
 PG_FUNCTION_INFO_V1(gbt_int8_distance);
 PG_FUNCTION_INFO_V1(gbt_int8_penalty);
 PG_FUNCTION_INFO_V1(gbt_int8_same);
+PG_FUNCTION_INFO_V1(gbt_int8_sortsupport);
 
 
 static bool
@@ -215,3 +216,82 @@ gbt_int8_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_int8_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   int64KEY   *ia = (int64KEY *) DatumGetPointer(a);
+   int64KEY   *ib = (int64KEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_int8_abbrev_convert(Datum original, SortSupport ssup)
+{
+   int64KEY   *b1 = (int64KEY *) DatumGetPointer(original);
+   int64       z = b1->lower;
+
+#if SIZEOF_DATUM == 8
+   return Int64GetDatum(z);
+#else
+   return Int32GetDatum(z >> 32);
+#endif
+}
+
+static int
+gbt_int8_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+#if SIZEOF_DATUM == 8
+   int64       a = DatumGetInt64(z1);
+   int64       b = DatumGetInt64(z2);
+#else
+   int32       a = DatumGetInt32(z1);
+   int32       b = DatumGetInt32(z2);
+#endif
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+/*
+ * We never consider aborting the abbreviation.
+ */
+static bool
+gbt_int8_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_int8_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_int8_cmp_abbrev;
+       ssup->abbrev_converter = gbt_int8_abbrev_convert;
+       ssup->abbrev_abort = gbt_int8_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_int8_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_int8_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index a4b3b2b1e6fe44fdc5a9a9f01d713a70fc2a5138..0041acd3dddf02e836689cf43da4fce562cb23ef 100644 (file)
@@ -27,6 +27,7 @@ PG_FUNCTION_INFO_V1(gbt_intv_consistent);
 PG_FUNCTION_INFO_V1(gbt_intv_distance);
 PG_FUNCTION_INFO_V1(gbt_intv_penalty);
 PG_FUNCTION_INFO_V1(gbt_intv_same);
+PG_FUNCTION_INFO_V1(gbt_intv_sortsupport);
 
 
 static bool
@@ -297,3 +298,29 @@ gbt_intv_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_intv_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   intvKEY    *ia = (intvKEY *) DatumGetPointer(a);
+   intvKEY    *ib = (intvKEY *) DatumGetPointer(b);
+
+   return DatumGetInt32(DirectFunctionCall2(interval_cmp,
+                                            IntervalPGetDatum(&ia->lower),
+                                            IntervalPGetDatum(&ib->lower)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_intv_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_intv_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index 7f0e9e9c91254b52e55da33a99cc31322ae0b830..805148575d748bcb190549c2e0ed0c7700888543 100644 (file)
@@ -25,6 +25,7 @@ PG_FUNCTION_INFO_V1(gbt_macad_picksplit);
 PG_FUNCTION_INFO_V1(gbt_macad_consistent);
 PG_FUNCTION_INFO_V1(gbt_macad_penalty);
 PG_FUNCTION_INFO_V1(gbt_macad_same);
+PG_FUNCTION_INFO_V1(gbt_macad_sortsupport);
 
 
 static bool
@@ -195,3 +196,80 @@ gbt_macad_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_macad_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   macKEY     *ma = (macKEY *) DatumGetPointer(a);
+   macKEY     *mb = (macKEY *) DatumGetPointer(b);
+   uint64      ia = mac_2_uint64(&ma->lower);
+   uint64      ib = mac_2_uint64(&mb->lower);
+
+   /* for leaf items we expect lower == upper */
+
+   if (ia == ib)
+       return 0;
+
+   return (ia > ib) ? 1 : -1;
+}
+
+static Datum
+gbt_macad_abbrev_convert(Datum original, SortSupport ssup)
+{
+   macKEY     *b1 = (macKEY *) DatumGetPointer(original);
+   uint64      z = mac_2_uint64(&b1->lower);
+
+#if SIZEOF_DATUM == 8
+   return UInt64GetDatum(z);
+#else
+   /* use the high 32 bits of the 48-bit integer */
+   return UInt32GetDatum(z >> 16);
+#endif
+}
+
+static int
+gbt_macad_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+#if SIZEOF_DATUM == 8
+   uint64      a = DatumGetUInt64(z1);
+   uint64      b = DatumGetUInt64(z2);
+#else
+   uint32      a = DatumGetUInt32(z1);
+   uint32      b = DatumGetUInt32(z2);
+#endif
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+static bool
+gbt_macad_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_macad_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_macad_cmp_abbrev;
+       ssup->abbrev_converter = gbt_macad_abbrev_convert;
+       ssup->abbrev_abort = gbt_macad_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_macad_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_macad_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index ab4bca5d50d84766caabefa9cb6a48059929fdd9..a0514727e358bf39e3329f7f4d6fc871ee4b9728 100644 (file)
@@ -25,6 +25,7 @@ PG_FUNCTION_INFO_V1(gbt_macad8_picksplit);
 PG_FUNCTION_INFO_V1(gbt_macad8_consistent);
 PG_FUNCTION_INFO_V1(gbt_macad8_penalty);
 PG_FUNCTION_INFO_V1(gbt_macad8_same);
+PG_FUNCTION_INFO_V1(gbt_macad8_sortsupport);
 
 
 static bool
@@ -195,3 +196,80 @@ gbt_macad8_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_macad8_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   mac8KEY    *ma = (mac8KEY *) DatumGetPointer(a);
+   mac8KEY    *mb = (mac8KEY *) DatumGetPointer(b);
+   uint64      ia = mac8_2_uint64(&ma->lower);
+   uint64      ib = mac8_2_uint64(&mb->lower);
+
+   /* for leaf items we expect lower == upper */
+
+   if (ia == ib)
+       return 0;
+
+   return (ia > ib) ? 1 : -1;
+}
+
+static Datum
+gbt_macad8_abbrev_convert(Datum original, SortSupport ssup)
+{
+   mac8KEY    *b1 = (mac8KEY *) DatumGetPointer(original);
+   uint64      z = mac8_2_uint64(&b1->lower);
+
+#if SIZEOF_DATUM == 8
+   return UInt64GetDatum(z);
+#else
+   /* use the high bits only */
+   return UInt32GetDatum(z >> 32);
+#endif
+}
+
+static int
+gbt_macad8_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+#if SIZEOF_DATUM == 8
+   uint64      a = DatumGetUInt64(z1);
+   uint64      b = DatumGetUInt64(z2);
+#else
+   uint32      a = DatumGetUInt32(z1);
+   uint32      b = DatumGetUInt32(z2);
+#endif
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+static bool
+gbt_macad8_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_macad8_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_macad8_cmp_abbrev;
+       ssup->abbrev_converter = gbt_macad8_abbrev_convert;
+       ssup->abbrev_abort = gbt_macad8_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_macad8_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_macad8_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index 35e466cdd9423a1f43ca68d082b11ddff7753f82..face4e2b3af917e149d69a5a67f51d006953d1b6 100644 (file)
@@ -21,6 +21,7 @@ PG_FUNCTION_INFO_V1(gbt_numeric_picksplit);
 PG_FUNCTION_INFO_V1(gbt_numeric_consistent);
 PG_FUNCTION_INFO_V1(gbt_numeric_penalty);
 PG_FUNCTION_INFO_V1(gbt_numeric_same);
+PG_FUNCTION_INFO_V1(gbt_numeric_sortsupport);
 
 
 /* define for comparison */
@@ -227,3 +228,31 @@ gbt_numeric_picksplit(PG_FUNCTION_ARGS)
                      &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(v);
 }
+
+static int
+gbt_numeric_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   return DatumGetInt32(DirectFunctionCall2(numeric_cmp,
+                                            PointerGetDatum(a),
+                                            PointerGetDatum(b)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_numeric_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_numeric_sort_build_cmp;
+
+   /*
+    * Numeric has abbreviation routines in numeric.c, but we don't try to use
+    * them here. Maybe later.
+    */
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index 3cc7d4245d42b410f15bb4c3ab4500132d46738b..9b7c546aeeb666226581e74a90700f5e7f47f9f7 100644 (file)
@@ -23,6 +23,7 @@ PG_FUNCTION_INFO_V1(gbt_oid_consistent);
 PG_FUNCTION_INFO_V1(gbt_oid_distance);
 PG_FUNCTION_INFO_V1(gbt_oid_penalty);
 PG_FUNCTION_INFO_V1(gbt_oid_same);
+PG_FUNCTION_INFO_V1(gbt_oid_sortsupport);
 
 
 static bool
@@ -215,3 +216,72 @@ gbt_oid_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_oid_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   oidKEY     *ia = (oidKEY *) DatumGetPointer(a);
+   oidKEY     *ib = (oidKEY *) DatumGetPointer(b);
+
+   /* for leaf items we expect lower == upper */
+   Assert(ia->lower == ia->upper);
+   Assert(ib->lower == ib->upper);
+
+   if (ia->lower == ib->lower)
+       return 0;
+
+   return (ia->lower > ib->lower) ? 1 : -1;
+}
+
+static Datum
+gbt_oid_abbrev_convert(Datum original, SortSupport ssup)
+{
+   oidKEY     *b1 = (oidKEY *) DatumGetPointer(original);
+
+   return ObjectIdGetDatum(b1->lower);
+}
+
+static int
+gbt_oid_cmp_abbrev(Datum z1, Datum z2, SortSupport ssup)
+{
+   Oid         a = DatumGetObjectId(z1);
+   Oid         b = DatumGetObjectId(z2);
+
+   if (a > b)
+       return 1;
+   else if (a < b)
+       return -1;
+   else
+       return 0;
+}
+
+/*
+ * We never consider aborting the abbreviation.
+ */
+static bool
+gbt_oid_abbrev_abort(int memtupcount, SortSupport ssup)
+{
+   return false;
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_oid_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   if (ssup->abbreviate)
+   {
+       ssup->comparator = gbt_oid_cmp_abbrev;
+       ssup->abbrev_converter = gbt_oid_abbrev_convert;
+       ssup->abbrev_abort = gbt_oid_abbrev_abort;
+       ssup->abbrev_full_comparator = gbt_oid_sort_build_cmp;
+   }
+   else
+   {
+       ssup->comparator = gbt_oid_sort_build_cmp;
+   }
+   PG_RETURN_VOID();
+}
index 8019d11281952b1c6d0950797dcee13e809d9458..01b1bda2f66b60f963b38f2988c6710ea3b34f96 100644 (file)
@@ -18,6 +18,7 @@ PG_FUNCTION_INFO_V1(gbt_text_consistent);
 PG_FUNCTION_INFO_V1(gbt_bpchar_consistent);
 PG_FUNCTION_INFO_V1(gbt_text_penalty);
 PG_FUNCTION_INFO_V1(gbt_text_same);
+PG_FUNCTION_INFO_V1(gbt_text_sortsupport);
 
 
 /* define for comparison */
@@ -239,3 +240,27 @@ gbt_text_penalty(PG_FUNCTION_ARGS)
    PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
                                      &tinfo, fcinfo->flinfo));
 }
+
+static int
+gbt_text_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   return DatumGetInt32(DirectFunctionCall2Coll(bttextcmp,
+                                                ssup->ssup_collation,
+                                                PointerGetDatum(a),
+                                                PointerGetDatum(b)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_text_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_text_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index fd8774a2f0856e0a1f2b0620213930121f540c85..c021f6751426c92c092ba518f9d351908b6f93a0 100644 (file)
@@ -28,6 +28,7 @@ PG_FUNCTION_INFO_V1(gbt_time_distance);
 PG_FUNCTION_INFO_V1(gbt_timetz_consistent);
 PG_FUNCTION_INFO_V1(gbt_time_penalty);
 PG_FUNCTION_INFO_V1(gbt_time_same);
+PG_FUNCTION_INFO_V1(gbt_time_sortsupport);
 
 
 #ifdef USE_FLOAT8_BYVAL
@@ -332,3 +333,29 @@ gbt_time_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_time_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   timeKEY    *ia = (timeKEY *) DatumGetPointer(a);
+   timeKEY    *ib = (timeKEY *) DatumGetPointer(b);
+
+   return DatumGetInt32(DirectFunctionCall2(time_cmp,
+                                            TimeADTGetDatumFast(ia->lower),
+                                            TimeADTGetDatumFast(ib->lower)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_time_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_time_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index 2671ba961cdae67ec9fa4f180fe083bf38e3a60d..c6ef0782d24da56bb03eca29c1d754b767e0cc28 100644 (file)
@@ -31,6 +31,7 @@ PG_FUNCTION_INFO_V1(gbt_tstz_consistent);
 PG_FUNCTION_INFO_V1(gbt_tstz_distance);
 PG_FUNCTION_INFO_V1(gbt_ts_penalty);
 PG_FUNCTION_INFO_V1(gbt_ts_same);
+PG_FUNCTION_INFO_V1(gbt_ts_sortsupport);
 
 
 #ifdef USE_FLOAT8_BYVAL
@@ -399,3 +400,29 @@ gbt_ts_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_ts_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   tsKEY      *ia = (tsKEY *) DatumGetPointer(a);
+   tsKEY      *ib = (tsKEY *) DatumGetPointer(b);
+
+   return DatumGetInt32(DirectFunctionCall2(timestamp_cmp,
+                                            TimestampGetDatumFast(ia->lower),
+                                            TimestampGetDatumFast(ib->lower)));
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_ts_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_ts_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index b81875979a3b905f09857e0c5f4f4b21a4c24ea6..c802bf95a9072f6019fdaec4e6c767fbe639bb20 100644 (file)
@@ -25,6 +25,7 @@ PG_FUNCTION_INFO_V1(gbt_uuid_picksplit);
 PG_FUNCTION_INFO_V1(gbt_uuid_consistent);
 PG_FUNCTION_INFO_V1(gbt_uuid_penalty);
 PG_FUNCTION_INFO_V1(gbt_uuid_same);
+PG_FUNCTION_INFO_V1(gbt_uuid_sortsupport);
 
 
 static int
@@ -233,3 +234,27 @@ gbt_uuid_same(PG_FUNCTION_ARGS)
    *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
    PG_RETURN_POINTER(result);
 }
+
+static int
+gbt_uuid_sort_build_cmp(Datum a, Datum b, SortSupport ssup)
+{
+   uuidKEY    *ua = (uuidKEY *) DatumGetPointer(a);
+   uuidKEY    *ub = (uuidKEY *) DatumGetPointer(b);
+
+   return uuid_internal_cmp(&ua->lower, &ub->lower);
+}
+
+/*
+ * Sort support routine for fast GiST index build by sorting.
+ */
+Datum
+gbt_uuid_sortsupport(PG_FUNCTION_ARGS)
+{
+   SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+   ssup->comparator = gbt_uuid_sort_build_cmp;
+   ssup->abbrev_converter = NULL;
+   ssup->abbrev_abort = NULL;
+   ssup->abbrev_full_comparator = NULL;
+   PG_RETURN_VOID();
+}
index e57871f310b1487afe35bfd91019faf569cfc8fa..cb2297ce806f4a79beb97377ee9d2e7150302d51 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM bittmp WHERE a >   '011011000100010111011000110000100';
    350
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX bitidx ON bittmp USING GIST ( a );
+DEBUG:  building index "bitidx" on table "bittmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX bitidx_b ON bittmp USING GIST ( a ) WITH (buffering=on);
+DEBUG:  building index "bitidx_b" on table "bittmp" serially
+DROP INDEX bitidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM bittmp WHERE a <   '011011000100010111011000110000100';
  count 
index b9efa73c0855f87d79e8598b56385a02b7d5b46a..170b48e1db90b32f2fad8cf5180806e13825f3a3 100644 (file)
@@ -33,7 +33,14 @@ SELECT count(*) FROM byteatmp WHERE a >   '31b0';
    400
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX byteaidx ON byteatmp USING GIST ( a );
+DEBUG:  building index "byteaidx" on table "byteatmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX byteaidx_b ON byteatmp USING GIST ( a ) WITH (buffering=on);
+DEBUG:  building index "byteaidx_b" on table "byteatmp" serially
+DROP INDEX byteaidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM byteatmp WHERE a <   '31b0'::bytea;
  count 
index 7fbc7355929a1b944ab9738e651b955ee99c29d0..868af70b22ccbbcf1fb8938c7faa0130e7a1a2ae 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '21472.79' FROM moneytmp ORDER BY a <-> '21472.79' LIMIT 3;
  $21,915.01 |  $442.22
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX moneyidx ON moneytmp USING gist ( a );
+DEBUG:  building index "moneyidx" on table "moneytmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX moneyidx_b ON moneytmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "moneyidx_b" on table "moneytmp" serially
+DROP INDEX moneyidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM moneytmp WHERE a <  '22649.64'::money;
  count 
index d715c045cc152a4ca3cb53d4514535a832ac8f86..97316cbb06bd2a7a9b42c615373a3149c8cd08e3 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM chartmp WHERE a >   '31b0'::char(32);
    400
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX charidx ON chartmp USING GIST ( a );
+DEBUG:  building index "charidx" on table "chartmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX charidx_b ON chartmp USING GIST ( a ) WITH (buffering=on);
+DEBUG:  building index "charidx_b" on table "chartmp" serially
+DROP INDEX charidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM chartmp WHERE a <   '31b0'::char(32);
  count 
index 6d0995add60ec54d3a23e76a6baad98120f15ee0..f15597c06a0ff291b59a97c6fbe89b31e7527b98 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM cidrtmp WHERE a >  '121.111.63.82';
    309
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX cidridx ON cidrtmp USING gist ( a );
+DEBUG:  building index "cidridx" on table "cidrtmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX cidridx_b ON cidrtmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "cidridx_b" on table "cidrtmp" serially
+DROP INDEX cidridx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM cidrtmp WHERE a <  '121.111.63.82'::cidr;
  count 
index 5db864bb82caaf0078e8ce6727eb04283fc82a10..5c93d02209c3eee53dd4f6ee776e37d2ab3a94fc 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '2001-02-13' FROM datetmp ORDER BY a <-> '2001-02-13' LIMIT 3;
  03-24-2001 |       39
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX dateidx ON datetmp USING gist ( a );
+DEBUG:  building index "dateidx" on table "datetmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX dateidx_b ON datetmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "dateidx_b" on table "datetmp" serially
+DROP INDEX dateidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM datetmp WHERE a <  '2001-02-13'::date;
  count 
index c4b769dd4b77cc064919cbd750ce3db905ea7823..d73ad33974ddd199fe821c3164d2c1e28c45c01d 100644 (file)
@@ -46,7 +46,14 @@ SELECT count(*) FROM enumtmp WHERE a >  'g'::rainbow;
    230
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX enumidx ON enumtmp USING gist ( a );
+DEBUG:  building index "enumidx" on table "enumtmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX enumidx_b ON enumtmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "enumidx_b" on table "enumtmp" serially
+DROP INDEX enumidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM enumtmp WHERE a <  'g'::rainbow;
  count 
index dfe732049e6d6b7b7b5541ca25047c0b55978657..5f4f1aa4ec5d41a776f18b8d7e90a49e14293278 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
  -158.17741 | 20.822586
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX float4idx ON float4tmp USING gist ( a );
+DEBUG:  building index "float4idx" on table "float4tmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX float4idx_b ON float4tmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "float4idx_b" on table "float4tmp" serially
+DROP INDEX float4idx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM float4tmp WHERE a <  -179.0::float4;
  count 
index ebd0ef3d689a14a40e6ca991352753065c764eba..4db0f7b8282ce269aee9da58fd99c82893d4dfa6 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '-1890.0' FROM float8tmp ORDER BY a <-> '-1890.0' LIMIT 3;
   -1769.73634 | 120.26366000000007
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX float8idx ON float8tmp USING gist ( a );
+DEBUG:  building index "float8idx" on table "float8tmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX float8idx_b ON float8tmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "float8idx_b" on table "float8tmp" serially
+DROP INDEX float8idx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM float8tmp WHERE a <  -1890.0::float8;
  count 
index c323d903da4613211998d24b2f3832c5c9c81f85..0847d3b7d128ae80ecb07f50c3772acc82061b67 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM inettmp WHERE a >  '89.225.196.191';
    386
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX inetidx ON inettmp USING gist ( a );
+DEBUG:  building index "inetidx" on table "inettmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX inetidx_b ON inettmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "inetidx_b" on table "inettmp" serially
+DROP INDEX inetidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM inettmp WHERE a <  '89.225.196.191'::inet;
  count 
index 50a332939bd484c92b92cf8bf0cc117bb1308f73..9ad06a8dce0cb509cbbea1e04f25b255c9e290ca 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '237' FROM int2tmp ORDER BY a <-> '237' LIMIT 3;
  228 |        9
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX int2idx ON int2tmp USING gist ( a );
+DEBUG:  building index "int2idx" on table "int2tmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX int2idx_b ON int2tmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "int2idx_b" on table "int2tmp" serially
+DROP INDEX int2idx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM int2tmp WHERE a <  237::int2;
  count 
index 6bbdc7c3f4bf98b61923dae8237cc816b615b58b..fdf143f32c3215331a71ac07a8d060d8b2ea57ab 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '237' FROM int4tmp ORDER BY a <-> '237' LIMIT 3;
  228 |        9
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX int4idx ON int4tmp USING gist ( a );
+DEBUG:  building index "int4idx" on table "int4tmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX int4idx_b ON int4tmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "int4idx_b" on table "int4tmp" serially
+DROP INDEX int4idx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM int4tmp WHERE a <  237::int4;
  count 
index eff77c26b5adb6e1ddd6c40afb64d74f74262e83..532c4e5e70413f5d9e1987681599b1923aabb4c2 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '464571291354841' FROM int8tmp ORDER BY a <-> '464571291354841'
  478227196042750 | 13655904687909
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX int8idx ON int8tmp USING gist ( a );
+DEBUG:  building index "int8idx" on table "int8tmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX int8idx_b ON int8tmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "int8idx_b" on table "int8tmp" serially
+DROP INDEX int8idx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM int8tmp WHERE a <  464571291354841::int8;
  count 
index 4c3d494e4a656ed4830bb47b0d3b1256b1a308a9..12d50fdf5810f03199dcf057747d380a484c8b7e 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '199 days 21:21:23' FROM intervaltmp ORDER BY a <-> '199 days 21
  @ 220 days 19 hours 5 mins 42 secs  | @ 21 days -2 hours -15 mins -41 secs
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX intervalidx ON intervaltmp USING gist ( a );
+DEBUG:  building index "intervalidx" on table "intervaltmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX intervalidx_b ON intervaltmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "intervalidx_b" on table "intervaltmp" serially
+DROP INDEX intervalidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM intervaltmp WHERE a <  '199 days 21:21:23'::interval;
  count 
index c0a4c6287f3210e6f002be80efb61f4f68b87128..9634000618f53dcd899604e05efacc38a42ce725 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM macaddrtmp WHERE a >  '22:00:5c:e5:9b:0d';
    540
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX macaddridx ON macaddrtmp USING gist ( a );
+DEBUG:  building index "macaddridx" on table "macaddrtmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX macaddridx_b ON macaddrtmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "macaddridx_b" on table "macaddrtmp" serially
+DROP INDEX macaddridx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM macaddrtmp WHERE a <  '22:00:5c:e5:9b:0d'::macaddr;
  count 
index e5ec6a5deab1beaf4d5076b79f05a10cfa3629dd..910223cd3b22e786e947fd4906e1e2e938c001fe 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM macaddr8tmp WHERE a >  '22:00:5c:e5:9b:0d';
    540
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX macaddr8idx ON macaddr8tmp USING gist ( a );
+DEBUG:  building index "macaddr8idx" on table "macaddr8tmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX macaddr8idx_b ON macaddr8tmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "macaddr8idx_b" on table "macaddr8tmp" serially
+DROP INDEX macaddr8idx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM macaddr8tmp WHERE a <  '22:00:5c:e5:9b:0d'::macaddr8;
  count 
index ae839b8ec839d2598b1dd03262365ea14861c405..8dce480c303475db2830f2d43c19ef46cb5e9cc9 100644 (file)
@@ -94,7 +94,14 @@ SELECT count(*) FROM numerictmp WHERE a >  0 ;
    576
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX numericidx ON numerictmp USING gist ( a );
+DEBUG:  building index "numericidx" on table "numerictmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX numericidx_b ON numerictmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "numericidx_b" on table "numerictmp" serially
+DROP INDEX numericidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM numerictmp WHERE a <  -1890.0;
  count 
index 776bbb10267c4366d3a195a41dd818994a87700e..da27172609b305049200862caded1f45c8827e30 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM oidtmp WHERE oid >  17;
    983
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX oididx ON oidtmp USING gist ( oid );
+DEBUG:  building index "oididx" on table "oidtmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX oididx_b ON oidtmp USING gist ( oid ) WITH (buffering=on);
+DEBUG:  building index "oididx_b" on table "oidtmp" serially
+DROP INDEX oididx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM oidtmp WHERE oid <  17;
  count 
index bb4e2e62d1d532d84e85a5043af7fde4f1dc267c..2e760d148714072fcfe3fa569831d678f9354931 100644 (file)
@@ -33,7 +33,14 @@ SELECT count(*) FROM texttmp WHERE a >   '31b0';
    400
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX textidx ON texttmp USING GIST ( a );
+DEBUG:  building index "textidx" on table "texttmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX textidx_b ON texttmp USING GIST ( a ) WITH (buffering=on);
+DEBUG:  building index "textidx_b" on table "texttmp" serially
+DROP INDEX textidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM texttmp WHERE a <   '31b0'::text;
  count 
index ec95ef77c57a668c0f3f8e96393281c5d0f14bcf..9b81e58ed4dbf20a194fc54bebeeb3fe25ec5362 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '10:57:11' FROM timetmp ORDER BY a <-> '10:57:11' LIMIT 3;
  10:55:32 | @ 1 min 39 secs
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX timeidx ON timetmp USING gist ( a );
+DEBUG:  building index "timeidx" on table "timetmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX timeidx_b ON timetmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "timeidx_b" on table "timetmp" serially
+DROP INDEX timeidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM timetmp WHERE a <  '10:57:11'::time;
  count 
index 0d94f2f245ceab9e99d84d39f95d476eba114f5d..8ea9897551c7306843337b9ed83ccbbfd0a01a8e 100644 (file)
@@ -40,7 +40,14 @@ SELECT a, a <-> '2004-10-26 08:55:08' FROM timestamptmp ORDER BY a <-> '2004-10-
  Mon Nov 29 20:12:43 2004 | @ 34 days 11 hours 17 mins 35 secs
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX timestampidx ON timestamptmp USING gist ( a );
+DEBUG:  building index "timestampidx" on table "timestamptmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX timestampidx_b ON timestamptmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "timestampidx_b" on table "timestamptmp" serially
+DROP INDEX timestampidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM timestamptmp WHERE a <  '2004-10-26 08:55:08'::timestamp;
  count 
index 75a15a425684fa1f4ffe78696c1d58105fa2e054..2ba0dcd7ede901dae85e541e46f6f98a91512989 100644 (file)
@@ -100,7 +100,14 @@ SELECT a, a <-> '2018-12-18 10:59:54 GMT+2' FROM timestamptztmp ORDER BY a <-> '
  Thu Jan 24 12:28:12 2019 PST | @ 37 days 7 hours 28 mins 18 secs
 (3 rows)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX timestamptzidx ON timestamptztmp USING gist ( a );
+DEBUG:  building index "timestamptzidx" on table "timestamptztmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX timestamptzidx_b ON timestamptztmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "timestamptzidx_b" on table "timestamptztmp" serially
+DROP INDEX timestamptzidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM timestamptztmp WHERE a <  '2018-12-18 10:59:54 GMT+3'::timestamptz;
  count 
index 7f73e447977251207571204d9ec1da6e7581f3ca..6c855bfcd641052b7f7160ef71bbb9414facf472 100644 (file)
@@ -18,7 +18,14 @@ INSERT INTO timetzcmp (r_id,a) SELECT 22,count(*) FROM timetztmp WHERE a <= '07:
 INSERT INTO timetzcmp (r_id,a) SELECT 23,count(*) FROM timetztmp WHERE a  = '07:46:45 GMT+4';
 INSERT INTO timetzcmp (r_id,a) SELECT 24,count(*) FROM timetztmp WHERE a >= '07:46:45 GMT+4';
 INSERT INTO timetzcmp (r_id,a) SELECT 25,count(*) FROM timetztmp WHERE a >  '07:46:45 GMT+4';
+SET client_min_messages = DEBUG1;
 CREATE INDEX timetzidx ON timetztmp USING gist ( a );
+DEBUG:  building index "timetzidx" on table "timetztmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX timetzidx_b ON timetztmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "timetzidx_b" on table "timetztmp" serially
+DROP INDEX timetzidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 UPDATE timetzcmp SET b=c FROM ( SELECT count(*) AS c FROM timetztmp WHERE a <  '07:46:45 GMT+3'::timetz ) q WHERE r_id=1 ;
 UPDATE timetzcmp SET b=c FROM ( SELECT count(*) AS c FROM timetztmp WHERE a <= '07:46:45 GMT+3'::timetz ) q WHERE r_id=2 ;
index a34b0246032038a8ed65c51fb5afc16102384f57..0f0f2960392b507240bc37df402a42a860db67d8 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM uuidtmp WHERE a >  '55e65ca2-4136-4a4b-ba78-cd3fe4678203';
    375
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX uuididx ON uuidtmp USING gist ( a );
+DEBUG:  building index "uuididx" on table "uuidtmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX uuididx_b ON uuidtmp USING gist ( a ) WITH (buffering=on);
+DEBUG:  building index "uuididx_b" on table "uuidtmp" serially
+DROP INDEX uuididx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM uuidtmp WHERE a <  '55e65ca2-4136-4a4b-ba78-cd3fe4678203'::uuid;
  count 
index ede36bc3ead1fe889d273e3acdb70a1ade5cc33d..9cd41f4c9aaf9d4443718bb7f09a0f7912d3d925 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM varbittmp WHERE a >   '1110100111010';
     50
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX varbitidx ON varbittmp USING GIST ( a );
+DEBUG:  building index "varbitidx" on table "varbittmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX varbitidx_b ON varbittmp USING GIST ( a ) WITH (buffering=on);
+DEBUG:  building index "varbitidx_b" on table "varbittmp" serially
+DROP INDEX varbitidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM varbittmp WHERE a <   '1110100111010'::varbit;
  count 
index d071d714cdddda327af97cddaf685e63b9e990ae..0520eb473155c9781d469bf6bb59419fa2958eaf 100644 (file)
@@ -32,7 +32,14 @@ SELECT count(*) FROM vchartmp WHERE a >   '31b0'::varchar(32);
    400
 (1 row)
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX vcharidx ON vchartmp USING GIST ( text(a) );
+DEBUG:  building index "vcharidx" on table "vchartmp" serially
+DEBUG:  using sorted GiST build
+CREATE INDEX vcharidx_b ON vchartmp USING GIST ( text(a) ) WITH (buffering=on);
+DEBUG:  building index "vcharidx_b" on table "vchartmp" serially
+DROP INDEX vcharidx_b;
+RESET client_min_messages;
 SET enable_seqscan=off;
 SELECT count(*) FROM vchartmp WHERE a <   '31b0'::varchar(32);
  count 
index a733042023f0fa463bdafc1cad12610a8295819e..53c67cf77acfe528b50fecc16f527b7089262c56 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM bittmp WHERE a >=  '011011000100010111011000110000100';
 
 SELECT count(*) FROM bittmp WHERE a >   '011011000100010111011000110000100';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX bitidx ON bittmp USING GIST ( a );
+CREATE INDEX bitidx_b ON bittmp USING GIST ( a ) WITH (buffering=on);
+DROP INDEX bitidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 6885f5e56d5c84c8b6a231b714570dc309130477..fdfa0c345bd523155a92e095556c886f04101cde 100644 (file)
@@ -17,7 +17,11 @@ SELECT count(*) FROM byteatmp WHERE a >=  '31b0';
 
 SELECT count(*) FROM byteatmp WHERE a >   '31b0';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX byteaidx ON byteatmp USING GIST ( a );
+CREATE INDEX byteaidx_b ON byteatmp USING GIST ( a ) WITH (buffering=on);
+DROP INDEX byteaidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 4526cc4f0aa63248b852f105eb73139be5cfe696..0581b3593efa58b8cbd729ce088e60f493fe3556 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM moneytmp WHERE a >  '22649.64';
 
 SELECT a, a <-> '21472.79' FROM moneytmp ORDER BY a <-> '21472.79' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX moneyidx ON moneytmp USING gist ( a );
+CREATE INDEX moneyidx_b ON moneytmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX moneyidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index f6eb52e6724f102e1cf19742b1e3949517500622..234eabee3b8942b4655e1d72cff14d999c15c206 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM chartmp WHERE a >=  '31b0'::char(32);
 
 SELECT count(*) FROM chartmp WHERE a >   '31b0'::char(32);
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX charidx ON chartmp USING GIST ( a );
+CREATE INDEX charidx_b ON chartmp USING GIST ( a ) WITH (buffering=on);
+DROP INDEX charidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 9bd77185b96a8ec9913ff15f7927b787a733dbb4..be2d22b079a62367aeb4d12c50dc7b9a3e01a02f 100644 (file)
@@ -15,7 +15,11 @@ SELECT count(*) FROM cidrtmp WHERE a >= '121.111.63.82';
 
 SELECT count(*) FROM cidrtmp WHERE a >  '121.111.63.82';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX cidridx ON cidrtmp USING gist ( a );
+CREATE INDEX cidridx_b ON cidrtmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX cidridx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index f969ef0a08cb37aaa7fe9745f9642263db6d95e3..f007402bacc7717bed20a9e47a020d02979be5a5 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM datetmp WHERE a >  '2001-02-13';
 
 SELECT a, a <-> '2001-02-13' FROM datetmp ORDER BY a <-> '2001-02-13' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX dateidx ON datetmp USING gist ( a );
+CREATE INDEX dateidx_b ON datetmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX dateidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 476211e97952cdff7cf905437823f9fdd8f2cbe8..d6dbcb423921df3f33b93c39a80bbb0b019016a1 100644 (file)
@@ -20,7 +20,11 @@ SELECT count(*) FROM enumtmp WHERE a >= 'g'::rainbow;
 
 SELECT count(*) FROM enumtmp WHERE a >  'g'::rainbow;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX enumidx ON enumtmp USING gist ( a );
+CREATE INDEX enumidx_b ON enumtmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX enumidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 3da1ce953c8d1471d49236d65e4ab88c447c5460..0e3eb49343ff90187ecc865d1a40d121226cc275 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM float4tmp WHERE a >  -179.0;
 
 SELECT a, a <-> '-179.0' FROM float4tmp ORDER BY a <-> '-179.0' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX float4idx ON float4tmp USING gist ( a );
+CREATE INDEX float4idx_b ON float4tmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX float4idx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index e1e819b37f98c18c50b6eb1eb00752d6ef5fe695..6a216dd6065ba66c1d2a8b5779d26c079ee3bc6d 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM float8tmp WHERE a >  -1890.0;
 
 SELECT a, a <-> '-1890.0' FROM float8tmp ORDER BY a <-> '-1890.0' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX float8idx ON float8tmp USING gist ( a );
+CREATE INDEX float8idx_b ON float8tmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX float8idx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 4b8d354b00ee5b255db0ef8a4e9f228592656a3f..0339c853d38229553a594ac981fb4d5eb0b001ea 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM inettmp WHERE a >= '89.225.196.191';
 
 SELECT count(*) FROM inettmp WHERE a >  '89.225.196.191';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX inetidx ON inettmp USING gist ( a );
+CREATE INDEX inetidx_b ON inettmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX inetidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 988518795fc5631c04e82768c6dcc88f275ebcda..bf98ac65f830537df9d1e5f37a536d46425a48b5 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM int2tmp WHERE a >  237;
 
 SELECT a, a <-> '237' FROM int2tmp ORDER BY a <-> '237' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX int2idx ON int2tmp USING gist ( a );
+CREATE INDEX int2idx_b ON int2tmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX int2idx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 659ab5ee24bbc6d18a5a82d283570d911ca58a1f..214993314afb79cf5a1e4d8395d338d27e254e74 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM int4tmp WHERE a >  237;
 
 SELECT a, a <-> '237' FROM int4tmp ORDER BY a <-> '237' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX int4idx ON int4tmp USING gist ( a );
+CREATE INDEX int4idx_b ON int4tmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX int4idx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 51e55e9c14b87b7c081b69a0f7ec4ba8ebc5757f..8a6c2a4bfd1c807b76435f3abb431247af84589c 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM int8tmp WHERE a >  464571291354841;
 
 SELECT a, a <-> '464571291354841' FROM int8tmp ORDER BY a <-> '464571291354841' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX int8idx ON int8tmp USING gist ( a );
+CREATE INDEX int8idx_b ON int8tmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX int8idx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 346d6adcb51ef44fd3fc95c1d742efd3d0ffcde4..6f9b1d4a39aa02944237aa6019830ab93435ef6e 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM intervaltmp WHERE a >  '199 days 21:21:23';
 
 SELECT a, a <-> '199 days 21:21:23' FROM intervaltmp ORDER BY a <-> '199 days 21:21:23' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX intervalidx ON intervaltmp USING gist ( a );
+CREATE INDEX intervalidx_b ON intervaltmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX intervalidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 85c271f7ce3c6744e55500013542d14945f414b5..bccfc820ca40a4518f8d4571ebcd4dbdc9857b4b 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM macaddrtmp WHERE a >= '22:00:5c:e5:9b:0d';
 
 SELECT count(*) FROM macaddrtmp WHERE a >  '22:00:5c:e5:9b:0d';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX macaddridx ON macaddrtmp USING gist ( a );
+CREATE INDEX macaddridx_b ON macaddrtmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX macaddridx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 61e7d7af405d19078d734cba7ac3b310ed7b2925..2d0447a777b6a40342ad09efa639e0eab4df5956 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM macaddr8tmp WHERE a >= '22:00:5c:e5:9b:0d';
 
 SELECT count(*) FROM macaddr8tmp WHERE a >  '22:00:5c:e5:9b:0d';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX macaddr8idx ON macaddr8tmp USING gist ( a );
+CREATE INDEX macaddr8idx_b ON macaddr8tmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX macaddr8idx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index dbb2f2f1838a8381f11b0f35f93cdeb233b611d5..55ecbcdadc5740edc5afb962c8f21d7c3d30c69c 100644 (file)
@@ -40,7 +40,11 @@ SELECT count(*) FROM numerictmp WHERE a >= 0 ;
 SELECT count(*) FROM numerictmp WHERE a >  0 ;
 
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX numericidx ON numerictmp USING gist ( a );
+CREATE INDEX numericidx_b ON numerictmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX numericidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index c9358234ce9f4af65a16a3cf0b8056c61d878819..bc9ee0cba348d2741f8411c88bae74f23772ef4f 100644 (file)
@@ -15,7 +15,11 @@ SELECT count(*) FROM oidtmp WHERE oid >= 17;
 
 SELECT count(*) FROM oidtmp WHERE oid >  17;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX oididx ON oidtmp USING gist ( oid );
+CREATE INDEX oididx_b ON oidtmp USING gist ( oid ) WITH (buffering=on);
+DROP INDEX oididx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 46597e731d65d81f04d875bd4fd63f63bb98c274..52705a216d111289d341262691954f70807bea36 100644 (file)
@@ -17,7 +17,11 @@ SELECT count(*) FROM texttmp WHERE a >=  '31b0';
 
 SELECT count(*) FROM texttmp WHERE a >   '31b0';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX textidx ON texttmp USING GIST ( a );
+CREATE INDEX textidx_b ON texttmp USING GIST ( a ) WITH (buffering=on);
+DROP INDEX textidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 6104e7f61c8e28ca6dfeca1735a916ce456a0f42..6123945213130df24669622f6f58b0a6d25457fb 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM timetmp WHERE a >  '10:57:11';
 
 SELECT a, a <-> '10:57:11' FROM timetmp ORDER BY a <-> '10:57:11' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX timeidx ON timetmp USING gist ( a );
+CREATE INDEX timeidx_b ON timetmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX timeidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 95effebfc47a7fbf9d9896d7f2e17c37c2107be2..66a14f5ae516ed651e3d72e03496c8b2e305a48f 100644 (file)
@@ -18,7 +18,11 @@ SELECT count(*) FROM timestamptmp WHERE a >  '2004-10-26 08:55:08';
 
 SELECT a, a <-> '2004-10-26 08:55:08' FROM timestamptmp ORDER BY a <-> '2004-10-26 08:55:08' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX timestampidx ON timestamptmp USING gist ( a );
+CREATE INDEX timestampidx_b ON timestamptmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX timestampidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index f70caa4a6492c19d53572ee38520c9e6bd5a6b2d..2a92f63fc4a0a38a011ab878620acd0744a30675 100644 (file)
@@ -39,7 +39,11 @@ SELECT count(*) FROM timestamptztmp WHERE a >  '2018-12-18 10:59:54 GMT+4';
 
 SELECT a, a <-> '2018-12-18 10:59:54 GMT+2' FROM timestamptztmp ORDER BY a <-> '2018-12-18 10:59:54 GMT+2' LIMIT 3;
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX timestamptzidx ON timestamptztmp USING gist ( a );
+CREATE INDEX timestamptzidx_b ON timestamptztmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX timestamptzidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 2fb725db747f52f7453398b029124021f48e871a..bc79d134b8f578e949d75b5a7d87003bca8ed045 100644 (file)
@@ -42,7 +42,11 @@ INSERT INTO timetzcmp (r_id,a) SELECT 25,count(*) FROM timetztmp WHERE a >  '07:
 
 
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX timetzidx ON timetztmp USING gist ( a );
+CREATE INDEX timetzidx_b ON timetztmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX timetzidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 3f7ad764e2db0a79190db79a87abcd21d2d3fbe2..7771bc0d8284c9e468bb4bcecbb75b7a9882abbf 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM uuidtmp WHERE a >= '55e65ca2-4136-4a4b-ba78-cd3fe4678203';
 
 SELECT count(*) FROM uuidtmp WHERE a >  '55e65ca2-4136-4a4b-ba78-cd3fe4678203';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX uuididx ON uuidtmp USING gist ( a );
+CREATE INDEX uuididx_b ON uuidtmp USING gist ( a ) WITH (buffering=on);
+DROP INDEX uuididx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index e2a33b5a1b046ba84fb7c209cc959ebc84ee0b15..6d8243572bf6722f057029e2919370ce9cf4196d 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM varbittmp WHERE a >=  '1110100111010';
 
 SELECT count(*) FROM varbittmp WHERE a >   '1110100111010';
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX varbitidx ON varbittmp USING GIST ( a );
+CREATE INDEX varbitidx_b ON varbittmp USING GIST ( a ) WITH (buffering=on);
+DROP INDEX varbitidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 8087a17704e7a8a416a73b418b053c9c179fadc0..59b77e0983c81fe627e4f889ad3626370625303d 100644 (file)
@@ -16,7 +16,11 @@ SELECT count(*) FROM vchartmp WHERE a >=  '31b0'::varchar(32);
 
 SELECT count(*) FROM vchartmp WHERE a >   '31b0'::varchar(32);
 
+SET client_min_messages = DEBUG1;
 CREATE INDEX vcharidx ON vchartmp USING GIST ( text(a) );
+CREATE INDEX vcharidx_b ON vchartmp USING GIST ( text(a) ) WITH (buffering=on);
+DROP INDEX vcharidx_b;
+RESET client_min_messages;
 
 SET enable_seqscan=off;
 
index 1054f6f1f2e34c996c86052fab10896542ee56df..a90e3de3326b8658e01dfa1ed46dab8ee1ee1f43 100644 (file)
@@ -260,6 +260,7 @@ gistbuild(Relation heap, Relation index, IndexInfo *indexInfo)
        /*
         * Sort all data, build the index from bottom up.
         */
+       elog(DEBUG1, "using sorted GiST build");
        buildstate.sortstate = tuplesort_begin_index_gist(heap,
                                                          index,
                                                          maintenance_work_mem,