Skip to content

Commit 0633a60

Browse files
committed
Add index-only scan support to range type GiST opclass.
Andreas Karlsson
1 parent 1c41e2a commit 0633a60

File tree

7 files changed

+38
-2
lines changed

7 files changed

+38
-2
lines changed

src/backend/utils/adt/rangetypes_gist.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ range_gist_union(PG_FUNCTION_ARGS)
216216
PG_RETURN_RANGE(result_range);
217217
}
218218

219-
/* compress, decompress are no-ops */
219+
/* compress, decompress, fetch are no-ops */
220220
Datum
221221
range_gist_compress(PG_FUNCTION_ARGS)
222222
{
@@ -233,6 +233,14 @@ range_gist_decompress(PG_FUNCTION_ARGS)
233233
PG_RETURN_POINTER(entry);
234234
}
235235

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+
}
243+
236244
/*
237245
* GiST page split penalty function.
238246
*

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-
#define CATALOG_VERSION_NO 201503281
56+
#define CATALOG_VERSION_NO 201503301
5757

5858
#endif

src/include/catalog/pg_amproc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ DATA(insert ( 3919 3831 3831 4 3878 ));
235235
DATA(insert ( 3919 3831 3831 5 3879 ));
236236
DATA(insert ( 3919 3831 3831 6 3880 ));
237237
DATA(insert ( 3919 3831 3831 7 3881 ));
238+
DATA(insert ( 3919 3831 3831 9 3996 ));
238239

239240

240241
/* gin */

src/include/catalog/pg_proc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4951,6 +4951,8 @@ DATA(insert OID = 3877 ( range_gist_compress PGNSP PGUID 12 1 0 0 0 f f f f t f
49514951
DESCR("GiST support");
49524952
DATA(insert OID = 3878 ( range_gist_decompress PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 2281 "2281" _null_ _null_ _null_ _null_ range_gist_decompress _null_ _null_ _null_ ));
49534953
DESCR("GiST support");
4954+
DATA(insert OID = 3996 ( range_gist_fetch PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 2281 "2281" _null_ _null_ _null_ _null_ range_gist_fetch _null_ _null_ _null_ ));
4955+
DESCR("GiST support");
49544956
DATA(insert OID = 3879 ( range_gist_penalty PGNSP PGUID 12 1 0 0 0 f f f f t f i 3 0 2281 "2281 2281 2281" _null_ _null_ _null_ _null_ range_gist_penalty _null_ _null_ _null_ ));
49554957
DESCR("GiST support");
49564958
DATA(insert OID = 3880 ( range_gist_picksplit PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 2281 "2281 2281" _null_ _null_ _null_ _null_ range_gist_picksplit _null_ _null_ _null_ ));

src/include/utils/rangetypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ extern RangeType *make_empty_range(TypeCacheEntry *typcache);
209209
extern Datum range_gist_consistent(PG_FUNCTION_ARGS);
210210
extern Datum range_gist_compress(PG_FUNCTION_ARGS);
211211
extern Datum range_gist_decompress(PG_FUNCTION_ARGS);
212+
extern Datum range_gist_fetch(PG_FUNCTION_ARGS);
212213
extern Datum range_gist_union(PG_FUNCTION_ARGS);
213214
extern Datum range_gist_penalty(PG_FUNCTION_ARGS);
214215
extern Datum range_gist_picksplit(PG_FUNCTION_ARGS);

src/test/regress/expected/rangetypes.out

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,25 @@ select count(*) from test_range_spgist where ir -|- int4range(100,500);
10721072
5
10731073
(1 row)
10741074

1075+
-- test index-only scans
1076+
explain (costs off)
1077+
select ir from test_range_spgist where ir -|- int4range(10,20) order by ir;
1078+
QUERY PLAN
1079+
------------------------------------------------------------------------
1080+
Sort
1081+
Sort Key: ir
1082+
-> Index Only Scan using test_range_spgist_idx on test_range_spgist
1083+
Index Cond: (ir -|- '[10,20)'::int4range)
1084+
(4 rows)
1085+
1086+
select ir from test_range_spgist where ir -|- int4range(10,20) order by ir;
1087+
ir
1088+
------------
1089+
[20,30)
1090+
[20,30)
1091+
[20,10020)
1092+
(3 rows)
1093+
10751094
RESET enable_seqscan;
10761095
RESET enable_indexscan;
10771096
RESET enable_bitmapscan;

src/test/regress/sql/rangetypes.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,11 @@ select count(*) from test_range_spgist where ir &< int4range(100,500);
286286
select count(*) from test_range_spgist where ir &> int4range(100,500);
287287
select count(*) from test_range_spgist where ir -|- int4range(100,500);
288288

289+
-- test index-only scans
290+
explain (costs off)
291+
select ir from test_range_spgist where ir -|- int4range(10,20) order by ir;
292+
select ir from test_range_spgist where ir -|- int4range(10,20) order by ir;
293+
289294
RESET enable_seqscan;
290295
RESET enable_indexscan;
291296
RESET enable_bitmapscan;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy