Skip to content

Commit c2a2351

Browse files
committed
Merge index fetch support for spoint3 into main files
So far, the function backing index only fetches on spoint3 gist indexes was already always compiled, but only added to the operator class for PG9.5+, and only when special code in the Makefile was uncommented. We are well past 9.5, and the feature works just fine, so load it unconditionally (assuming no one used it in production yet, ADD FUNCTION will fail when executed twice). Version bumped since we add a new function to the opclass.
1 parent 2a2f70e commit c2a2351

10 files changed

+85
-103
lines changed

Makefile

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ ifneq ($(USE_HEALPIX),0)
4242
REGRESS += healpix moc mocautocast
4343
endif
4444

45-
REGRESS_9_5 = index_9.5 # experimental for spoint3
46-
4745
TESTS = init_test tables points euler circle line ellipse poly path box \
4846
index contains_ops contains_ops_compat bounding_box_gist gnomo \
4947
epochprop contains overlaps spoint_brin sbox_brin
@@ -84,8 +82,6 @@ endif
8482

8583
PGS_SQL += pgs_epochprop.sql
8684

87-
PGS_SQL_9_5 = pgs_9.5.sql # experimental for spoint3
88-
8985
ifdef USE_PGXS
9086
ifndef PG_CONFIG
9187
PG_CONFIG = pg_config
@@ -112,18 +108,9 @@ endif
112108
healpix_bare/healpix_bare.o : healpix_bare/healpix_bare.c
113109
$(COMPILE.c) -Wno-declaration-after-statement -o $@ $^
114110

115-
# experimental for spoint3
116111
pg_version := $(word 2,$(shell $(PG_CONFIG) --version))
117-
pg_version_9_5_plus = $(if $(filter-out 9.1% 9.2% 9.3% 9.4%,$(pg_version)),y,n)
118112
has_explain_summary = $(if $(filter-out 9.%,$(pg_version)),y,n)
119113

120-
## the use of spoint 3 is too experimental and preliminary:
121-
#ifeq ($(pg_version_9_5_plus),y)
122-
# REGRESS += $(REGRESS_9_5)
123-
# TESTS += $(REGRESS_9_5)
124-
# PGS_SQL += $(PGS_SQL_9_5)
125-
#endif
126-
127114
crushtest: REGRESS += $(CRUSH_TESTS)
128115
crushtest: installcheck
129116

expected/index.out

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,64 @@ SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>' ;
134134
40
135135
(1 row)
136136

137+
-- test spoint3 operator class with and without index-only scan
138+
SET enable_bitmapscan = OFF;
139+
SET enable_indexonlyscan = ON;
140+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
141+
QUERY PLAN
142+
--------------------------------------------------------
143+
Aggregate
144+
-> Index Only Scan using spoint3_idx on spheretmp1b
145+
Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle)
146+
(3 rows)
147+
148+
SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
149+
count
150+
-------
151+
32
152+
(1 row)
153+
154+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';
155+
QUERY PLAN
156+
--------------------------------------------------------
157+
Aggregate
158+
-> Index Only Scan using spoint3_idx on spheretmp1b
159+
Index Cond: (p = '(3.09 , 1.25)'::spoint)
160+
(3 rows)
161+
162+
SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';
163+
count
164+
-------
165+
4
166+
(1 row)
167+
168+
SET enable_bitmapscan = ON;
169+
SET enable_indexonlyscan = OFF;
170+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
171+
QUERY PLAN
172+
-------------------------------------------------------
173+
Aggregate
174+
-> Index Scan using spoint3_idx on spheretmp1b
175+
Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle)
176+
(3 rows)
177+
178+
SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
179+
count
180+
-------
181+
32
182+
(1 row)
183+
184+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';
185+
QUERY PLAN
186+
---------------------------------------------------
187+
Aggregate
188+
-> Index Scan using spoint3_idx on spheretmp1b
189+
Index Cond: (p = '(3.09 , 1.25)'::spoint)
190+
(3 rows)
191+
192+
SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';
193+
count
194+
-------
195+
4
196+
(1 row)
197+

expected/index_9.5.out

Lines changed: 0 additions & 62 deletions
This file was deleted.

expected/init_test_healpix.out.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
psql:pg_sphere.test.sql:9684: NOTICE: return type smoc is only a shell
2-
psql:pg_sphere.test.sql:9690: NOTICE: argument type smoc is only a shell
1+
psql:pg_sphere.test.sql:9685: NOTICE: return type smoc is only a shell
2+
psql:pg_sphere.test.sql:9691: NOTICE: argument type smoc is only a shell

index_9.5

Whitespace-only changes.

pgs_9.5.sql.in

Lines changed: 0 additions & 7 deletions
This file was deleted.

pgs_gist_spoint3.sql.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@ CREATE OPERATOR CLASS spoint3
6666
FUNCTION 6 g_spoint3_picksplit (internal, internal),
6767
FUNCTION 7 g_spoint3_same (bytea, bytea, internal),
6868
FUNCTION 8 g_spoint3_distance (internal, internal, int4, oid),
69+
FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal),
6970
STORAGE pointkey;

sql/index.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,20 @@ SELECT count(*) FROM spheretmp4 WHERE l @ scircle '<(1,1),0.3>' ;
5959

6060
SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>' ;
6161

62+
-- test spoint3 operator class with and without index-only scan
63+
64+
SET enable_bitmapscan = OFF;
65+
SET enable_indexonlyscan = ON;
66+
67+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
68+
SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
69+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';
70+
SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';
71+
72+
SET enable_bitmapscan = ON;
73+
SET enable_indexonlyscan = OFF;
74+
75+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
76+
SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>';
77+
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';
78+
SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)';

sql/index_9.5.sql

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
-- Nothing to upgrade in the schema
1+
-- add "fetch" support function to enable index-only scans for spoint3
2+
3+
ALTER OPERATOR FAMILY spoint3 USING gist ADD
4+
FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal);

0 commit comments

Comments
 (0)