Loading...
Loading...
VeloDB/Apache Doris table design and cluster sizing best practices. MUST USE when writing, reviewing, or optimizing Doris CREATE TABLE statements, partition/bucket strategies, data models, or cluster configurations. ALSO MUST USE whenever the velodb-architecture-advisor skill produces DDL — apply the Pre-Flight Checklist to every CREATE TABLE before output. Also triggers on any workload design involving: IoT, analytics, dashboard, CDC, time-series, log analysis, real-time warehouse, point query, data platform, or any scenario where table design decisions are being made. Also triggers on replacing or migrating from legacy analytics/search/serving stacks such as Impala, Kudu, Elasticsearch/ES, Greenplum, Presto, HBase, Hive, Hadoop, Redis, or Lambda-style multi-engine data platforms, even when VeloDB/Doris is not named explicitly. Also use when user provides a VeloDB connection string or asks to get started. Also triggers on slow query investigation, query profiling, runtime performance diagnosis, tablet skew analysis, and table health checks — any scenario where runtime evidence (profile output, tablet distribution) informs optimization. For Cloud operations (auth, cluster lifecycle, billing, networking), defer to the velocli-cloud skill.
npx skill4agent add velodb/agent-skills velodb-best-practicesProblem-first table design intelligence for Apache Doris. 37 rules, 7 use case templates, 4 sizing guides. All details indirectory and compiledreferences/.AGENTS.md
| Problem | Template(s) | Key Rules |
|---|---|---|
| Real-time log/event analytics | | DUPLICATE, RANGE partition, dynamic TTL, ZSTD |
| CDC / MySQL sync to Doris | | UNIQUE MoW, sequence_col, HASH bucket |
| Dashboard with pre-aggregated metrics | | AGGREGATE, BITMAP_UNION, sync MV |
| User-facing API with low-latency point queries | | UNIQUE MoW, store_row_column, BloomFilter |
| Star schema with JOIN-heavy analytics | | Colocation, same bucket key/count |
| Small dimension / lookup table | | DUPLICATE, RANDOM bucket, 3 buckets |
| Observability (logs + traces + metrics) | | 3 tables: DUP logs, DUP traces, AGG metrics |
| Vehicle/fleet tracking | | Time-series + point-query hybrid |
| E-commerce order analytics | | Star schema + AGG rollups |
| Full-text search / content search | | Inverted index, MATCH, BM25 |
| User behavior / funnel analysis | | BITMAP_UNION, bitmap_intersect |
| Semi-structured JSON data | | VARIANT type, schema_template |
references/cli-investigation.mdprofile getprofile listprofile historytabletEXPLAINauth status| Symptom | Check These Rules | Quick Fix |
|---|---|---|
| Full table scan on WHERE clause | | Move filtered column to sort key position 1 |
| JOINs are slow / shuffle | | Small dims (<1GB): broadcast + runtime filter. Large: colocation |
| COUNT DISTINCT is slow | | Switch to BITMAP_UNION aggregation |
| LIKE '%keyword%' is slow | | Add NGram BloomFilter index |
| Point query latency too high | | Enable store_row_column + Prepared Statement |
| Storage growing too fast | | AUTO PARTITION + ZSTD compression + scheduled DROP PARTITION |
| Sync MV not being used | | Use raw columns (not date_trunc) in MV GROUP BY; unique aliases |
| Async MV rewrite fails | | Check State/RefreshState; query MV directly if predicate fails |
| Data skew / hot tablets | | Composite bucket key or RANDOM |
| Import fails / data version error | | Check concurrent MV refresh limit (max 3) |
| VARCHAR in key kills perf | | Move VARCHAR after fixed-length types |
| Writes slow on UNIQUE table | | Ensure MoW is enabled (not MoR) |
schema-model-choose-for-workloadschema-partition-*daily_GB / target_tablet_GBschema-bucket-*schema-keys-*schema-types-*schema-index-*schema-props-*UNIQUE KEY(id, dt) PARTITION BY RANGE(dt)UNIQUE KEY(account_id, symbol)account_id, symbol, ...store_row_column = "true"date_trunc()AUTO PARTITION BY RANGE(date_trunc(col, 'day')) ()()PARTITION BY RANGE(col) ()dynamic_partition.bucketsDISTRIBUTED BY HASH(col) BUCKETS Ncompaction_policy = "time_series"REFRESH AUTO ON SCHEDULE EVERY 10 MINUTEREFRESH COMPLETE ON SCHEDULE EVERY 10 MINUTEREFRESH SCHEDULE EVERYREFRESH ASYNC EVERY(INTERVAL ...)NOW()CURDATE()PROPERTIES ("enable_nondeterministic_function" = "true")DEFAULT "true"DEFAULT TRUEPROPERTIES ("bloom_filter_columns" = "col1,col2")INDEX ... USING BLOOM FILTERcol BIGINT SUM DEFAULT "0"col BIGINT DEFAULT "0" SUMDEFAULT "null"vip_level INT REPLACE_IF_NOT_NULLDEFAULT "null"enable_unique_key_partial_updateschema-ddl-gotchasCREATE TABLE events (
entity_id VARCHAR(64) NOT NULL,
event_time DATETIME NOT NULL,
event_type VARCHAR(50) NOT NULL,
payload VARIANT
) DUPLICATE KEY(entity_id, event_time, event_type)
PARTITION BY RANGE(event_time) ()
DISTRIBUTED BY HASH(entity_id) BUCKETS 10
PROPERTIES (
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.start" = "-90",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"compression" = "zstd",
"compaction_policy" = "time_series",
"replication_num" = "1"
);CREATE TABLE orders (
order_id BIGINT NOT NULL,
order_time DATETIME NOT NULL,
update_time DATETIME NOT NULL,
status VARCHAR(20),
amount DECIMAL(18,2)
) UNIQUE KEY(order_id, order_time)
PARTITION BY RANGE(order_time) ()
DISTRIBUTED BY HASH(order_id) BUCKETS 5
PROPERTIES (
"enable_unique_key_merge_on_write" = "true",
"function_column.sequence_col" = "update_time",
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "DAY",
"dynamic_partition.start" = "-365",
"dynamic_partition.end" = "3",
"dynamic_partition.prefix" = "p",
"replication_num" = "1"
);CREATE TABLE dim_product (
product_id INT NOT NULL,
name VARCHAR(200),
category VARCHAR(50)
) UNIQUE KEY(product_id)
DISTRIBUTED BY HASH(product_id) BUCKETS 3
PROPERTIES (
"enable_unique_key_merge_on_write" = "true",
"replication_num" = "1"
);CREATE TABLE daily_kpi (
stat_date DATE NOT NULL,
dimension VARCHAR(50) NOT NULL,
metric_sum BIGINT SUM DEFAULT "0",
metric_max DOUBLE MAX DEFAULT "0",
unique_users BITMAP BITMAP_UNION
) AGGREGATE KEY(stat_date, dimension)
PARTITION BY RANGE(stat_date) ()
DISTRIBUTED BY HASH(dimension) BUCKETS 3
PROPERTIES (
"dynamic_partition.enable" = "true",
"dynamic_partition.time_unit" = "MONTH",
"dynamic_partition.start" = "-12",
"dynamic_partition.end" = "1",
"dynamic_partition.prefix" = "p",
"replication_num" = "1"
);CREATE TABLE user_profiles (
user_id BIGINT NOT NULL,
update_time DATETIME NOT NULL,
name VARCHAR(100),
data VARIANT
) UNIQUE KEY(user_id)
DISTRIBUTED BY HASH(user_id) BUCKETS 5
PROPERTIES (
"enable_unique_key_merge_on_write" = "true",
"function_column.sequence_col" = "update_time",
"store_row_column" = "true",
"light_schema_change" = "true",
"replication_num" = "1"
);VELOCLI_PATHcommand -v veloclicommand -v sdbclimysqlreferences/start-*.md| Task | VeloCLI Command |
|---|---|
| Run SQL | |
| DDL inspection | |
| Table/tablet health | |
| Profile a slow query | |
| Get query profile | |
| Compare fast vs slow | |
| Performance trend | |
| Test connection | |
| Switch environment | |
references/cli-investigation.mdprofile get <query_id>profile listprofile historyauth statusprofile list --activeprofile list--profilevelocli sql "EXPLAIN <query>" --format json--format jsonreferences/start-cloud.mdreferences/start-self-hosted.mdreferences/sizing-fe.mdreferences/sizing-be-integrated.mdreferences/sizing-be-cloud.mdreferences/sizing-storage-formula.mdschema-model-choose-for-workloadschema-model-prefer-mowschema-model-avoid-agg-for-updatesschema-model-sequence-col-for-cdcschema-partition-range-for-timeseriesschema-partition-dynamic-ttlschema-partition-auto-on-demandschema-partition-skip-for-smallschema-bucket-hash-vs-randomschema-bucket-high-cardinality-keyschema-bucket-composite-for-skewschema-bucket-target-sizeschema-bucket-cloud-mandatory-hashschema-keys-selectivity-firstschema-keys-fixed-length-typesschema-keys-prefix-index-limitsschema-keys-cluster-key-for-mowschema-keys-avoid-floatschema-types-native-vs-stringschema-types-zonemap-limitationsschema-types-variant-jsonschema-types-bitmap-count-distinctschema-types-doris-specificsschema-index-bloomfilterschema-index-invertedschema-index-ngram-for-likeschema-index-bitmapschema-index-vectorschema-index-text-searchschema-mv-sync-rollupschema-mv-async-joinschema-mv-async-limitsschema-props-cloud-forcedschema-props-compressionschema-cache-file-cacheschema-cache-query-partition