-
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.
Configurable smoc_gin_ops index resolution
Back when smoc GIN indexes were implemented, indexes did not support opclass options yet; that was added only later in PG 13. Add an "order" parameter on the smoc_gin_ops opclass to allow picking the smoc index granularity between level 0 and 12. (Larger levels do not fit into the internal int32 datatype anymore.) Example: `create index on sky using gin (coverage smoc_gin_ops (order = 8))`
- Loading branch information
Showing
8 changed files
with
137 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
create table moc_opt (m smoc); | ||
insert into moc_opt select format('9/%s', i)::smoc from generate_series(1, 1000) g(i); | ||
analyze moc_opt; | ||
create index moc_opt5 on moc_opt using gin (m); | ||
explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; | ||
QUERY PLAN | ||
--------------------------------------------------------------- | ||
Bitmap Heap Scan on moc_opt (actual rows=1 loops=1) | ||
Recheck Cond: (m && '9/1'::smoc) | ||
Rows Removed by Index Recheck: 254 | ||
Heap Blocks: exact=4 | ||
-> Bitmap Index Scan on moc_opt5 (actual rows=255 loops=1) | ||
Index Cond: (m && '9/1'::smoc) | ||
(6 rows) | ||
|
||
drop index moc_opt5; | ||
create index moc_opt8 on moc_opt using gin (m smoc_gin_ops_fine); | ||
explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; | ||
QUERY PLAN | ||
------------------------------------------------------------- | ||
Bitmap Heap Scan on moc_opt (actual rows=1 loops=1) | ||
Recheck Cond: (m && '9/1'::smoc) | ||
Rows Removed by Index Recheck: 2 | ||
Heap Blocks: exact=1 | ||
-> Bitmap Index Scan on moc_opt8 (actual rows=3 loops=1) | ||
Index Cond: (m && '9/1'::smoc) | ||
(6 rows) | ||
|
||
drop index moc_opt8; | ||
create index moc_opt9 on moc_opt using gin (m smoc_gin_ops (order = 9)); | ||
explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; | ||
QUERY PLAN | ||
------------------------------------------------------------- | ||
Bitmap Heap Scan on moc_opt (actual rows=1 loops=1) | ||
Recheck Cond: (m && '9/1'::smoc) | ||
Heap Blocks: exact=1 | ||
-> Bitmap Index Scan on moc_opt9 (actual rows=1 loops=1) | ||
Index Cond: (m && '9/1'::smoc) | ||
(5 rows) | ||
|
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- GIN opclass options | ||
|
||
CREATE FUNCTION smoc_gin_options (internal) | ||
RETURNS void | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C | ||
PARALLEL SAFE | ||
IMMUTABLE | ||
STRICT; | ||
|
||
ALTER OPERATOR FAMILY smoc_gin_ops USING gin | ||
ADD FUNCTION 7 (smoc) smoc_gin_options (internal); |
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,14 @@ | ||
create table moc_opt (m smoc); | ||
insert into moc_opt select format('9/%s', i)::smoc from generate_series(1, 1000) g(i); | ||
analyze moc_opt; | ||
|
||
create index moc_opt5 on moc_opt using gin (m); | ||
explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; | ||
drop index moc_opt5; | ||
|
||
create index moc_opt8 on moc_opt using gin (m smoc_gin_ops_fine); | ||
explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; | ||
drop index moc_opt8; | ||
|
||
create index moc_opt9 on moc_opt using gin (m smoc_gin_ops (order = 9)); | ||
explain (analyze, costs off, timing off, summary off) select * from moc_opt where m && '9/1'; |
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