CREATE TABLE uaocs_basic (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO uaocs_basic SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1, 10) AS i;
INSERT INTO uaocs_basic SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1, 10) AS i;
-- @Description Tests dropping a column after a compaction with update
CREATE TABLE uaocs_drop_column_update(
text_col text,
bigint_col bigint,
char_vary_col character varying(30),
int_array_col int[],
drop_col numeric) with (appendonly=true, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'text_col' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
INSERT INTO uaocs_drop_column_update values ('1_zero', 1, '1_zero', '{1}', 1);
ALTER TABLE uaocs_drop_column_update DROP COLUMN drop_col;
Select char_vary_col, int_array_col from uaocs_drop_column_update;
char_vary_col | int_array_col
---------------+---------------
1_zero | {1}
(1 row)
INSERT INTO uaocs_drop_column_update values ('2_zero', 2, '2_zero', '{2}');
update uaocs_drop_column_update set bigint_col = bigint_col + 1 where text_col = '1_zero';
Select char_vary_col, int_array_col from uaocs_drop_column_update;
-- @Description Tests the behavior while compacting is disabled
CREATE TABLE uaocs_eof_truncate (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE INDEX uaocs_eof_truncate_index ON uaocs_eof_truncate(b);
BEGIN;
INSERT INTO uaocs_eof_truncate SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1,1000) AS i;
COMMIT;
BEGIN;
INSERT INTO uaocs_eof_truncate SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1000,2000) AS i;
ROLLBACK;
SET gp_appendonly_compaction=false;
SELECT COUNT(*) FROM uaocs_eof_truncate;
count
-------
1000
(1 row)
VACUUM uaocs_eof_truncate;
SELECT COUNT(*) FROM uaocs_eof_truncate;
count
-------
1000
(1 row)
-- Insert afterwards
INSERT INTO uaocs_eof_truncate SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1,10) AS i;
-- @Description Test the basic bahavior of vacuum full
CREATE TABLE uaocs_full (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE INDEX uaocs_full_index ON uaocs_full(b);
INSERT INTO uaocs_full SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1,10) AS i;
INSERT INTO uaocs_full SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1,10) AS i;
-- @Description Tests the behavior while compacting is disabled
CREATE TABLE uaocs_full_eof_truncate (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE INDEX uaocs_full_eof_truncate_index ON uaocs_full_eof_truncate(b);
BEGIN;
INSERT INTO uaocs_full_eof_truncate SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1,1000) AS i;
COMMIT;
BEGIN;
INSERT INTO uaocs_full_eof_truncate SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1000,2000) AS i;
ROLLBACK;
SET gp_appendonly_compaction=false;
SELECT COUNT(*) FROM uaocs_full_eof_truncate;
count
-------
1000
(1 row)
VACUUM FULL uaocs_full_eof_truncate;
SELECT COUNT(*) FROM uaocs_full_eof_truncate;
count
-------
1000
(1 row)
-- Insert afterwards
INSERT INTO uaocs_full_eof_truncate SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1,10) AS i;
-- @Description Tests basic index usage behavior after vacuuming
CREATE TABLE uaocs_index (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE INDEX uaocs_index_index ON uaocs_index(b);
INSERT INTO uaocs_index SELECT i as a, i as b, 'hello world' as c FROM generate_series(1,10) AS i;
INSERT INTO uaocs_index SELECT i as a, i as b, 'hello world' as c FROM generate_series(1,10) AS i;
-- @Description Tests the basic behavior of (lazy) vacuum w.r.t. to the threshold guc.
-- The output depends on the number of segments as the skip decision and the
-- notify is done on the segments.
CREATE TABLE uaocs_threshold (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE INDEX uaocs_threshold_index ON uaocs_threshold(b);
INSERT INTO uaocs_threshold SELECT i as a, 1 as b, 'hello world' as c FROM generate_series(1, 100) AS i;
\set QUIET off
VACUUM uaocs_threshold;
VACUUM
DELETE FROM uaocs_threshold WHERE a < 4;
DELETE 3
SELECT COUNT(*) FROM uaocs_threshold;
count
-------
97
(1 row)
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');
segno | tupcount | state
-------+----------+-------
1 | 100 | 1
(1 row)
-- 97 visible tuples, no vacuum
VACUUM uaocs_threshold;
VACUUM
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');
segno | tupcount | state
-------+----------+-------
1 | 100 | 1
(1 row)
DELETE FROM uaocs_threshold WHERE a < 12;
DELETE 8
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');
segno | tupcount | state
-------+----------+-------
1 | 100 | 1
(1 row)
-- 89 visible tuples, do vacuum
VACUUM uaocs_threshold;
VACUUM
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');
segno | tupcount | state
-------+----------+-------
1 | 50 | 1
2 | 44 | 1
(2 rows)
-- no invisible tuples, no vacuum
VACUUM uaocs_threshold;
VACUUM
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');
segno | tupcount | state
-------+----------+-------
1 | 50 | 1
2 | 44 | 1
(2 rows)
DELETE FROM uaocs_threshold WHERE a < 15;
DELETE 3
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');
segno | tupcount | state
-------+----------+-------
1 | 50 | 1
2 | 44 | 1
(2 rows)
-- 3 invisible tuples, no vacuum
VACUUM uaocs_threshold;
VACUUM
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');
segno | tupcount | state
-------+----------+-------
2 | 44 | 1
1 | 0 | 1
3 | 43 | 1
(3 rows)
SET gp_appendonly_compaction_threshold=2;
SET
-- 3 invisible tuples, no vacuum
VACUUM uaocs_threshold;
VACUUM
SELECT DISTINCT segno, tupcount, state FROM gp_toolkit.__gp_aocsseg_name('uaocs_threshold');