--
|
-- one_c_temp_storage_parallel
|
--
|
|
SET client_min_messages = warning;
|
|
SET enable_temp_memory_catalog = on;
|
|
BEGIN;
|
CREATE TEMP TABLE tmc_storage_mem(
|
id integer,
|
grp integer,
|
payload text
|
);
|
INSERT INTO pg_temp.tmc_storage_mem(id, grp, payload)
|
SELECT g, g % 10, repeat('m', 200)
|
FROM generate_series(1, 5000) AS g;
|
CREATE INDEX tmc_storage_mem_idx ON pg_temp.tmc_storage_mem(grp, id);
|
ANALYZE pg_temp.tmc_storage_mem;
|
COMMIT;
|
|
VACUUM pg_temp.tmc_storage_mem;
|
SELECT count(*) AS mem_rows_after_vacuum,
|
sum(id) AS mem_id_sum_after_vacuum
|
FROM pg_temp.tmc_storage_mem;
|
REINDEX INDEX pg_temp.tmc_storage_mem_idx;
|
SELECT count(*) AS mem_rows_after_reindex
|
FROM pg_temp.tmc_storage_mem
|
WHERE grp = 0;
|
|
BEGIN;
|
TRUNCATE pg_temp.tmc_storage_mem;
|
INSERT INTO pg_temp.tmc_storage_mem(id, grp, payload)
|
SELECT g, g % 3, repeat('n', 50)
|
FROM generate_series(1, 12) AS g;
|
COMMIT;
|
|
VACUUM (ANALYZE) pg_temp.tmc_storage_mem;
|
SELECT count(*) AS mem_rows_after_truncate,
|
min(id) AS mem_min_id,
|
max(id) AS mem_max_id,
|
sum(grp) AS mem_grp_sum
|
FROM pg_temp.tmc_storage_mem;
|
|
BEGIN;
|
DROP TABLE pg_temp.tmc_storage_mem;
|
COMMIT;
|
|
SET enable_temp_memory_catalog = off;
|
|
CREATE TEMP TABLE tmc_storage_phys(
|
id integer,
|
grp integer
|
);
|
INSERT INTO pg_temp.tmc_storage_phys(id, grp)
|
SELECT g, g % 4
|
FROM generate_series(1, 20) AS g;
|
CREATE INDEX tmc_storage_phys_idx ON pg_temp.tmc_storage_phys(grp, id);
|
VACUUM pg_temp.tmc_storage_phys;
|
SELECT count(*) AS phys_rows_after_vacuum
|
FROM pg_temp.tmc_storage_phys;
|
REINDEX INDEX pg_temp.tmc_storage_phys_idx;
|
SELECT count(*) AS phys_rows_after_reindex
|
FROM pg_temp.tmc_storage_phys
|
WHERE grp = 0;
|
TRUNCATE pg_temp.tmc_storage_phys;
|
INSERT INTO pg_temp.tmc_storage_phys(id, grp)
|
VALUES (10, 1), (20, 2), (30, 3);
|
SELECT count(*) AS phys_rows_after_truncate,
|
sum(id) AS phys_id_sum_after_truncate
|
FROM pg_temp.tmc_storage_phys;
|
DROP TABLE pg_temp.tmc_storage_phys;
|
|
SET enable_temp_memory_catalog = on;
|
|
BEGIN;
|
CREATE TEMP TABLE tmc_storage_guc(
|
id integer,
|
payload text
|
);
|
INSERT INTO pg_temp.tmc_storage_guc(id, payload)
|
SELECT g, repeat('g', 40)
|
FROM generate_series(1, 9) AS g;
|
CREATE INDEX tmc_storage_guc_idx ON pg_temp.tmc_storage_guc(id);
|
COMMIT;
|
|
SET enable_temp_memory_catalog = off;
|
|
VACUUM pg_temp.tmc_storage_guc;
|
REINDEX INDEX pg_temp.tmc_storage_guc_idx;
|
TRUNCATE pg_temp.tmc_storage_guc;
|
INSERT INTO pg_temp.tmc_storage_guc(id, payload)
|
VALUES (41, 'after-off-one'), (42, 'after-off-two');
|
SELECT count(*) AS guc_rows_after_toggle,
|
min(id) AS guc_min_id,
|
max(id) AS guc_max_id
|
FROM pg_temp.tmc_storage_guc;
|
DROP TABLE pg_temp.tmc_storage_guc;
|
|
DROP TABLE IF EXISTS tmc_storage_perm;
|
|
CREATE TABLE tmc_storage_perm(
|
id integer,
|
grp integer,
|
payload text
|
);
|
INSERT INTO tmc_storage_perm(id, grp, payload)
|
SELECT g, g % 8, repeat('p', 200)
|
FROM generate_series(1, 5000) AS g;
|
CREATE INDEX tmc_storage_perm_idx ON tmc_storage_perm(grp, id);
|
ALTER TABLE tmc_storage_perm SET (parallel_workers = 2);
|
ANALYZE tmc_storage_perm;
|
VACUUM tmc_storage_perm;
|
REINDEX INDEX tmc_storage_perm_idx;
|
TRUNCATE tmc_storage_perm;
|
INSERT INTO tmc_storage_perm(id, grp, payload)
|
SELECT g, g % 8, repeat('q', 200)
|
FROM generate_series(1, 5000) AS g;
|
ANALYZE tmc_storage_perm;
|
SELECT count(*) AS perm_rows_after_truncate,
|
sum(id) AS perm_id_sum_after_truncate
|
FROM tmc_storage_perm;
|
|
SET enable_temp_memory_catalog = on;
|
|
CREATE TEMP TABLE tmc_storage_mem_parallel(
|
id integer,
|
grp integer,
|
payload text
|
);
|
INSERT INTO pg_temp.tmc_storage_mem_parallel(id, grp, payload)
|
SELECT g, g % 8, repeat('r', 200)
|
FROM generate_series(1, 5000) AS g;
|
ALTER TABLE pg_temp.tmc_storage_mem_parallel SET (parallel_workers = 2);
|
ANALYZE pg_temp.tmc_storage_mem_parallel;
|
|
SET max_parallel_workers_per_gather = 2;
|
SET min_parallel_table_scan_size = 0;
|
SET parallel_setup_cost = 0;
|
SET parallel_tuple_cost = 0;
|
SET enable_indexscan = off;
|
SET enable_indexonlyscan = off;
|
SET enable_bitmapscan = off;
|
|
EXPLAIN (COSTS OFF)
|
SELECT sum(id) FROM tmc_storage_perm;
|
|
EXPLAIN (COSTS OFF)
|
SELECT sum(id) FROM pg_temp.tmc_storage_mem_parallel;
|
|
RESET enable_bitmapscan;
|
RESET enable_indexonlyscan;
|
RESET enable_indexscan;
|
RESET parallel_tuple_cost;
|
RESET parallel_setup_cost;
|
RESET min_parallel_table_scan_size;
|
RESET max_parallel_workers_per_gather;
|
RESET enable_temp_memory_catalog;
|
|
DROP TABLE pg_temp.tmc_storage_mem_parallel;
|
DROP TABLE tmc_storage_perm;
|