mirror of https://github.com/citusdata/citus.git
121 lines
3.7 KiB
Plaintext
121 lines
3.7 KiB
Plaintext
--
|
|
-- MULTI_SIZE_QUERIES
|
|
--
|
|
-- Test checks whether size of distributed tables can be obtained with citus_table_size.
|
|
-- To find the relation size and total relation size citus_relation_size and
|
|
-- citus_total_relation_size are also tested.
|
|
SET citus.next_shard_id TO 1390000;
|
|
ALTER SEQUENCE pg_catalog.pg_dist_jobid_seq RESTART 1390000;
|
|
-- Tests with invalid relation IDs
|
|
SELECT citus_table_size(1);
|
|
ERROR: could not compute table size: relation does not exist
|
|
SELECT citus_relation_size(1);
|
|
ERROR: could not compute table size: relation does not exist
|
|
SELECT citus_total_relation_size(1);
|
|
ERROR: could not compute table size: relation does not exist
|
|
-- Tests with non-distributed table
|
|
CREATE TABLE non_distributed_table (x int);
|
|
SELECT citus_table_size('non_distributed_table');
|
|
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
|
SELECT citus_relation_size('non_distributed_table');
|
|
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
|
SELECT citus_total_relation_size('non_distributed_table');
|
|
ERROR: cannot calculate the size because relation 'non_distributed_table' is not distributed
|
|
DROP TABLE non_distributed_table;
|
|
-- Tests on distributed table with replication factor > 1
|
|
SELECT citus_table_size('lineitem_hash_part');
|
|
ERROR: cannot calculate the size because replication factor is greater than 1
|
|
SELECT citus_relation_size('lineitem_hash_part');
|
|
ERROR: cannot calculate the size because replication factor is greater than 1
|
|
SELECT citus_total_relation_size('lineitem_hash_part');
|
|
ERROR: cannot calculate the size because replication factor is greater than 1
|
|
VACUUM (FULL) customer_copy_hash;
|
|
-- Tests on distributed tables with streaming replication.
|
|
SELECT citus_table_size('customer_copy_hash');
|
|
citus_table_size
|
|
------------------
|
|
548864
|
|
(1 row)
|
|
|
|
SELECT citus_relation_size('customer_copy_hash');
|
|
citus_relation_size
|
|
---------------------
|
|
548864
|
|
(1 row)
|
|
|
|
SELECT citus_total_relation_size('customer_copy_hash');
|
|
citus_total_relation_size
|
|
---------------------------
|
|
1597440
|
|
(1 row)
|
|
|
|
CREATE INDEX index_1 on customer_copy_hash(c_custkey);
|
|
VACUUM (FULL) customer_copy_hash;
|
|
-- Tests on distributed table with index.
|
|
SELECT citus_table_size('customer_copy_hash');
|
|
citus_table_size
|
|
------------------
|
|
548864
|
|
(1 row)
|
|
|
|
SELECT citus_relation_size('customer_copy_hash');
|
|
citus_relation_size
|
|
---------------------
|
|
548864
|
|
(1 row)
|
|
|
|
SELECT citus_total_relation_size('customer_copy_hash');
|
|
citus_total_relation_size
|
|
---------------------------
|
|
2646016
|
|
(1 row)
|
|
|
|
-- Tests on reference table
|
|
VACUUM (FULL) supplier;
|
|
SELECT citus_table_size('supplier');
|
|
citus_table_size
|
|
------------------
|
|
376832
|
|
(1 row)
|
|
|
|
SELECT citus_relation_size('supplier');
|
|
citus_relation_size
|
|
---------------------
|
|
376832
|
|
(1 row)
|
|
|
|
SELECT citus_total_relation_size('supplier');
|
|
citus_total_relation_size
|
|
---------------------------
|
|
376832
|
|
(1 row)
|
|
|
|
CREATE INDEX index_2 on supplier(s_suppkey);
|
|
VACUUM (FULL) supplier;
|
|
SELECT citus_table_size('supplier');
|
|
citus_table_size
|
|
------------------
|
|
376832
|
|
(1 row)
|
|
|
|
SELECT citus_relation_size('supplier');
|
|
citus_relation_size
|
|
---------------------
|
|
376832
|
|
(1 row)
|
|
|
|
SELECT citus_total_relation_size('supplier');
|
|
citus_total_relation_size
|
|
---------------------------
|
|
458752
|
|
(1 row)
|
|
|
|
-- Test inside the transaction
|
|
BEGIN;
|
|
ALTER TABLE supplier ALTER COLUMN s_suppkey SET NOT NULL;
|
|
select citus_table_size('supplier');
|
|
ERROR: citus size functions cannot be called in transaction blocks which contain multi-shard data modifications
|
|
END;
|
|
DROP INDEX index_1;
|
|
DROP INDEX index_2;
|