问题描述
CREATE TABLE table1 (col1 text,col2 text);
我可以通过运行以下命令告诉table1如何对数据进行分区,该数据随后将被加载到表中:
SELECT create_distributed_table('table1','col1');
此刻,我将知道我的表如何分布在CitusDB节点上。
但是,如果遇到一个我没有创建的新表,但是我知道它是分布式的,那么我怎么知道该表分布在哪一列呢?
解决方法
您要使用citus db文档中描述的citusDB column_to_column函数:http://docs.citusdata.com/en/v9.3/develop/api_udf.html
SELECT column_to_column_name(logicalrelid,partkey) AS dist_col_name
FROM pg_dist_partition
WHERE logicalrelid='<table>'::regclass;