《童虎学习笔记》5分钟Citus之SQL命令参考

本文提供了一篇关于Citus的实战学习笔记,详细介绍了如何使用SQL命令进行分布表转换、设置表间亲和性、在worker节点上执行命令、添加和管理worker节点以及查看Citus表的大小和连接数等操作。内容包括从分布表转为普通表的过程,以及在不同worker节点上查看表情况和调整shard分布的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本专栏全部文章 ​​​​​​​https://blog.youkuaiyun.com/tonghu_note/category_11713514.html
总目录 https://blog.youkuaiyun.com/tonghu_note/article/details/124333034

来我的dou音 aa10246666, 看配套视频


一、实战环境

节点 cn_node1(协调节点,不存储数据) postgresql 14.2 10.211.55.9
节点 worker1_node2(工作节点,存储数据) postgresql 14.2 10.211.55.4
节点 worker2_node3(工作节点,存储数据) postgresql 14.2 10.211.55.6
citus-10.2 / debian 9

二、SQL命令参考

1、分布表转为普通表

在cn节点,查看系统中现有的Citus表

d1=# select * from citus_tables;
 table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method 
------------+------------------+---------------------+---------------+------------+-------------+-------------+---------------
 t1         | distributed      | id                  |             2 | 8512 kB    |          32 | postgres    | heap
 t11        | distributed      | id                  |             2 | 8512 kB    |          32 | postgres    | heap
 t2         | reference        | <none>              |             1 | 13 MB      |           1 | postgres    | heap
 t22        | reference        | <none>              |             1 | 13 MB      |           1 | postgres    | heap
(4 rows)
 

在cn节点,我们将以上的分布表t1在线改为普通表

d1=# SELECT undistribute_table('t1');
NOTICE:  creating a new table for public.t1
NOTICE:  moving the data of public.t1
NOTICE:  dropping the old public.t1
NOTICE:  renaming the new table to public.t1
 undistribute_table 
--------------------
 
(1 row)

在cn节点,再查看系统中现有的Citus表,可以看到表t1已经转为了普通表

d1=# select * from citus_tables;
 table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method 
------------+------------------+---------------------+---------------+------------+-------------+-------------+---------------
 t11        

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值