cluster-operations
Installation
SKILL.md
Cluster Operations
Distributed Tables
CREATE TABLE dist ENGINE = Distributed(cluster, db, local_table, sharding_key)- Sharding key:
rand()for even distribution,cityHash64(user_id)for user affinity - Reads: query all shards in parallel; Writes: route to correct shard or write locally
ON CLUSTER DDL
ALTER TABLE t ON CLUSTER '{cluster}' ADD COLUMN col Type— propagate schema to all replicasCREATE TABLE t ON CLUSTER '{cluster}' AS template_db.template_table— clone across shardsdistributed_ddl_output_mode:throw(fail on error),null(ignore),none,active- Check status:
SELECT * FROM system.distributed_ddl_queue
Load Balancing and Read Routing
load_balancing:random,in_order,first_or_random,nearest_hostnamemax_replica_delay_for_distributed_queries— skip lagging replicasfallback_to_stale_replicas_for_distributed_queries=1— use stale when all delayed