Compute Resource DDL
Compute cluster (VCluster) DDL commands are used to create, configure, start/stop, and drop compute clusters. All SQL that requires computation (SELECT, DML) runs on a compute cluster.
In This Chapter
Common Operations
Create a Cluster
-- General-purpose (GP): suited for ETL batch processing
CREATE VCLUSTER IF NOT EXISTS my_etl_cluster
VCLUSTER_TYPE = GENERAL
VCLUSTER_SIZE = 2
AUTO_SUSPEND_IN_SECOND = 60
AUTO_RESUME = TRUE;
-- General-purpose (GP) with auto-scaling enabled
CREATE VCLUSTER IF NOT EXISTS my_etl_cluster
VCLUSTER_TYPE = GENERAL
MIN_VCLUSTER_SIZE = 1
MAX_VCLUSTER_SIZE = 8
AUTO_SUSPEND_IN_SECOND = 60
AUTO_RESUME = TRUE;
-- Analytics (AP): suited for BI queries and high-concurrency online queries
CREATE VCLUSTER IF NOT EXISTS my_bi_cluster
VCLUSTER_TYPE = ANALYTICS
VCLUSTER_SIZE = 2
MIN_REPLICAS = 1
MAX_REPLICAS = 4
MAX_CONCURRENCY = 8
AUTO_SUSPEND_IN_SECOND = 120
AUTO_RESUME = TRUE;
Start and Stop
-- Start a cluster
ALTER VCLUSTER IF EXISTS my_cluster RESUME;
-- Stop a cluster (waits for current jobs to complete)
ALTER VCLUSTER IF EXISTS my_cluster SUSPEND;
-- Force stop (immediately terminates all running jobs)
ALTER VCLUSTER IF EXISTS my_cluster SUSPEND FORCE;
Modify Cluster Configuration
-- General-purpose: adjust auto-scaling range
ALTER VCLUSTER my_etl_cluster SET MIN_VCLUSTER_SIZE = 1 MAX_VCLUSTER_SIZE = 4;
-- Analytics: adjust replica count range
ALTER VCLUSTER my_bi_cluster SET MIN_REPLICAS = 1 MAX_REPLICAS = 4;
-- Analytics: adjust max concurrency per replica
ALTER VCLUSTER my_bi_cluster SET MAX_CONCURRENCY = 16;
-- Set auto-suspend time (seconds)
ALTER VCLUSTER my_cluster SET AUTO_SUSPEND_IN_SECOND = 300;
-- Set job timeout (seconds)
ALTER VCLUSTER my_cluster SET QUERY_RUNTIME_LIMIT_IN_SECOND = 600;
View Clusters
-- List all clusters
SHOW VCLUSTERS;
-- List only running clusters
SHOW VCLUSTERS WHERE state = 'RUNNING';
-- View detailed cluster configuration
DESC VCLUSTER my_cluster;
View Jobs
-- View failed jobs
SHOW JOBS WHERE status = 'FAILED' LIMIT 20;
Switch Cluster
-- Switch the current session to a specific cluster
USE VCLUSTER my_cluster;
Drop a Cluster
DROP VCLUSTER IF EXISTS my_cluster;
-- Force drop (does not wait for running jobs to complete)
DROP VCLUSTER IF EXISTS my_cluster FORCE;