Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2d484f9

Browse files
committed
Remove no-op GiST support functions in the core GiST opclasses.
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
1 parent d3a4f89 commit 2d484f9

File tree

10 files changed

+22
-105
lines changed

10 files changed

+22
-105
lines changed

src/backend/access/gist/gistproc.c

+2-30
Original file line numberDiff line numberDiff line change
@@ -185,37 +185,9 @@ gist_box_union(PG_FUNCTION_ARGS)
185185
}
186186

187187
/*
188-
* GiST Compress methods for boxes
189-
*
190-
* do not do anything.
188+
* We store boxes as boxes in GiST indexes, so we do not need
189+
* compress, decompress, or fetch functions.
191190
*/
192-
Datum
193-
gist_box_compress(PG_FUNCTION_ARGS)
194-
{
195-
PG_RETURN_POINTER(PG_GETARG_POINTER(0));
196-
}
197-
198-
/*
199-
* GiST DeCompress method for boxes (also used for points, polygons
200-
* and circles)
201-
*
202-
* do not do anything --- we just use the stored box as is.
203-
*/
204-
Datum
205-
gist_box_decompress(PG_FUNCTION_ARGS)
206-
{
207-
PG_RETURN_POINTER(PG_GETARG_POINTER(0));
208-
}
209-
210-
/*
211-
* GiST Fetch method for boxes
212-
* do not do anything --- we just return the stored box as is.
213-
*/
214-
Datum
215-
gist_box_fetch(PG_FUNCTION_ARGS)
216-
{
217-
PG_RETURN_POINTER(PG_GETARG_POINTER(0));
218-
}
219191

220192
/*
221193
* The GiST Penalty method for boxes (also used for points)

src/backend/utils/adt/network_gist.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -576,17 +576,9 @@ inet_gist_compress(PG_FUNCTION_ARGS)
576576
}
577577

578578
/*
579-
* The GiST decompress function
580-
*
581-
* do not do anything --- we just use the stored GistInetKey as-is.
579+
* We do not need a decompress function, because the other GiST inet
580+
* support functions work with the GistInetKey representation.
582581
*/
583-
Datum
584-
inet_gist_decompress(PG_FUNCTION_ARGS)
585-
{
586-
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
587-
588-
PG_RETURN_POINTER(entry);
589-
}
590582

591583
/*
592584
* The GiST fetch function

src/backend/utils/adt/rangetypes_gist.c

+5-24
Original file line numberDiff line numberDiff line change
@@ -216,30 +216,11 @@ range_gist_union(PG_FUNCTION_ARGS)
216216
PG_RETURN_RANGE_P(result_range);
217217
}
218218

219-
/* compress, decompress, fetch are no-ops */
220-
Datum
221-
range_gist_compress(PG_FUNCTION_ARGS)
222-
{
223-
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
224-
225-
PG_RETURN_POINTER(entry);
226-
}
227-
228-
Datum
229-
range_gist_decompress(PG_FUNCTION_ARGS)
230-
{
231-
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
232-
233-
PG_RETURN_POINTER(entry);
234-
}
235-
236-
Datum
237-
range_gist_fetch(PG_FUNCTION_ARGS)
238-
{
239-
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
240-
241-
PG_RETURN_POINTER(entry);
242-
}
219+
/*
220+
* We store ranges as ranges in GiST indexes, so we do not need
221+
* compress, decompress, or fetch functions. Note this implies a limit
222+
* on the size of range values that can be indexed.
223+
*/
243224

244225
/*
245226
* GiST page split penalty function.

src/backend/utils/adt/tsgistidx.c

+4
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ gtsvector_compress(PG_FUNCTION_ARGS)
272272
Datum
273273
gtsvector_decompress(PG_FUNCTION_ARGS)
274274
{
275+
/*
276+
* We need to detoast the stored value, because the other gtsvector
277+
* support functions don't cope with toasted values.
278+
*/
275279
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
276280
SignTSVector *key = (SignTSVector *) PG_DETOAST_DATUM(entry->key);
277281

src/backend/utils/adt/tsquery_gist.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ gtsquery_compress(PG_FUNCTION_ARGS)
4343
PG_RETURN_POINTER(retval);
4444
}
4545

46-
Datum
47-
gtsquery_decompress(PG_FUNCTION_ARGS)
48-
{
49-
PG_RETURN_DATUM(PG_GETARG_DATUM(0));
50-
}
46+
/*
47+
* We do not need a decompress function, because the other gtsquery
48+
* support functions work with the compressed representation.
49+
*/
5150

5251
Datum
5352
gtsquery_consistent(PG_FUNCTION_ARGS)

src/include/catalog/catversion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201709131
56+
#define CATALOG_VERSION_NO 201709191
5757

5858
#endif

src/include/catalog/pg_amproc.h

-11
Original file line numberDiff line numberDiff line change
@@ -230,32 +230,26 @@ DATA(insert ( 4034 3802 3802 2 3416));
230230
DATA(insert ( 1029 600 600 1 2179 ));
231231
DATA(insert ( 1029 600 600 2 2583 ));
232232
DATA(insert ( 1029 600 600 3 1030 ));
233-
DATA(insert ( 1029 600 600 4 2580 ));
234233
DATA(insert ( 1029 600 600 5 2581 ));
235234
DATA(insert ( 1029 600 600 6 2582 ));
236235
DATA(insert ( 1029 600 600 7 2584 ));
237236
DATA(insert ( 1029 600 600 8 3064 ));
238237
DATA(insert ( 1029 600 600 9 3282 ));
239238
DATA(insert ( 2593 603 603 1 2578 ));
240239
DATA(insert ( 2593 603 603 2 2583 ));
241-
DATA(insert ( 2593 603 603 3 2579 ));
242-
DATA(insert ( 2593 603 603 4 2580 ));
243240
DATA(insert ( 2593 603 603 5 2581 ));
244241
DATA(insert ( 2593 603 603 6 2582 ));
245242
DATA(insert ( 2593 603 603 7 2584 ));
246-
DATA(insert ( 2593 603 603 9 3281 ));
247243
DATA(insert ( 2594 604 604 1 2585 ));
248244
DATA(insert ( 2594 604 604 2 2583 ));
249245
DATA(insert ( 2594 604 604 3 2586 ));
250-
DATA(insert ( 2594 604 604 4 2580 ));
251246
DATA(insert ( 2594 604 604 5 2581 ));
252247
DATA(insert ( 2594 604 604 6 2582 ));
253248
DATA(insert ( 2594 604 604 7 2584 ));
254249
DATA(insert ( 2594 604 604 8 3288 ));
255250
DATA(insert ( 2595 718 718 1 2591 ));
256251
DATA(insert ( 2595 718 718 2 2583 ));
257252
DATA(insert ( 2595 718 718 3 2592 ));
258-
DATA(insert ( 2595 718 718 4 2580 ));
259253
DATA(insert ( 2595 718 718 5 2581 ));
260254
DATA(insert ( 2595 718 718 6 2582 ));
261255
DATA(insert ( 2595 718 718 7 2584 ));
@@ -270,22 +264,17 @@ DATA(insert ( 3655 3614 3614 7 3652 ));
270264
DATA(insert ( 3702 3615 3615 1 3701 ));
271265
DATA(insert ( 3702 3615 3615 2 3698 ));
272266
DATA(insert ( 3702 3615 3615 3 3695 ));
273-
DATA(insert ( 3702 3615 3615 4 3696 ));
274267
DATA(insert ( 3702 3615 3615 5 3700 ));
275268
DATA(insert ( 3702 3615 3615 6 3697 ));
276269
DATA(insert ( 3702 3615 3615 7 3699 ));
277270
DATA(insert ( 3919 3831 3831 1 3875 ));
278271
DATA(insert ( 3919 3831 3831 2 3876 ));
279-
DATA(insert ( 3919 3831 3831 3 3877 ));
280-
DATA(insert ( 3919 3831 3831 4 3878 ));
281272
DATA(insert ( 3919 3831 3831 5 3879 ));
282273
DATA(insert ( 3919 3831 3831 6 3880 ));
283274
DATA(insert ( 3919 3831 3831 7 3881 ));
284-
DATA(insert ( 3919 3831 3831 9 3996 ));
285275
DATA(insert ( 3550 869 869 1 3553 ));
286276
DATA(insert ( 3550 869 869 2 3554 ));
287277
DATA(insert ( 3550 869 869 3 3555 ));
288-
DATA(insert ( 3550 869 869 4 3556 ));
289278
DATA(insert ( 3550 869 869 5 3557 ));
290279
DATA(insert ( 3550 869 869 6 3558 ));
291280
DATA(insert ( 3550 869 869 7 3559 ));

src/include/catalog/pg_proc.h

-16
Original file line numberDiff line numberDiff line change
@@ -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
22932293
DESCR("GiST support");
22942294
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_ ));
22952295
DESCR("GiST support");
2296-
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_ ));
2297-
DESCR("GiST support");
22982296
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_ ));
22992297
DESCR("GiST support");
23002298
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
43104308
/* support functions for GiST r-tree emulation */
43114309
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_ ));
43124310
DESCR("GiST support");
4313-
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_ ));
4314-
DESCR("GiST support");
4315-
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_ ));
4316-
DESCR("GiST support");
4317-
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_ ));
4318-
DESCR("GiST support");
43194311
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_ ));
43204312
DESCR("GiST support");
43214313
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");
47964788

47974789
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_ ));
47984790
DESCR("GiST tsquery support");
4799-
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_ ));
4800-
DESCR("GiST tsquery support");
48014791
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_ ));
48024792
DESCR("GiST tsquery support");
48034793
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
52185208
DESCR("GiST support");
52195209
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_ ));
52205210
DESCR("GiST support");
5221-
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_ ));
5222-
DESCR("GiST support");
5223-
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_ ));
5224-
DESCR("GiST support");
5225-
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_ ));
5226-
DESCR("GiST support");
52275211
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_ ));
52285212
DESCR("GiST support");
52295213
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_ ));

src/test/regress/expected/create_am.out

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ CREATE OPERATOR CLASS box_ops DEFAULT
2626
OPERATOR 14 @,
2727
FUNCTION 1 gist_box_consistent(internal, box, smallint, oid, internal),
2828
FUNCTION 2 gist_box_union(internal, internal),
29-
FUNCTION 3 gist_box_compress(internal),
30-
FUNCTION 4 gist_box_decompress(internal),
29+
-- don't need compress, decompress, or fetch functions
3130
FUNCTION 5 gist_box_penalty(internal, internal, internal),
3231
FUNCTION 6 gist_box_picksplit(internal, internal),
33-
FUNCTION 7 gist_box_same(box, box, internal),
34-
FUNCTION 9 gist_box_fetch(internal);
32+
FUNCTION 7 gist_box_same(box, box, internal);
3533
-- Create gist2 index on fast_emp4000
3634
CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base);
3735
-- Now check the results from plain indexscan; temporarily drop existing

src/test/regress/sql/create_am.sql

+2-4
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ CREATE OPERATOR CLASS box_ops DEFAULT
2727
OPERATOR 14 @,
2828
FUNCTION 1 gist_box_consistent(internal, box, smallint, oid, internal),
2929
FUNCTION 2 gist_box_union(internal, internal),
30-
FUNCTION 3 gist_box_compress(internal),
31-
FUNCTION 4 gist_box_decompress(internal),
30+
-- don't need compress, decompress, or fetch functions
3231
FUNCTION 5 gist_box_penalty(internal, internal, internal),
3332
FUNCTION 6 gist_box_picksplit(internal, internal),
34-
FUNCTION 7 gist_box_same(box, box, internal),
35-
FUNCTION 9 gist_box_fetch(internal);
33+
FUNCTION 7 gist_box_same(box, box, internal);
3634

3735
-- Create gist2 index on fast_emp4000
3836
CREATE INDEX grect2ind2 ON fast_emp4000 USING gist2 (home_base);

0 commit comments

Comments
 (0)