From starrocks
StarRocks analytical data warehouse skill. Use when writing or reviewing StarRocks SQL, designing tables, choosing partition/bucket strategies, loading or unloading data, creating materialized views, tuning queries, or working with external catalogs (Hive, Iceberg, Hudi, Delta Lake). Covers DBA and data architect concerns — not cluster deployment or platform engineering. Trigger on mentions of 'starrocks', 'StarRocks', table types (Duplicate Key, Primary Key, Aggregate, Unique Key), Routine Load, Stream Load, or StarRocks-specific SQL.
How this skill is triggered — by the user, by Claude, or both
Slash command
/starrocks:sqlThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
StarRocks is an MPP analytical database with columnar storage, a fully vectorized
StarRocks is an MPP analytical database with columnar storage, a fully vectorized execution engine, a cost-based optimizer (CBO), and MySQL protocol compatibility. It supports real-time ingestion, sub-second queries, and zero-migration data lake analytics via external catalogs.
Before writing DDL or loading data, read the relevant reference files:
references/table-design.rst — Table types, partitioning, bucketing, indexing quick-refreferences/data-loading.rst — Loading methods comparison and patternsreferences/query-acceleration.rst — Materialized views, CBO, join strategies, caching| Type | Use When | Key Behaviour |
|---|---|---|
| Duplicate Key | Raw logs, append-only data | Rows stored as-is; sort key for scan efficiency |
| Aggregate | Pre-aggregated metrics | Rows with same key auto-aggregate (SUM, MAX, MIN, etc.) |
| Unique Key | Dimension tables, dedup | Latest row per key wins (merge-on-read) |
| Primary Key | Real-time upserts, CDC | Latest row per key wins (delete+insert, better read perf) |
Default choice: Primary Key for mutable data, Duplicate Key for append-only.
Partition by time or a low-cardinality dimension that aligns with query predicates. Use expression-based partitioning for automatic partition creation:
CREATE TABLE events (
event_time DATETIME NOT NULL,
user_id BIGINT,
event_type VARCHAR(64),
payload JSON
)
PRIMARY KEY (event_time, user_id)
PARTITION BY date_trunc('day', event_time)
DISTRIBUTED BY HASH(user_id) BUCKETS 16
PROPERTIES ("replication_num" = "3");
user_id)The sort key is the highest-leverage physical design knob. Place the most frequently filtered columns first. For Primary Key tables, the primary key IS the sort key.
| Index Type | Best For |
|---|---|
| Prefix index | Range scans on leading sort key columns (automatic) |
| Bitmap index | Low-cardinality columns in WHERE clauses |
| Bloom filter | High-cardinality equality lookups |
| Ngram bloom filter | LIKE '%substring%' queries on text columns |
| Method | Source | Best For |
|---|---|---|
| Stream Load | HTTP push | Small batches, real-time micro-batch |
| Broker Load | S3, HDFS, GCS | Large-scale batch import from object storage |
| INSERT INTO | SQL | Small inserts, ETL within StarRocks |
| Routine Load | Kafka | Continuous streaming ingestion |
| Spark connector | Spark | ETL pipelines via Spark jobs |
| Flink connector | Flink | Streaming ETL via Flink |
| Pipe | S3 (continuous) | Auto-discovery of new files in a bucket |
| INSERT INTO FILES | StarRocks → S3/HDFS | Data export to remote storage |
information_schema.routine_load_jobsSee references/data-loading.rst for detailed patterns per method.
Prefer INSERT INTO FILES for bulk export with format control:
INSERT INTO FILES (
"path" = "s3://bucket/export/",
"format" = "parquet",
"aws.s3.access_key" = "...",
"aws.s3.secret_key" = "..."
)
SELECT * FROM my_table WHERE dt = '2024-01-01';
Collect statistics so the CBO can choose optimal plans:
-- Full collection (run periodically or after large loads)
ANALYZE TABLE my_table;
-- Sample-based for large tables
ANALYZE SAMPLE TABLE my_table;
-- Check stats freshness
SHOW COLUMN STATS my_table;
Synchronous MVs — single-table, auto-refreshed on load, transparent rewrite:
CREATE MATERIALIZED VIEW mv_daily_sales AS
SELECT date_trunc('day', order_time) AS dt, SUM(amount) AS total
FROM orders
GROUP BY date_trunc('day', order_time);
Asynchronous MVs — multi-table, scheduled refresh, query rewrite:
CREATE MATERIALIZED VIEW mv_user_orders
REFRESH ASYNC EVERY (INTERVAL 1 HOUR)
AS
SELECT u.name, COUNT(*) AS order_count, SUM(o.amount) AS total
FROM users u JOIN orders o ON u.id = o.user_id
GROUP BY u.name;
"colocate_with" property.unnest() for array/JSON expansionSee references/query-acceleration.rst for the full acceleration toolkit.
default_catalog) — StarRocks-managed tables-- Create a Hive external catalog
CREATE EXTERNAL CATALOG hive_catalog
PROPERTIES (
"type" = "hive",
"hive.metastore.uris" = "thrift://metastore:9083"
);
-- Query across catalogs
SELECT s.user_id, h.page_views
FROM default_catalog.analytics.sessions s
JOIN hive_catalog.web.pageviews h ON s.user_id = h.user_id;
Use information_schema views for metadata queries:
tables / columns — table and column metadatamaterialized_views — MV definitions and refresh statusloads / load_tracking_logs — load job status and errorsroutine_load_jobs — Kafka ingestion job monitoringbe_tablets — tablet distribution across BE nodespartitions_meta — partition detailsIsolate workloads for multi-tenant environments:
-- Create a resource group for ETL workloads
CREATE RESOURCE GROUP etl_group
TO (user = 'etl_user')
WITH (cpu_weight = 4, mem_limit = '40%', concurrency_limit = 20);
-- Create a resource group for dashboard queries
CREATE RESOURCE GROUP dashboard_group
TO (user = 'dashboard_user')
WITH (cpu_weight = 8, mem_limit = '30%', concurrency_limit = 50);
loads, routine_load_jobs, be_tabletsreferences/table-design.rst — Table types, partitioning, bucketing, indexing quick-refreferences/data-loading.rst — Loading methods comparison and patternsreferences/query-acceleration.rst — Materialized views, CBO, join strategies, cachingGuides reception of code review feedback: verify before implementing, avoid performative agreement, push back with technical reasoning when needed.
Design banners for social media, ads, website heroes, and print with multiple art direction options and AI-generated visuals.
npx claudepluginhub nq-rdl/agent-extensions --plugin starrocks