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

PageDescription
CREATE VCLUSTERCreate a general-purpose, analytics, or sync compute cluster
ALTER VCLUSTERStart, stop, or modify cluster properties
DROP VCLUSTERDrop a compute cluster
USE VCLUSTERSwitch the cluster used by the current session
DESC VCLUSTERView detailed cluster configuration and status
SHOW VCLUSTERSList all clusters in the workspace

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;


DocumentDescription
Managing Compute ResourcesCluster type selection guide and common operation walkthrough
Compute Cluster Size Code ChangesMapping between old and new size codes
Compute Cluster CacheHow active and passive caching work
SHOW JOBSFull syntax for viewing and filtering job records