Remove no-op GiST support functions in the core GiST opclasses.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 20 Sep 2017 03:32:45 +0000 (23:32 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 20 Sep 2017 03:32:59 +0000 (23:32 -0400)
The preceding patch allowed us to remove useless GiST support functions.
This patch actually does that for all the no-op cases in the core GiST
code.  This buys us whatever performance gain is to be had, and more
importantly exercises the preceding patch.

There remain no-op functions in the contrib GiST opclasses, but those
will take more work to remove.

Discussion: https://postgr.es/m/CAJEAwVELVx9gYscpE=Be6iJxvdW5unZ_LkcAaVNSeOwvdwtD=A@mail.gmail.com

src/backend/access/gist/gistproc.c
src/backend/utils/adt/network_gist.c
src/backend/utils/adt/rangetypes_gist.c
src/backend/utils/adt/tsgistidx.c
src/backend/utils/adt/tsquery_gist.c
src/include/catalog/catversion.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_proc.h
src/test/regress/expected/create_am.out
src/test/regress/sql/create_am.sql

index 08990f5a1be7daaae2aa84e07b595e56af488aa7..d1919fc74bc69b3809dcf3c4f0ad9579b4baf877 100644 (file)
@@ -185,37 +185,9 @@ gist_box_union(PG_FUNCTION_ARGS)
 }
 
 /*
- * GiST Compress methods for boxes
- *
- * do not do anything.
+ * We store boxes as boxes in GiST indexes, so we do not need
+ * compress, decompress, or fetch functions.
  */
-Datum
-gist_box_compress(PG_FUNCTION_ARGS)
-{
-   PG_RETURN_POINTER(PG_GETARG_POINTER(0));
-}
-
-/*
- * GiST DeCompress method for boxes (also used for points, polygons
- * and circles)
- *
- * do not do anything --- we just use the stored box as is.
- */
-Datum
-gist_box_decompress(PG_FUNCTION_ARGS)
-{
-   PG_RETURN_POINTER(PG_GETARG_POINTER(0));
-}
-
-/*
- * GiST Fetch method for boxes
- * do not do anything --- we just return the stored box as is.
- */
-Datum
-gist_box_fetch(PG_FUNCTION_ARGS)
-{
-   PG_RETURN_POINTER(PG_GETARG_POINTER(0));
-}
 
 /*
  * The GiST Penalty method for boxes (also used for points)
index a0097dae9c56fa1a42dadf3ae7ba33e0f1498029..0e36b7685de97b13cf6230bc66db29770cd65376 100644 (file)
@@ -576,17 +576,9 @@ inet_gist_compress(PG_FUNCTION_ARGS)
 }
 
 /*
- * The GiST decompress function
- *
- * do not do anything --- we just use the stored GistInetKey as-is.
+ * We do not need a decompress function, because the other GiST inet
+ * support functions work with the GistInetKey representation.
  */
-Datum
-inet_gist_decompress(PG_FUNCTION_ARGS)
-{
-   GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
-
-   PG_RETURN_POINTER(entry);
-}
 
 /*
  * The GiST fetch function
index cb2d5a3b73ae2009c6e32f8c379b25e4586173dc..29fa1ae325ba4d46ea4faaf416c7ef27467083d9 100644 (file)
@@ -216,30 +216,11 @@ range_gist_union(PG_FUNCTION_ARGS)
    PG_RETURN_RANGE_P(result_range);
 }
 
-/* compress, decompress, fetch are no-ops */
-Datum
-range_gist_compress(PG_FUNCTION_ARGS)
-{
-   GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
-
-   PG_RETURN_POINTER(entry);
-}
-
-Datum
-range_gist_decompress(PG_FUNCTION_ARGS)
-{
-   GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
-
-   PG_RETURN_POINTER(entry);
-}
-
-Datum
-range_gist_fetch(PG_FUNCTION_ARGS)
-{
-   GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
-
-   PG_RETURN_POINTER(entry);
-}
+/*
+ * We store ranges as ranges in GiST indexes, so we do not need
+ * compress, decompress, or fetch functions.  Note this implies a limit
+ * on the size of range values that can be indexed.
+ */
 
 /*
  * GiST page split penalty function.
index 732d87f22ffb81d118a50e24b31be760a5922075..578af5d5126637b5064289b5ac3d2c90d3c66402 100644 (file)
@@ -272,6 +272,10 @@ gtsvector_compress(PG_FUNCTION_ARGS)
 Datum
 gtsvector_decompress(PG_FUNCTION_ARGS)
 {
+   /*
+    * We need to detoast the stored value, because the other gtsvector
+    * support functions don't cope with toasted values.
+    */
    GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
    SignTSVector *key = (SignTSVector *) PG_DETOAST_DATUM(entry->key);
 
index 85518dc7d9f1070ed7be25ffc23906a7cfc44a06..05bc0d6adb36aa15425f220a31f6ba33010ff802 100644 (file)
@@ -43,11 +43,10 @@ gtsquery_compress(PG_FUNCTION_ARGS)
    PG_RETURN_POINTER(retval);
 }
 
-Datum
-gtsquery_decompress(PG_FUNCTION_ARGS)
-{
-   PG_RETURN_DATUM(PG_GETARG_DATUM(0));
-}
+/*
+ * We do not need a decompress function, because the other gtsquery
+ * support functions work with the compressed representation.
+ */
 
 Datum
 gtsquery_consistent(PG_FUNCTION_ARGS)
index 032b244fb89a13f1d39c7bab48cef03a613c3677..5d57a95d8bb222fe3cc7706e623d2f1e832e8fd6 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 201709131
+#define CATALOG_VERSION_NO 201709191
 
 #endif
index fb6a829c90ce74a0a5084d229fdf4bc12e0f9860..1c958462074b8e2746a53a4c736b1f206f61a45f 100644 (file)
@@ -230,7 +230,6 @@ DATA(insert (   4034   3802 3802 2 3416));
 DATA(insert (  1029   600 600 1 2179 ));
 DATA(insert (  1029   600 600 2 2583 ));
 DATA(insert (  1029   600 600 3 1030 ));
-DATA(insert (  1029   600 600 4 2580 ));
 DATA(insert (  1029   600 600 5 2581 ));
 DATA(insert (  1029   600 600 6 2582 ));
 DATA(insert (  1029   600 600 7 2584 ));
@@ -238,16 +237,12 @@ DATA(insert ( 1029   600 600 8 3064 ));
 DATA(insert (  1029   600 600 9 3282 ));
 DATA(insert (  2593   603 603 1 2578 ));
 DATA(insert (  2593   603 603 2 2583 ));
-DATA(insert (  2593   603 603 3 2579 ));
-DATA(insert (  2593   603 603 4 2580 ));
 DATA(insert (  2593   603 603 5 2581 ));
 DATA(insert (  2593   603 603 6 2582 ));
 DATA(insert (  2593   603 603 7 2584 ));
-DATA(insert (  2593   603 603 9 3281 ));
 DATA(insert (  2594   604 604 1 2585 ));
 DATA(insert (  2594   604 604 2 2583 ));
 DATA(insert (  2594   604 604 3 2586 ));
-DATA(insert (  2594   604 604 4 2580 ));
 DATA(insert (  2594   604 604 5 2581 ));
 DATA(insert (  2594   604 604 6 2582 ));
 DATA(insert (  2594   604 604 7 2584 ));
@@ -255,7 +250,6 @@ DATA(insert (   2594   604 604 8 3288 ));
 DATA(insert (  2595   718 718 1 2591 ));
 DATA(insert (  2595   718 718 2 2583 ));
 DATA(insert (  2595   718 718 3 2592 ));
-DATA(insert (  2595   718 718 4 2580 ));
 DATA(insert (  2595   718 718 5 2581 ));
 DATA(insert (  2595   718 718 6 2582 ));
 DATA(insert (  2595   718 718 7 2584 ));
@@ -270,22 +264,17 @@ DATA(insert ( 3655   3614 3614 7 3652 ));
 DATA(insert (  3702   3615 3615 1 3701 ));
 DATA(insert (  3702   3615 3615 2 3698 ));
 DATA(insert (  3702   3615 3615 3 3695 ));
-DATA(insert (  3702   3615 3615 4 3696 ));
 DATA(insert (  3702   3615 3615 5 3700 ));
 DATA(insert (  3702   3615 3615 6 3697 ));
 DATA(insert (  3702   3615 3615 7 3699 ));
 DATA(insert (  3919   3831 3831 1 3875 ));
 DATA(insert (  3919   3831 3831 2 3876 ));
-DATA(insert (  3919   3831 3831 3 3877 ));
-DATA(insert (  3919   3831 3831 4 3878 ));
 DATA(insert (  3919   3831 3831 5 3879 ));
 DATA(insert (  3919   3831 3831 6 3880 ));
 DATA(insert (  3919   3831 3831 7 3881 ));
-DATA(insert (  3919   3831 3831 9 3996 ));
 DATA(insert (  3550   869 869 1 3553 ));
 DATA(insert (  3550   869 869 2 3554 ));
 DATA(insert (  3550   869 869 3 3555 ));
-DATA(insert (  3550   869 869 4 3556 ));
 DATA(insert (  3550   869 869 5 3557 ));
 DATA(insert (  3550   869 869 6 3558 ));
 DATA(insert (  3550   869 869 7 3559 ));
index f73c6c6201ac13f26d3d3abf061da890f5f3d2f9..93c031aad73bcd57708ef97bec942549ab0df630 100644 (file)
@@ -2293,8 +2293,6 @@ DATA(insert OID = 3554 (  inet_gist_union     PGNSP PGUID 12 1 0 0 0 f f f f t f i
 DESCR("GiST support");
 DATA(insert OID = 3555 (  inet_gist_compress   PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ inet_gist_compress _null_ _null_ _null_ ));
 DESCR("GiST support");
-DATA(insert OID = 3556 (  inet_gist_decompress PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ inet_gist_decompress _null_ _null_ _null_ ));
-DESCR("GiST support");
 DATA(insert OID = 3573 (  inet_gist_fetch      PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ inet_gist_fetch _null_ _null_ _null_ ));
 DESCR("GiST support");
 DATA(insert OID = 3557 (  inet_gist_penalty        PGNSP PGUID 12 1 0 0 0 f f f f t f i s 3 0 2281 "2281 2281 2281" _null_ _null_ _null_ _null_ _null_ inet_gist_penalty _null_ _null_ _null_ ));
@@ -4310,12 +4308,6 @@ DATA(insert OID = 2588 (  circle_overabove       PGNSP PGUID 12 1 0 0 0 f f f f t f i
 /* support functions for GiST r-tree emulation */
 DATA(insert OID = 2578 (  gist_box_consistent  PGNSP PGUID 12 1 0 0 0 f f f f t f i s 5 0 16 "2281 603 21 26 2281" _null_ _null_ _null_ _null_ _null_  gist_box_consistent _null_ _null_ _null_ ));
 DESCR("GiST support");
-DATA(insert OID = 2579 (  gist_box_compress        PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ gist_box_compress _null_ _null_ _null_ ));
-DESCR("GiST support");
-DATA(insert OID = 2580 (  gist_box_decompress  PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ gist_box_decompress _null_ _null_ _null_ ));
-DESCR("GiST support");
-DATA(insert OID = 3281 (  gist_box_fetch   PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ gist_box_fetch _null_ _null_ _null_ ));
-DESCR("GiST support");
 DATA(insert OID = 2581 (  gist_box_penalty     PGNSP PGUID 12 1 0 0 0 f f f f t f i s 3 0 2281 "2281 2281 2281" _null_ _null_ _null_ _null_ _null_ gist_box_penalty _null_ _null_ _null_ ));
 DESCR("GiST support");
 DATA(insert OID = 2582 (  gist_box_picksplit   PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ _null_  gist_box_picksplit _null_ _null_ _null_ ));
@@ -4796,8 +4788,6 @@ DESCR("rewrite tsquery");
 
 DATA(insert OID = 3695 (  gtsquery_compress                PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ gtsquery_compress _null_ _null_ _null_ ));
 DESCR("GiST tsquery support");
-DATA(insert OID = 3696 (  gtsquery_decompress          PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ gtsquery_decompress _null_ _null_ _null_ ));
-DESCR("GiST tsquery support");
 DATA(insert OID = 3697 (  gtsquery_picksplit           PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ _null_ gtsquery_picksplit _null_ _null_ _null_ ));
 DESCR("GiST tsquery support");
 DATA(insert OID = 3698 (  gtsquery_union               PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 20 "2281 2281" _null_ _null_ _null_ _null_ _null_ gtsquery_union _null_ _null_ _null_ ));
@@ -5218,12 +5208,6 @@ DATA(insert OID = 3875 (  range_gist_consistent PGNSP PGUID 12 1 0 0 0 f f f f t
 DESCR("GiST support");
 DATA(insert OID = 3876 (  range_gist_union     PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 3831 "2281 2281" _null_ _null_ _null_ _null_ _null_ range_gist_union _null_ _null_ _null_ ));
 DESCR("GiST support");
-DATA(insert OID = 3877 (  range_gist_compress  PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ range_gist_compress _null_ _null_ _null_ ));
-DESCR("GiST support");
-DATA(insert OID = 3878 (  range_gist_decompress PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ range_gist_decompress _null_ _null_ _null_ ));
-DESCR("GiST support");
-DATA(insert OID = 3996 (  range_gist_fetch     PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2281 "2281" _null_ _null_ _null_ _null_ _null_ range_gist_fetch _null_ _null_ _null_ ));
-DESCR("GiST support");
 DATA(insert OID = 3879 (  range_gist_penalty   PGNSP PGUID 12 1 0 0 0 f f f f t f i s 3 0 2281 "2281 2281 2281" _null_ _null_ _null_ _null_ _null_ range_gist_penalty _null_ _null_ _null_ ));
 DESCR("GiST support");
 DATA(insert OID = 3880 (  range_gist_picksplit PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ _null_ range_gist_picksplit _null_ _null_ _null_ ));
index 1b464aae2dc9529ed32b3b68ecedd73478e38c50..47dd885c4e9b1ff8d1595197bc926c855b7d2fa5 100644 (file)
@@ -26,12 +26,10 @@ CREATE OPERATOR CLASS box_ops DEFAULT
    OPERATOR 14 @,
    FUNCTION 1  gist_box_consistent(internal, box, smallint, oid, internal),
    FUNCTION 2  gist_box_union(internal, internal),
-   FUNCTION 3  gist_box_compress(internal),
-   FUNCTION 4  gist_box_decompress(internal),
+   -- don't need compress, decompress, or fetch functions
    FUNCTION 5  gist_box_penalty(internal, internal, internal),
    FUNCTION 6  gist_box_picksplit(internal, internal),
-   FUNCTION 7  gist_box_same(box, box, internal),
-   FUNCTION 9  gist_box_fetch(internal);
+   FUNCTION 7  gist_box_same(box, box, internal);
 -- Create gist2 index on fast_emp4000
 CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base);
 -- Now check the results from plain indexscan; temporarily drop existing
index 2f116d98c779d75fe86e965b14bee9410dffb65d..3e0ac104f3cca3d59f33f83c808b7d2954bc2fc6 100644 (file)
@@ -27,12 +27,10 @@ CREATE OPERATOR CLASS box_ops DEFAULT
    OPERATOR 14 @,
    FUNCTION 1  gist_box_consistent(internal, box, smallint, oid, internal),
    FUNCTION 2  gist_box_union(internal, internal),
-   FUNCTION 3  gist_box_compress(internal),
-   FUNCTION 4  gist_box_decompress(internal),
+   -- don't need compress, decompress, or fetch functions
    FUNCTION 5  gist_box_penalty(internal, internal, internal),
    FUNCTION 6  gist_box_picksplit(internal, internal),
-   FUNCTION 7  gist_box_same(box, box, internal),
-   FUNCTION 9  gist_box_fetch(internal);
+   FUNCTION 7  gist_box_same(box, box, internal);
 
 -- Create gist2 index on fast_emp4000
 CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base);