- Notifications
You must be signed in to change notification settings - Fork15
Selectivity estimators for <@(spoint, scircle) and spoint_dwithin(spoint, spoint, float8)#80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
24 changes: 17 additions & 7 deletionsMakefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -10,8 +10,8 @@ SRC_DIR = $(shell basename $(shell pwd)) | ||
MODULE_big = pg_sphere | ||
OBJS = src/sscan.o src/sparse.o src/sbuffer.o src/vector3d.o src/point.o \ | ||
src/euler.o src/circle.o src/circle_sel.o src/line.o src/ellipse.o src/polygon.o \ | ||
src/path.o src/box.o src/output.o src/gq_cache.o src/gist.osrc/gist_support.o\ | ||
src/key.o src/gnomo.o src/epochprop.o src/brin.o | ||
ifneq ($(USE_HEALPIX),0) | ||
@@ -35,11 +35,11 @@ DATA_built = $(RELEASE_SQL) \ | ||
DOCS = README.pg_sphere COPYRIGHT.pg_sphere | ||
REGRESS = init tables points euler circle line ellipse poly path box index \ | ||
contains_ops contains_ops_compat bounding_box_gist gnomo epochprop \ | ||
contains overlaps spoint_brin sbox_brin selectivity | ||
TESTS = init_test tables points euler circle line ellipse poly path box \ | ||
index contains_ops contains_ops_compat bounding_box_gist gnomo \ | ||
epochprop contains overlaps spoint_brin sbox_brin selectivity | ||
PG_CFLAGS+= -DPGSPHERE_VERSION=$(PGSPHERE_VERSION) | ||
PG_CPPFLAGS+= -DPGSPHERE_VERSION=$(PGSPHERE_VERSION) | ||
@@ -58,7 +58,7 @@ CRUSH_TESTS = init_extended circle_extended | ||
PGS_SQL = pgs_types.sql pgs_point.sql pgs_euler.sql pgs_circle.sql \ | ||
pgs_line.sql pgs_ellipse.sql pgs_polygon.sql pgs_path.sql \ | ||
pgs_box.sql pgs_contains_ops.sql pgs_contains_ops_compat.sql \ | ||
pgs_gist.sql gnomo.sql pgs_brin.sql pgs_circle_sel.sql | ||
ifneq ($(USE_HEALPIX),0) | ||
REGRESS += healpix moc moc1 moc100 mocautocast | ||
@@ -102,10 +102,17 @@ healpix_bare/healpix_bare.o : healpix_bare/healpix_bare.c | ||
$(COMPILE.c) -Wno-declaration-after-statement -o $@ $^ | ||
pg_version := $(word 2,$(shell $(PG_CONFIG) --version)) | ||
has_support_functions = $(if $(filter-out 9.% 10.% 11.%,$(pg_version)),y,n) | ||
crushtest: REGRESS += $(CRUSH_TESTS) | ||
crushtest: installcheck | ||
ifeq ($(has_support_functions),y) | ||
PGS_SQL += pgs_gist_support.sql | ||
REGRESS += gist_support | ||
TESTS += gist_support | ||
endif | ||
test: pg_sphere.test.sql | ||
$(pg_regress_installcheck) --temp-instance=tmp_check $(REGRESS_OPTS) $(TESTS) | ||
@@ -180,8 +187,11 @@ pg_sphere--1.2.3--1.3.0.sql: pgs_brin.sql.in | ||
pg_sphere--1.3.0--1.3.1.sql: | ||
cat upgrade_scripts/$@.in > $@ | ||
ifeq ($(has_support_functions),y) | ||
pg_sphere--1.3.1--1.3.2.sql: pgs_gist_support.sql.in | ||
endif | ||
pg_sphere--1.3.1--1.3.2.sql: pgs_circle_sel.sql.in | ||
cat upgrade_scripts/$@.in $^ > $@ | ||
df7cb marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# end of local stuff | ||
35 changes: 35 additions & 0 deletionsdoc/functions.sgm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletionsexpected/gist_support.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
-- spoint_dwithin function selectivity | ||
set jit = off; -- suppress extra planning output | ||
select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), 1)'); | ||
explain | ||
----------------------------------------------------------------------------------------------- | ||
Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) | ||
Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '1'::double precision) | ||
Rows Removed by Filter: 1560 | ||
Heap Blocks: exact=55 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) | ||
(6 rows) | ||
select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .1)'); | ||
explain | ||
------------------------------------------------------------------------------------------- | ||
Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) | ||
Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) | ||
Rows Removed by Filter: 19 | ||
Heap Blocks: exact=32 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
(6 rows) | ||
select explain('select * from spoint10k where spoint_dwithin(star, spoint(1,1), .01)'); | ||
explain | ||
--------------------------------------------------------------------------------------------- | ||
Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) | ||
(2 rows) | ||
select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, 1)'); | ||
explain | ||
----------------------------------------------------------------------------------------------- | ||
Bitmap Heap Scan on spoint10k (rows=2298 width=16) (actual rows=3009 loops=1) | ||
Filter: spoint_dwithin('(1 , 1)'::spoint, star, '1'::double precision) | ||
Rows Removed by Filter: 1560 | ||
Heap Blocks: exact=55 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=2298 width=0) (actual rows=4569 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 1>'::scircle) | ||
(6 rows) | ||
select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .1)'); | ||
explain | ||
------------------------------------------------------------------------------------------- | ||
Bitmap Heap Scan on spoint10k (rows=25 width=16) (actual rows=29 loops=1) | ||
Filter: spoint_dwithin('(1 , 1)'::spoint, star, '0.1'::double precision) | ||
Rows Removed by Filter: 19 | ||
Heap Blocks: exact=32 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
(6 rows) | ||
select explain('select * from spoint10k where spoint_dwithin(spoint(1,1), star, .01)'); | ||
explain | ||
--------------------------------------------------------------------------------------------- | ||
Index Scan using spoint10k_star_idx on spoint10k (rows=1 width=16) (actual rows=1 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.01>'::scircle) | ||
(2 rows) | ||
select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, 1)', do_analyze := 'false'); | ||
explain | ||
--------------------------------------------------------------------------------------- | ||
Nested Loop (rows=22984885 width=32) | ||
-> Seq Scan on spoint10k a (rows=10000 width=16) | ||
-> Index Scan using spoint10k_star_idx on spoint10k b (rows=2298 width=16) | ||
Index Cond: (star OPERATOR(public.<@) scircle(a.star, '1'::double precision)) | ||
(4 rows) | ||
select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .1)'); | ||
explain | ||
----------------------------------------------------------------------------------------------------------- | ||
Nested Loop (rows=249792 width=32) (actual rows=505342 loops=1) | ||
-> Seq Scan on spoint10k a (rows=10000 width=16) (actual rows=10000 loops=1) | ||
-> Index Scan using spoint10k_star_idx on spoint10k b (rows=25 width=16) (actual rows=51 loops=10000) | ||
Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.1'::double precision)) | ||
Rows Removed by Index Recheck: 31 | ||
(5 rows) | ||
select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01)'); | ||
explain | ||
--------------------------------------------------------------------------------------------------------- | ||
Nested Loop (rows=2500 width=32) (actual rows=17614 loops=1) | ||
-> Seq Scan on spoint10k a (rows=10000 width=16) (actual rows=10000 loops=1) | ||
-> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=2 loops=10000) | ||
Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) | ||
Rows Removed by Index Recheck: 1 | ||
(5 rows) | ||
-- spoint_dwithin is symmetric in the first two arguments | ||
select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) | ||
where spoint_dwithin(a.star, spoint(1,1), .1)'); | ||
explain | ||
------------------------------------------------------------------------------------------------------ | ||
Nested Loop (rows=6 width=32) (actual rows=33 loops=1) | ||
-> Bitmap Heap Scan on spoint10k a (rows=25 width=16) (actual rows=29 loops=1) | ||
Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) | ||
Rows Removed by Filter: 19 | ||
Heap Blocks: exact=32 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
-> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=29) | ||
Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) | ||
Rows Removed by Index Recheck: 0 | ||
(10 rows) | ||
select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(b.star, a.star, .01) | ||
where spoint_dwithin(a.star, spoint(1,1), .1)'); | ||
explain | ||
------------------------------------------------------------------------------------------------------ | ||
Nested Loop (rows=6 width=32) (actual rows=33 loops=1) | ||
-> Bitmap Heap Scan on spoint10k a (rows=25 width=16) (actual rows=29 loops=1) | ||
Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.1'::double precision) | ||
Rows Removed by Filter: 19 | ||
Heap Blocks: exact=32 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=25 width=0) (actual rows=48 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.1>'::scircle) | ||
-> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=29) | ||
Index Cond: (star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) | ||
Rows Removed by Index Recheck: 0 | ||
(10 rows) | ||
-- both sides indexable, check if the planner figures out the better choice | ||
select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) | ||
where spoint_dwithin(a.star, spoint(1,1), .1) and spoint_dwithin(b.star, spoint(1,1), .05)'); | ||
explain | ||
------------------------------------------------------------------------------------------------------------------------------------- | ||
Nested Loop (rows=1 width=32) (actual rows=16 loops=1) | ||
-> Bitmap Heap Scan on spoint10k b (rows=6 width=16) (actual rows=12 loops=1) | ||
Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.05'::double precision) | ||
Rows Removed by Filter: 4 | ||
Heap Blocks: exact=14 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=6 width=0) (actual rows=16 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.05>'::scircle) | ||
-> Index Scan using spoint10k_star_idx on spoint10k a (rows=1 width=16) (actual rows=1 loops=12) | ||
Index Cond: ((star OPERATOR(public.<@) scircle(b.star, '0.01'::double precision)) AND (star <@ '<(1 , 1) , 0.1>'::scircle)) | ||
Rows Removed by Index Recheck: 0 | ||
(10 rows) | ||
select explain('select * from spoint10k a join spoint10k b on spoint_dwithin(a.star, b.star, .01) | ||
where spoint_dwithin(a.star, spoint(1,1), .05) and spoint_dwithin(b.star, spoint(1,1), .1)'); | ||
explain | ||
------------------------------------------------------------------------------------------------------------------------------------- | ||
Nested Loop (rows=1 width=32) (actual rows=16 loops=1) | ||
-> Bitmap Heap Scan on spoint10k a (rows=6 width=16) (actual rows=12 loops=1) | ||
Filter: spoint_dwithin(star, '(1 , 1)'::spoint, '0.05'::double precision) | ||
Rows Removed by Filter: 4 | ||
Heap Blocks: exact=14 | ||
-> Bitmap Index Scan on spoint10k_star_idx (rows=6 width=0) (actual rows=16 loops=1) | ||
Index Cond: (star <@ '<(1 , 1) , 0.05>'::scircle) | ||
-> Index Scan using spoint10k_star_idx on spoint10k b (rows=1 width=16) (actual rows=1 loops=12) | ||
Index Cond: ((star OPERATOR(public.<@) scircle(a.star, '0.01'::double precision)) AND (star <@ '<(1 , 1) , 0.1>'::scircle)) | ||
Rows Removed by Index Recheck: 0 | ||
(10 rows) | ||
2 changes: 1 addition & 1 deletionexpected/index.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -55,6 +55,7 @@ SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>'; | ||
-- create idx | ||
CREATE TABLE spheretmp1b AS TABLE spheretmp1; | ||
ANALYZE spheretmp1; | ||
df7cb marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
CREATE INDEX aaaidx ON spheretmp1 USING gist ( p ); | ||
CREATE INDEX spoint3_idx ON spheretmp1b USING gist (p spoint3); | ||
CREATE INDEX bbbidx ON spheretmp2 USING gist ( c ); | ||
@@ -165,7 +166,6 @@ EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1 | ||
4 | ||
(1 row) | ||
SET enable_indexonlyscan = OFF; | ||
EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; | ||
QUERY PLAN | ||
16 changes: 16 additions & 0 deletionsexpected/points.out
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.