Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2d484f9

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 GiSTcode. This buys us whatever performance gain is to be had, and moreimportantly exercises the preceding patch.There remain no-op functions in the contrib GiST opclasses, but thosewill take more work to remove.Discussion:https://postgr.es/m/CAJEAwVELVx9gYscpE=Be6iJxvdW5unZ_LkcAaVNSeOwvdwtD=A@mail.gmail.com
1 parentd3a4f89 commit2d484f9

File tree

10 files changed

+22
-105
lines changed

10 files changed

+22
-105
lines changed

‎src/backend/access/gist/gistproc.c

Lines changed: 2 additions & 30 deletions
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

Lines changed: 2 additions & 10 deletions
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

Lines changed: 5 additions & 24 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 4 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201709131
56+
#defineCATALOG_VERSION_NO201709191
5757

5858
#endif

‎src/include/catalog/pg_amproc.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,32 +230,26 @@ DATA(insert (4034 3802 3802 2 3416));
230230
DATA(insert (102960060012179 ));
231231
DATA(insert (102960060022583 ));
232232
DATA(insert (102960060031030 ));
233-
DATA(insert (102960060042580 ));
234233
DATA(insert (102960060052581 ));
235234
DATA(insert (102960060062582 ));
236235
DATA(insert (102960060072584 ));
237236
DATA(insert (102960060083064 ));
238237
DATA(insert (102960060093282 ));
239238
DATA(insert (259360360312578 ));
240239
DATA(insert (259360360322583 ));
241-
DATA(insert (259360360332579 ));
242-
DATA(insert (259360360342580 ));
243240
DATA(insert (259360360352581 ));
244241
DATA(insert (259360360362582 ));
245242
DATA(insert (259360360372584 ));
246-
DATA(insert (259360360393281 ));
247243
DATA(insert (259460460412585 ));
248244
DATA(insert (259460460422583 ));
249245
DATA(insert (259460460432586 ));
250-
DATA(insert (259460460442580 ));
251246
DATA(insert (259460460452581 ));
252247
DATA(insert (259460460462582 ));
253248
DATA(insert (259460460472584 ));
254249
DATA(insert (259460460483288 ));
255250
DATA(insert (259571871812591 ));
256251
DATA(insert (259571871822583 ));
257252
DATA(insert (259571871832592 ));
258-
DATA(insert (259571871842580 ));
259253
DATA(insert (259571871852581 ));
260254
DATA(insert (259571871862582 ));
261255
DATA(insert (259571871872584 ));
@@ -270,22 +264,17 @@ DATA(insert (3655 3614 3614 7 3652 ));
270264
DATA(insert (37023615361513701 ));
271265
DATA(insert (37023615361523698 ));
272266
DATA(insert (37023615361533695 ));
273-
DATA(insert (37023615361543696 ));
274267
DATA(insert (37023615361553700 ));
275268
DATA(insert (37023615361563697 ));
276269
DATA(insert (37023615361573699 ));
277270
DATA(insert (39193831383113875 ));
278271
DATA(insert (39193831383123876 ));
279-
DATA(insert (39193831383133877 ));
280-
DATA(insert (39193831383143878 ));
281272
DATA(insert (39193831383153879 ));
282273
DATA(insert (39193831383163880 ));
283274
DATA(insert (39193831383173881 ));
284-
DATA(insert (39193831383193996 ));
285275
DATA(insert (355086986913553 ));
286276
DATA(insert (355086986923554 ));
287277
DATA(insert (355086986933555 ));
288-
DATA(insert (355086986943556 ));
289278
DATA(insert (355086986953557 ));
290279
DATA(insert (355086986963558 ));
291280
DATA(insert (355086986973559 ));

‎src/include/catalog/pg_proc.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,8 +2293,6 @@ DATA(insert OID = 3554 ( inet_gist_unionPGNSP PGUID 12 1 0 0 0 f f f f t f i
22932293
DESCR("GiST support");
22942294
DATA(insert OID = 3555 ( inet_gist_compressPGNSP 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_decompressPGNSP 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_fetchPGNSP 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_penaltyPGNSP 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_overabovePGNSP 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_consistentPGNSP 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_compressPGNSP 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_decompressPGNSP 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_fetchPGNSP 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_penaltyPGNSP 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_picksplitPGNSP 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_compressPGNSP 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_decompressPGNSP 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_picksplitPGNSP 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_unionPGNSP 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_unionPGNSP 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_compressPGNSP 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_fetchPGNSP 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_penaltyPGNSP 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_picksplitPGNSP 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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ CREATE OPERATOR CLASS box_ops DEFAULT
2626
OPERATOR 14@,
2727
FUNCTION 1gist_box_consistent(internal, box, smallint, oid, internal),
2828
FUNCTION 2gist_box_union(internal, internal),
29-
FUNCTION 3gist_box_compress(internal),
30-
FUNCTION 4gist_box_decompress(internal),
29+
-- don't need compress, decompress, or fetch functions
3130
FUNCTION 5gist_box_penalty(internal, internal, internal),
3231
FUNCTION 6gist_box_picksplit(internal, internal),
33-
FUNCTION 7gist_box_same(box, box, internal),
34-
FUNCTION 9gist_box_fetch(internal);
32+
FUNCTION 7gist_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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@ CREATE OPERATOR CLASS box_ops DEFAULT
2727
OPERATOR14@,
2828
FUNCTION1gist_box_consistent(internal,box,smallint,oid, internal),
2929
FUNCTION2gist_box_union(internal, internal),
30-
FUNCTION3gist_box_compress(internal),
31-
FUNCTION4gist_box_decompress(internal),
30+
-- don't need compress, decompress, or fetch functions
3231
FUNCTION5gist_box_penalty(internal, internal, internal),
3332
FUNCTION6gist_box_picksplit(internal, internal),
34-
FUNCTION7gist_box_same(box,box, internal),
35-
FUNCTION9gist_box_fetch(internal);
33+
FUNCTION7gist_box_same(box,box, internal);
3634

3735
-- Create gist2 index on fast_emp4000
3836
CREATEINDEXgrect2ind2ON fast_emp4000 USING gist2 (home_base);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp