mirror of https://github.com/postgres/postgres
That includes VACUUM on GIN, GiST and SP-GiST indexes, and B-tree indexes large enough to cause page deletions in B-tree. Plus some other special cases. After this patch, the regression tests generate all different WAL record types. Not all branches within the redo functions are covered, but it's a step forward.pull/14/head
parent
a016555361
commit
88fc719263
@ -0,0 +1,23 @@ |
|||||||
|
-- |
||||||
|
-- Test GIN indexes. |
||||||
|
-- |
||||||
|
-- There are other tests to test different GIN opclassed. This is for testing |
||||||
|
-- GIN itself. |
||||||
|
-- Create and populate a test table with a GIN index. |
||||||
|
create table gin_test_tbl(i int4[]); |
||||||
|
create index gin_test_idx on gin_test_tbl using gin (i) with (fastupdate = on); |
||||||
|
insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 20000) g; |
||||||
|
insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g; |
||||||
|
vacuum gin_test_tbl; -- flush the fastupdate buffers |
||||||
|
-- Test vacuuming |
||||||
|
delete from gin_test_tbl where i @> array[2]; |
||||||
|
vacuum gin_test_tbl; |
||||||
|
-- Disable fastupdate, and do more insertions. With fastupdate enabled, most |
||||||
|
-- insertions (by flushing the list pages) cause page splits. Without |
||||||
|
-- fastupdate, we get more churn in the GIN data leaf pages, and exercise the |
||||||
|
-- recompression codepaths. |
||||||
|
alter index gin_test_idx set (fastupdate = off); |
||||||
|
insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 1000) g; |
||||||
|
insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g; |
||||||
|
delete from gin_test_tbl where i @> array[2]; |
||||||
|
vacuum gin_test_tbl; |
@ -0,0 +1,19 @@ |
|||||||
|
-- |
||||||
|
-- Test GiST indexes. |
||||||
|
-- |
||||||
|
-- There are other tests to test different GiST opclasses. This is for |
||||||
|
-- testing GiST code itself. Vacuuming in particular. |
||||||
|
create table gist_point_tbl(id int4, p point); |
||||||
|
create index gist_pointidx on gist_point_tbl using gist(p); |
||||||
|
-- Insert enough data to create a tree that's a couple of levels deep. |
||||||
|
insert into gist_point_tbl (id, p) |
||||||
|
select g, point(g*10, g*10) from generate_series(1, 10000) g; |
||||||
|
insert into gist_point_tbl (id, p) |
||||||
|
select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g; |
||||||
|
-- To test vacuum, delete some entries from all over the index. |
||||||
|
delete from gist_point_tbl where id % 2 = 1; |
||||||
|
-- And also delete some concentration of values. (GiST doesn't currently |
||||||
|
-- attempt to delete pages even when they become empty, but if it did, this |
||||||
|
-- would exercise it) |
||||||
|
delete from gist_point_tbl where id < 10000; |
||||||
|
vacuum gist_point_tbl; |
@ -0,0 +1,39 @@ |
|||||||
|
-- |
||||||
|
-- Test SP-GiST indexes. |
||||||
|
-- |
||||||
|
-- There are other tests to test different SP-GiST opclasses. This is for |
||||||
|
-- testing SP-GiST code itself. |
||||||
|
create table spgist_point_tbl(id int4, p point); |
||||||
|
create index spgist_point_idx on spgist_point_tbl using spgist(p); |
||||||
|
-- Test vacuum-root operation. It gets invoked when the root is also a leaf, |
||||||
|
-- i.e. the index is very small. |
||||||
|
insert into spgist_point_tbl (id, p) |
||||||
|
select g, point(g*10, g*10) from generate_series(1, 10) g; |
||||||
|
delete from spgist_point_tbl where id < 5; |
||||||
|
vacuum spgist_point_tbl; |
||||||
|
-- Insert more data, to make the index a few levels deep. |
||||||
|
insert into spgist_point_tbl (id, p) |
||||||
|
select g, point(g*10, g*10) from generate_series(1, 10000) g; |
||||||
|
insert into spgist_point_tbl (id, p) |
||||||
|
select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g; |
||||||
|
-- To test vacuum, delete some entries from all over the index. |
||||||
|
delete from spgist_point_tbl where id % 2 = 1; |
||||||
|
-- And also delete some concentration of values. (SP-GiST doesn't currently |
||||||
|
-- attempt to delete pages even when they become empty, but if it did, this |
||||||
|
-- would exercise it) |
||||||
|
delete from spgist_point_tbl where id < 10000; |
||||||
|
vacuum spgist_point_tbl; |
||||||
|
-- The point opclass's choose method only uses the spgMatchNode action, |
||||||
|
-- so the other actions are not tested by the above. Create an index using |
||||||
|
-- text opclass, which uses the others actions. |
||||||
|
create table spgist_text_tbl(id int4, t text); |
||||||
|
create index spgist_text_idx on spgist_text_tbl using spgist(t); |
||||||
|
insert into spgist_text_tbl (id, t) |
||||||
|
select g, 'f' || repeat('o', 100) || g from generate_series(1, 10000) g |
||||||
|
union all |
||||||
|
select g, 'baaaaaaaaaaaaaar' || g from generate_series(1, 1000) g; |
||||||
|
-- Do a lot of insertions that have to split an existing node. Hopefully |
||||||
|
-- one of these will cause the page to run out of space, causing the inner |
||||||
|
-- tuple to be moved to another page. |
||||||
|
insert into spgist_text_tbl (id, t) |
||||||
|
select -g, 'f' || repeat('o', 100-g) || 'surprise' from generate_series(1, 100) g; |
@ -0,0 +1,29 @@ |
|||||||
|
-- |
||||||
|
-- Test GIN indexes. |
||||||
|
-- |
||||||
|
-- There are other tests to test different GIN opclassed. This is for testing |
||||||
|
-- GIN itself. |
||||||
|
|
||||||
|
-- Create and populate a test table with a GIN index. |
||||||
|
create table gin_test_tbl(i int4[]); |
||||||
|
create index gin_test_idx on gin_test_tbl using gin (i) with (fastupdate = on); |
||||||
|
insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 20000) g; |
||||||
|
insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g; |
||||||
|
|
||||||
|
vacuum gin_test_tbl; -- flush the fastupdate buffers |
||||||
|
|
||||||
|
-- Test vacuuming |
||||||
|
delete from gin_test_tbl where i @> array[2]; |
||||||
|
vacuum gin_test_tbl; |
||||||
|
|
||||||
|
-- Disable fastupdate, and do more insertions. With fastupdate enabled, most |
||||||
|
-- insertions (by flushing the list pages) cause page splits. Without |
||||||
|
-- fastupdate, we get more churn in the GIN data leaf pages, and exercise the |
||||||
|
-- recompression codepaths. |
||||||
|
alter index gin_test_idx set (fastupdate = off); |
||||||
|
|
||||||
|
insert into gin_test_tbl select array[1, 2, g] from generate_series(1, 1000) g; |
||||||
|
insert into gin_test_tbl select array[1, 3, g] from generate_series(1, 1000) g; |
||||||
|
|
||||||
|
delete from gin_test_tbl where i @> array[2]; |
||||||
|
vacuum gin_test_tbl; |
@ -0,0 +1,25 @@ |
|||||||
|
-- |
||||||
|
-- Test GiST indexes. |
||||||
|
-- |
||||||
|
-- There are other tests to test different GiST opclasses. This is for |
||||||
|
-- testing GiST code itself. Vacuuming in particular. |
||||||
|
|
||||||
|
create table gist_point_tbl(id int4, p point); |
||||||
|
create index gist_pointidx on gist_point_tbl using gist(p); |
||||||
|
|
||||||
|
-- Insert enough data to create a tree that's a couple of levels deep. |
||||||
|
insert into gist_point_tbl (id, p) |
||||||
|
select g, point(g*10, g*10) from generate_series(1, 10000) g; |
||||||
|
|
||||||
|
insert into gist_point_tbl (id, p) |
||||||
|
select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g; |
||||||
|
|
||||||
|
-- To test vacuum, delete some entries from all over the index. |
||||||
|
delete from gist_point_tbl where id % 2 = 1; |
||||||
|
|
||||||
|
-- And also delete some concentration of values. (GiST doesn't currently |
||||||
|
-- attempt to delete pages even when they become empty, but if it did, this |
||||||
|
-- would exercise it) |
||||||
|
delete from gist_point_tbl where id < 10000; |
||||||
|
|
||||||
|
vacuum gist_point_tbl; |
@ -0,0 +1,50 @@ |
|||||||
|
-- |
||||||
|
-- Test SP-GiST indexes. |
||||||
|
-- |
||||||
|
-- There are other tests to test different SP-GiST opclasses. This is for |
||||||
|
-- testing SP-GiST code itself. |
||||||
|
|
||||||
|
create table spgist_point_tbl(id int4, p point); |
||||||
|
create index spgist_point_idx on spgist_point_tbl using spgist(p); |
||||||
|
|
||||||
|
-- Test vacuum-root operation. It gets invoked when the root is also a leaf, |
||||||
|
-- i.e. the index is very small. |
||||||
|
insert into spgist_point_tbl (id, p) |
||||||
|
select g, point(g*10, g*10) from generate_series(1, 10) g; |
||||||
|
delete from spgist_point_tbl where id < 5; |
||||||
|
vacuum spgist_point_tbl; |
||||||
|
|
||||||
|
-- Insert more data, to make the index a few levels deep. |
||||||
|
insert into spgist_point_tbl (id, p) |
||||||
|
select g, point(g*10, g*10) from generate_series(1, 10000) g; |
||||||
|
insert into spgist_point_tbl (id, p) |
||||||
|
select g+100000, point(g*10+1, g*10+1) from generate_series(1, 10000) g; |
||||||
|
|
||||||
|
-- To test vacuum, delete some entries from all over the index. |
||||||
|
delete from spgist_point_tbl where id % 2 = 1; |
||||||
|
|
||||||
|
-- And also delete some concentration of values. (SP-GiST doesn't currently |
||||||
|
-- attempt to delete pages even when they become empty, but if it did, this |
||||||
|
-- would exercise it) |
||||||
|
delete from spgist_point_tbl where id < 10000; |
||||||
|
|
||||||
|
vacuum spgist_point_tbl; |
||||||
|
|
||||||
|
|
||||||
|
-- The point opclass's choose method only uses the spgMatchNode action, |
||||||
|
-- so the other actions are not tested by the above. Create an index using |
||||||
|
-- text opclass, which uses the others actions. |
||||||
|
|
||||||
|
create table spgist_text_tbl(id int4, t text); |
||||||
|
create index spgist_text_idx on spgist_text_tbl using spgist(t); |
||||||
|
|
||||||
|
insert into spgist_text_tbl (id, t) |
||||||
|
select g, 'f' || repeat('o', 100) || g from generate_series(1, 10000) g |
||||||
|
union all |
||||||
|
select g, 'baaaaaaaaaaaaaar' || g from generate_series(1, 1000) g; |
||||||
|
|
||||||
|
-- Do a lot of insertions that have to split an existing node. Hopefully |
||||||
|
-- one of these will cause the page to run out of space, causing the inner |
||||||
|
-- tuple to be moved to another page. |
||||||
|
insert into spgist_text_tbl (id, t) |
||||||
|
select -g, 'f' || repeat('o', 100-g) || 'surprise' from generate_series(1, 100) g; |
Loading…
Reference in new issue