diff --git a/src/test/regress/expected/multi_size_queries.out b/src/test/regress/expected/multi_size_queries.out index 6ddac6b86..23138b5dd 100644 --- a/src/test/regress/expected/multi_size_queries.out +++ b/src/test/regress/expected/multi_size_queries.out @@ -14,14 +14,12 @@ SELECT citus_total_relation_size(1); ERROR: could not compute relation size: relation does not exist -- Tests with non-distributed table CREATE TABLE non_distributed_table (x int primary key); --- table 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 --- index SELECT citus_table_size('non_distributed_table_pkey'); ERROR: cannot calculate the size because table 'non_distributed_table' for index 'non_distributed_table_pkey' is not distributed SELECT citus_relation_size('non_distributed_table_pkey'); @@ -37,10 +35,28 @@ SELECT replicate_table_shards('lineitem_hash_part', shard_replication_factor:=2, (1 row) -CREATE INDEX lineitem_hash_part_idx ON lineitem_hash_part(l_orderkey); -- Tests on distributed table with replication factor > 1 VACUUM (FULL) lineitem_hash_part; --- table +SELECT citus_table_size('lineitem_hash_part'); + citus_table_size +--------------------------------------------------------------------- + 3801088 +(1 row) + +SELECT citus_relation_size('lineitem_hash_part'); + citus_relation_size +--------------------------------------------------------------------- + 3801088 +(1 row) + +SELECT citus_total_relation_size('lineitem_hash_part'); + citus_total_relation_size +--------------------------------------------------------------------- + 3801088 +(1 row) + +CREATE INDEX lineitem_hash_part_idx ON lineitem_hash_part(l_orderkey); +VACUUM (FULL) lineitem_hash_part; SELECT citus_table_size('lineitem_hash_part'); citus_table_size --------------------------------------------------------------------- @@ -59,7 +75,6 @@ SELECT citus_total_relation_size('lineitem_hash_part'); 4259840 (1 row) --- index SELECT citus_table_size('lineitem_hash_part_idx'); citus_table_size --------------------------------------------------------------------- @@ -79,10 +94,38 @@ SELECT citus_total_relation_size('lineitem_hash_part_idx'); (1 row) DROP INDEX lineitem_hash_part_idx; -CREATE INDEX customer_copy_hash_idx on customer_copy_hash(c_custkey); VACUUM (FULL) customer_copy_hash; -- Tests on distributed tables with streaming replication. --- table +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) + +-- Make sure we can get multiple sizes in a single query +SELECT citus_table_size('customer_copy_hash'), + citus_table_size('customer_copy_hash'), + citus_table_size('supplier'); + citus_table_size | citus_table_size | citus_table_size +--------------------------------------------------------------------- + 548864 | 548864 | 655360 +(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 --------------------------------------------------------------------- @@ -101,37 +144,26 @@ SELECT citus_total_relation_size('customer_copy_hash'); 2646016 (1 row) --- index -SELECT citus_table_size('customer_copy_hash_idx'); +SELECT citus_table_size('index_1'); citus_table_size --------------------------------------------------------------------- 1048576 (1 row) -SELECT citus_relation_size('customer_copy_hash_idx'); +SELECT citus_relation_size('index_1'); citus_relation_size --------------------------------------------------------------------- 1048576 (1 row) -SELECT citus_total_relation_size('customer_copy_hash_idx'); +SELECT citus_total_relation_size('index_1'); citus_total_relation_size --------------------------------------------------------------------- 1048576 (1 row) -VACUUM (FULL) supplier; --- Make sure we can get multiple sizes in a single query -SELECT citus_table_size('customer_copy_hash'), - citus_table_size('customer_copy_hash'), - citus_table_size('supplier'); - citus_table_size | citus_table_size | citus_table_size ---------------------------------------------------------------------- - 548864 | 548864 | 565248 -(1 row) - -- Tests on reference table --- table +VACUUM (FULL) supplier; SELECT citus_table_size('supplier'); citus_table_size --------------------------------------------------------------------- @@ -150,8 +182,8 @@ SELECT citus_total_relation_size('supplier'); 565248 (1 row) -CREATE INDEX supplier_idx on supplier(s_suppkey); --- table +CREATE INDEX index_2 on supplier(s_suppkey); +VACUUM (FULL) supplier; SELECT citus_table_size('supplier'); citus_table_size --------------------------------------------------------------------- @@ -170,20 +202,19 @@ SELECT citus_total_relation_size('supplier'); 688128 (1 row) --- index -SELECT citus_table_size('supplier_idx'); +SELECT citus_table_size('index_2'); citus_table_size --------------------------------------------------------------------- 122880 (1 row) -SELECT citus_relation_size('supplier_idx'); +SELECT citus_relation_size('index_2'); citus_relation_size --------------------------------------------------------------------- 122880 (1 row) -SELECT citus_total_relation_size('supplier_idx'); +SELECT citus_total_relation_size('index_2'); citus_total_relation_size --------------------------------------------------------------------- 122880 @@ -286,5 +317,5 @@ SELECT pg_reload_conf(); t (1 row) -DROP INDEX customer_copy_hash_idx; -DROP INDEX supplier_idx; +DROP INDEX index_1; +DROP INDEX index_2; diff --git a/src/test/regress/sql/multi_size_queries.sql b/src/test/regress/sql/multi_size_queries.sql index 0ed136d23..e776f9936 100644 --- a/src/test/regress/sql/multi_size_queries.sql +++ b/src/test/regress/sql/multi_size_queries.sql @@ -14,11 +14,11 @@ SELECT citus_total_relation_size(1); -- Tests with non-distributed table CREATE TABLE non_distributed_table (x int primary key); --- table + SELECT citus_table_size('non_distributed_table'); SELECT citus_relation_size('non_distributed_table'); SELECT citus_total_relation_size('non_distributed_table'); --- index + SELECT citus_table_size('non_distributed_table_pkey'); SELECT citus_relation_size('non_distributed_table_pkey'); SELECT citus_total_relation_size('non_distributed_table_pkey'); @@ -28,57 +28,67 @@ DROP TABLE non_distributed_table; SET client_min_messages TO ERROR; SELECT replicate_table_shards('lineitem_hash_part', shard_replication_factor:=2, shard_transfer_mode:='block_writes'); -CREATE INDEX lineitem_hash_part_idx ON lineitem_hash_part(l_orderkey); -- Tests on distributed table with replication factor > 1 VACUUM (FULL) lineitem_hash_part; --- table SELECT citus_table_size('lineitem_hash_part'); SELECT citus_relation_size('lineitem_hash_part'); SELECT citus_total_relation_size('lineitem_hash_part'); --- index + +CREATE INDEX lineitem_hash_part_idx ON lineitem_hash_part(l_orderkey); +VACUUM (FULL) lineitem_hash_part; + +SELECT citus_table_size('lineitem_hash_part'); +SELECT citus_relation_size('lineitem_hash_part'); +SELECT citus_total_relation_size('lineitem_hash_part'); + SELECT citus_table_size('lineitem_hash_part_idx'); SELECT citus_relation_size('lineitem_hash_part_idx'); SELECT citus_total_relation_size('lineitem_hash_part_idx'); DROP INDEX lineitem_hash_part_idx; -CREATE INDEX customer_copy_hash_idx on customer_copy_hash(c_custkey); VACUUM (FULL) customer_copy_hash; -- Tests on distributed tables with streaming replication. --- table SELECT citus_table_size('customer_copy_hash'); SELECT citus_relation_size('customer_copy_hash'); SELECT citus_total_relation_size('customer_copy_hash'); --- index -SELECT citus_table_size('customer_copy_hash_idx'); -SELECT citus_relation_size('customer_copy_hash_idx'); -SELECT citus_total_relation_size('customer_copy_hash_idx'); - -VACUUM (FULL) supplier; -- Make sure we can get multiple sizes in a single query SELECT citus_table_size('customer_copy_hash'), citus_table_size('customer_copy_hash'), citus_table_size('supplier'); +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'); +SELECT citus_relation_size('customer_copy_hash'); +SELECT citus_total_relation_size('customer_copy_hash'); + +SELECT citus_table_size('index_1'); +SELECT citus_relation_size('index_1'); +SELECT citus_total_relation_size('index_1'); + -- Tests on reference table --- table +VACUUM (FULL) supplier; + SELECT citus_table_size('supplier'); SELECT citus_relation_size('supplier'); SELECT citus_total_relation_size('supplier'); -CREATE INDEX supplier_idx on supplier(s_suppkey); +CREATE INDEX index_2 on supplier(s_suppkey); +VACUUM (FULL) supplier; --- table SELECT citus_table_size('supplier'); SELECT citus_relation_size('supplier'); SELECT citus_total_relation_size('supplier'); --- index -SELECT citus_table_size('supplier_idx'); -SELECT citus_relation_size('supplier_idx'); -SELECT citus_total_relation_size('supplier_idx'); + +SELECT citus_table_size('index_2'); +SELECT citus_relation_size('index_2'); +SELECT citus_total_relation_size('index_2'); -- Test on partitioned table CREATE TABLE split_me (dist_col int, partition_col timestamp) PARTITION BY RANGE (partition_col); @@ -128,5 +138,5 @@ SELECT citus_total_relation_size('customer_copy_hash'); ALTER SYSTEM RESET citus.node_conninfo; SELECT pg_reload_conf(); -DROP INDEX customer_copy_hash_idx; -DROP INDEX supplier_idx; +DROP INDEX index_1; +DROP INDEX index_2;