-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare the original PR of @gbroccolo for the merge
Move brin.c(h) files into src subdirectory Add brin support in upgrade script Fix some code problems Fix test_init Fix Indices section in the doc Add test for sbox BRIN index Fix found problems in the doc after review Fix BRIN support for sbox
- Loading branch information
Vitaly Davydov
committed
Aug 26, 2023
1 parent
6ebf5c2
commit fa429a5
Showing
11 changed files
with
337 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,56 +1,87 @@ | ||
CREATE TABLE | ||
COPY 77 | ||
CREATE FUNCTION | ||
CREATE INDEX | ||
SET | ||
SET | ||
SET | ||
?column? | qnodes | ||
----------+---------- | ||
scan_seq | Seq Scan | ||
(1 row) | ||
|
||
p | ||
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) | ||
|
||
?column? | qnodes | ||
----------+---------- | ||
scan_seq | Seq Scan | ||
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) | ||
|
||
p | ||
SELECT * FROM test_points WHERE p && sbox '( (10d,10d), (20d,20d) )'; | ||
p | ||
----------------------------------------- | ||
(0.349065850398866 , 0.174532925199433) | ||
(1 row) | ||
|
||
SET | ||
SET | ||
SET | ||
?column? | qnodes | ||
----------+------------------------------------ | ||
scan_idx | Bitmap Heap Scan,Bitmap Index Scan | ||
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) | ||
|
||
p | ||
SELECT * FROM test_points WHERE p <@ sbox '( (10d,10d), (20d,20d) )'; | ||
p | ||
----------------------------------------- | ||
(0.349065850398866 , 0.174532925199433) | ||
(1 row) | ||
|
||
?column? | qnodes | ||
----------+------------------------------------ | ||
scan_idx | Bitmap Heap Scan,Bitmap Index Scan | ||
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) | ||
|
||
p | ||
SELECT * FROM test_points WHERE p && sbox '( (10d,10d), (20d,20d) )'; | ||
p | ||
----------------------------------------- | ||
(0.349065850398866 , 0.174532925199433) | ||
(1 row) | ||
|
||
DROP INDEX | ||
DROP TABLE | ||
DROP FUNCTION | ||
SET | ||
SET | ||
SET | ||
-- 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; |
This file contains 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.