-
Notifications
You must be signed in to change notification settings - Fork 15
Add BRIN support for spoint and sbox #55
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ 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/line.o src/ellipse.o src/polygon.o \ | ||
src/path.o src/box.o src/output.o src/gq_cache.o src/gist.o \ | ||
src/key.o src/gnomo.o src/epochprop.o | ||
src/key.o src/gnomo.o src/epochprop.o src/brin.o | ||
|
||
ifneq ($(USE_HEALPIX),0) | ||
OBJS += src/healpix.o src/moc.o src/process_moc.o \ | ||
|
@@ -33,7 +33,7 @@ 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 | ||
contains overlaps spoint_brin sbox_brin | ||
|
||
ifneq ($(USE_HEALPIX),0) | ||
REGRESS += healpix moc mocautocast | ||
|
@@ -43,7 +43,7 @@ REGRESS_9_5 = index_9.5 # experimental for spoint3 | |
|
||
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 | ||
epochprop contains overlaps spoint_brin sbox_brin | ||
|
||
ifneq ($(USE_HEALPIX),0) | ||
TESTS += healpix moc mocautocast | ||
|
@@ -66,7 +66,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_gist.sql gnomo.sql pgs_brin.sql | ||
|
||
ifneq ($(USE_HEALPIX),0) | ||
PGS_SQL += healpix.sql | ||
|
@@ -262,7 +262,7 @@ endif | |
pg_sphere--1.2.2--1.2.3.sql: | ||
cat upgrade_scripts/[email protected] > $@ | ||
|
||
pg_sphere--1.2.3--1.3.0.sql: | ||
pg_sphere--1.2.3--1.3.0.sql: pgs_brin.sql.in | ||
cat upgrade_scripts/[email protected] > $@ | ||
|
||
# end of local stuff | ||
|
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
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
psql:pg_sphere.test.sql:9271: NOTICE: return type smoc is only a shell | ||
psql:pg_sphere.test.sql:9277: NOTICE: argument type smoc is only a shell | ||
psql:pg_sphere.test.sql:9684: NOTICE: return type smoc is only a shell | ||
psql:pg_sphere.test.sql:9690: NOTICE: argument type smoc is only a shell |
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,91 @@ | ||
SELECT set_sphere_output_precision(8); | ||
set_sphere_output_precision | ||
----------------------------- | ||
SET 8 | ||
(1 row) | ||
|
||
CREATE TABLE test_boxes ( | ||
b sbox | ||
); | ||
COPY test_boxes (b) FROM stdin; | ||
CREATE OR REPLACE FUNCTION qnodes(q text) RETURNS text | ||
LANGUAGE 'plpgsql' AS | ||
$$ | ||
DECLARE | ||
exp TEXT; | ||
mat TEXT[]; | ||
ret TEXT[]; | ||
BEGIN | ||
FOR exp IN EXECUTE 'EXPLAIN ' || q | ||
LOOP | ||
--RAISE NOTICE 'EXP: %', exp; | ||
mat := regexp_matches(exp, ' *(?:-> *)?(.*Scan on (test_boxes|test_boxes_brin_idx))'); | ||
--RAISE NOTICE 'MAT: %', mat; | ||
IF mat IS NOT NULL THEN | ||
ret := array_append(ret, mat[1]); | ||
END IF; | ||
--RAISE NOTICE 'RET: %', ret; | ||
END LOOP; | ||
RETURN array_to_string(ret,','); | ||
END; | ||
$$; | ||
CREATE INDEX test_boxes_brin_idx ON test_boxes USING brin (b); | ||
SET enable_indexscan = OFF; | ||
SET enable_bitmapscan = OFF; | ||
SET enable_seqscan = ON; | ||
SELECT 'scan_seq', qnodes('SELECT * FROM test_boxes WHERE b <@ sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------ | ||
scan_seq | Seq Scan on test_boxes | ||
(1 row) | ||
|
||
SELECT * FROM test_boxes WHERE b <@ sbox '( (10d,10d), (20d,20d) )'; | ||
b | ||
--- | ||
(0 rows) | ||
|
||
SELECT 'scan_seq', qnodes('SELECT * FROM test_boxes WHERE b && sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------ | ||
scan_seq | Seq Scan on test_boxes | ||
(1 row) | ||
|
||
SELECT * FROM test_boxes WHERE b && sbox '( (10d,10d), (20d,20d) )'; | ||
b | ||
-------------------------------------------------------- | ||
((0.34906585 , 0.17453293), (0.35006585 , 0.17463293)) | ||
(1 row) | ||
|
||
SET enable_indexscan = OFF; | ||
SET enable_bitmapscan = ON; | ||
SET enable_seqscan = OFF; | ||
SELECT 'scan_idx', qnodes('SELECT * FROM test_boxes WHERE b <@ sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------------------------------------------------------- | ||
scan_idx | Bitmap Heap Scan on test_boxes,Bitmap Index Scan on test_boxes_brin_idx | ||
(1 row) | ||
|
||
SELECT * FROM test_boxes WHERE b <@ sbox '( (10d,10d), (20d,20d) )'; | ||
b | ||
--- | ||
(0 rows) | ||
|
||
SELECT 'scan_idx', qnodes('SELECT * FROM test_boxes WHERE b && sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------------------------------------------------------- | ||
scan_idx | Bitmap Heap Scan on test_boxes,Bitmap Index Scan on test_boxes_brin_idx | ||
(1 row) | ||
|
||
SELECT * FROM test_boxes WHERE b && sbox '( (10d,10d), (20d,20d) )'; | ||
b | ||
-------------------------------------------------------- | ||
((0.34906585 , 0.17453293), (0.35006585 , 0.17463293)) | ||
(1 row) | ||
|
||
---- cleanup | ||
DROP INDEX test_boxes_brin_idx; | ||
DROP TABLE test_boxes; | ||
DROP FUNCTION qnodes(text); | ||
SET enable_indexscan = ON; | ||
SET enable_bitmapscan = ON; | ||
SET enable_seqscan = ON; |
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,87 @@ | ||
CREATE TABLE test_points ( | ||
p spoint | ||
); | ||
COPY test_points (p) FROM stdin; | ||
CREATE OR REPLACE FUNCTION qnodes(q text) RETURNS text | ||
LANGUAGE 'plpgsql' AS | ||
$$ | ||
DECLARE | ||
exp TEXT; | ||
mat TEXT[]; | ||
ret TEXT[]; | ||
BEGIN | ||
FOR exp IN EXECUTE 'EXPLAIN ' || q | ||
LOOP | ||
--RAISE NOTICE 'EXP: %', exp; | ||
mat := regexp_matches(exp, ' *(?:-> *)?(.*Scan on (test_points|brin_spoint))'); | ||
--RAISE NOTICE 'MAT: %', mat; | ||
IF mat IS NOT NULL THEN | ||
ret := array_append(ret, mat[1]); | ||
END IF; | ||
--RAISE NOTICE 'RET: %', ret; | ||
END LOOP; | ||
RETURN array_to_string(ret,','); | ||
END; | ||
$$; | ||
CREATE INDEX brin_spoint ON test_points USING brin (p) WITH (pages_per_range = 16); | ||
set enable_indexscan = off; | ||
set enable_bitmapscan = off; | ||
set enable_seqscan = on; | ||
SELECT 'scan_seq', qnodes('SELECT * FROM test_points WHERE p <@ sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------- | ||
scan_seq | Seq Scan on test_points | ||
(1 row) | ||
|
||
SELECT * FROM test_points WHERE p <@ sbox '( (10d,10d), (20d,20d) )'; | ||
p | ||
----------------------------------------- | ||
(0.349065850398866 , 0.174532925199433) | ||
(1 row) | ||
|
||
SELECT 'scan_seq', qnodes('SELECT * FROM test_points WHERE p && sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------- | ||
scan_seq | Seq Scan on test_points | ||
(1 row) | ||
|
||
SELECT * FROM test_points WHERE p && sbox '( (10d,10d), (20d,20d) )'; | ||
p | ||
----------------------------------------- | ||
(0.349065850398866 , 0.174532925199433) | ||
(1 row) | ||
|
||
set enable_indexscan = off; | ||
set enable_bitmapscan = on; | ||
set enable_seqscan = off; | ||
SELECT 'scan_idx', qnodes('SELECT * FROM test_points WHERE p <@ sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------------------------------------------------ | ||
scan_idx | Bitmap Heap Scan on test_points,Bitmap Index Scan on brin_spoint | ||
(1 row) | ||
|
||
SELECT * FROM test_points WHERE p <@ sbox '( (10d,10d), (20d,20d) )'; | ||
p | ||
----------------------------------------- | ||
(0.349065850398866 , 0.174532925199433) | ||
(1 row) | ||
|
||
SELECT 'scan_idx', qnodes('SELECT * FROM test_points WHERE p && sbox ''( (10d,10d), (20d,20d) )'''); | ||
?column? | qnodes | ||
----------+------------------------------------------------------------------ | ||
scan_idx | Bitmap Heap Scan on test_points,Bitmap Index Scan on brin_spoint | ||
(1 row) | ||
|
||
SELECT * FROM test_points WHERE p && sbox '( (10d,10d), (20d,20d) )'; | ||
p | ||
----------------------------------------- | ||
(0.349065850398866 , 0.174532925199433) | ||
(1 row) | ||
|
||
-- cleanup | ||
DROP INDEX brin_spoint; | ||
DROP TABLE test_points; | ||
DROP FUNCTION qnodes(text); | ||
set enable_indexscan = on; | ||
set enable_bitmapscan = on; | ||
set enable_seqscan = on; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either change "data blocks" to "data block" or add an apostrophe after "data blocks" to make it possessive. "data block pages" or "data blocks' pages".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@esabol The 'pages' word is written in the brackets. It is how the text is shown in the generated pdf: "summarization" of data blocks (pages) on physical storage...
I think the word pages is used here as the synonym of data blocks. Not sure, we should make this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I didn't see the parentheses. Do not change this.