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 doris-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 Apache Doris is not named explicitly. Also use when user provides an Apache Doris connection string or asks to get started. Also triggers on slow query investigation, query profiling, runtime performance diagnosis, tablet skew an
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
La commande reste sur une seule ligne. Faites défiler horizontalement pour la vérifier avant de la copier.
Vous préférez une copie locale ? Téléchargez les fichiers actuellement disponibles dans SkillsMP.
Explorateur de fichiers
51 fichiers
Affichage de SKILL.md
SKILL.md
Instructions source · Aperçu en lecture seule
name
doris-best-practices
description
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 doris-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 Apache Doris is not named explicitly. Also use when user provides an Apache Doris 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. Cluster lifecycle, billing, and networking are managed-service operations, out of scope here — use your platform's cluster-management console for those.
license
Apache-2.0
metadata
{"author":"tomz-alt","version":"0.1.0"}
Apache Doris Best Practices
Problem-first table design intelligence for Apache Doris.
37 rules, 7 use case templates, 4 sizing guides.
All details in references/ directory.
For live slow-query or runtime diagnosis, do not use this table as the first response. First read references/cli-investigation.md and collect or attempt evidence (profile get, profile list, profile history, tablet, EXPLAIN, or auth status). Use this table only after evidence points to the symptom.
Symptom
Check These Rules
Quick Fix
Full table scan on WHERE clause
schema-keys-selectivity-first
Move filtered column to sort key position 1
JOINs are slow / shuffle
usecase-star-schema-join
Small dims (<1GB): broadcast + runtime filter. Large: colocation
AUTO PARTITION + ZSTD compression + scheduled DROP PARTITION
Sync MV not being used
schema-mv-sync-rollup
Use raw columns (not date_trunc) in MV GROUP BY; unique aliases
Async MV rewrite fails
schema-mv-async-join + schema-mv-async-limits
Check State/RefreshState; query MV directly if predicate fails
Data skew / hot tablets
schema-bucket-composite-for-skew
Composite bucket key or RANDOM
Import fails / data version error
schema-mv-async-limits
Check concurrent MV refresh limit (max 3)
VARCHAR in key kills perf
schema-keys-fixed-length-types
Move VARCHAR after fixed-length types
Writes slow on UNIQUE table
schema-model-prefer-mow
Ensure MoW is enabled (not MoR)
2 ▸ Pre-Flight Checklist (Before Any CREATE TABLE)
Run through this checklist in order. Each step references the relevant rule:
Data model — UNIQUE (updates?) vs DUPLICATE (append?) vs AGGREGATE (pre-agg only?) → schema-model-choose-for-workload
Partition strategy — Time-series? AUTO PARTITION preferred. Small table? Skip. Do NOT combine AUTO with dynamic_partition. → schema-partition-*
Bucket key + count — HASH on JOIN key. Calculate explicit count: daily_GB / target_tablet_GB. Use explicit fallback counts when volume is unknown: 3 for small dimensions, 8 for medium tables, 16-32 for large daily fact tables. → schema-bucket-*
Sort key order — High-selectivity first, fixed-length before VARCHAR → schema-keys-*
Data types — Native types, not STRING. DECIMAL not FLOAT. → schema-types-*
Indexes — BloomFilter for equality, Inverted for text, NGram for LIKE → schema-index-*
DDL hard constraints (Apache Doris rejects DDL if any violated):
UNIQUE KEY + PARTITION BY RANGE → partition column MUST be in the UNIQUE KEY: UNIQUE KEY(id, dt) PARTITION BY RANGE(dt)
Key columns must be the FIRST N columns in schema, same order — put key cols first, non-key after. Example: UNIQUE KEY(account_id, symbol) means schema must start with account_id, symbol, ... — never place non-key columns between key columns
store_row_column = "true" works on UNIQUE MoW and DUPLICATE — NOT on AGGREGATE (Doris rejects AGG: "Aggregate table can't support row column"). Verified on 4.x; older versions were UNIQUE-only
AUTO PARTITION requires date_trunc() AND empty parens: AUTO PARTITION BY RANGE(date_trunc(col, 'day')) () — bare column name fails, missing () fails
Dynamic partition requires explicit PARTITION BY RANGE(col) () clause in DDL — properties alone are not enough
2b ▸ DDL Templates (copy the closest match, customize columns)
For each CREATE TABLE, select the closest template below. Customize column names, types, bucket count, and partition settings. Do NOT write DDL from scratch.
Apache Doris speaks the MySQL protocol, so the always-available path is any MySQL-compatible client (mysql) plus SQL and the FE HTTP REST API. Some distributions also ship an optional management CLI (referred to here as doriscli) that adds ergonomic profiling and diagnostics commands — use it when your distribution provides one, otherwise use the native path.
Detect the optional CLI
Before running any queries, detect whether the CLI binary is available:
Check DORIS_CLI_PATH env var — if set, use that binary path
command -v doriscli — use from PATH
If none available: fall back to mysql client (see references/start-*.md)
When doriscli is available, prefer it for all operations:
Task
doriscli Command
Run SQL
doriscli sql "SELECT ..."
DDL inspection
doriscli sql "SHOW CREATE TABLE db.t"
Table/tablet health
doriscli tablet db.t (overview) or doriscli tablet db.t --detail
doriscli profile get <qid> or --full for complete diagnosis
Compare fast vs slow
doriscli profile diff <slow_qid> <fast_qid>
Performance trend
doriscli profile history <sql_pattern> --days 7
Test connection
doriscli auth status
Switch environment
doriscli use <name>
Runtime Query Investigation
For slow queries or runtime performance issues, read references/cli-investigation.md.
Evidence first is mandatory: collect or attempt profile, tablet, DDL, stats, EXPLAIN, history, active-query, or connection evidence before forming hypotheses. If evidence cannot be collected locally, state that and provide the exact commands to run
Prefer existing profiles: use profile get <query_id>, profile list, or profile history before re-executing SQL
Proactive discovery: for vague slow-query reports, start with auth status, profile list --active, and recent profile list before asking the user for more context
Safety gate: before running user SQL with --profile, check whether it is safe (no DDL, no mutation, no unbounded scan). For unknown, peak-hour, or expensive SQL, run doriscli sql "EXPLAIN <query>" --format json first and ask confirmation or request an existing query_id
Hypotheses, not verdicts: diagnostic mappings are heuristics. Present evidence, likely cause, what to check next, and when the conclusion may be wrong
If doriscli is unavailable, fall back to SQL commands listed in the reference
Always use --format json for structured agent-readable output
schema-props-compression — LZ4 vs ZSTD compression
Caching — MEDIUM (2 rules)
schema-cache-file-cache — File cache for cloud mode
schema-cache-query-partition — Query and partition cache
Do not set dynamic_partition.buckets; put the numeric count only in DISTRIBUTED BY HASH(col) BUCKETS N
compaction_policy = "time_series" only for DUPLICATE tables — fails on UNIQUE
Async MV refresh: use REFRESH AUTO ON SCHEDULE EVERY 10 MINUTE or REFRESH COMPLETE ON SCHEDULE EVERY 10 MINUTE — NOT REFRESH SCHEDULE EVERY, NOT REFRESH ASYNC EVERY(INTERVAL ...). Minimum interval: 1 MINUTE
MV using NOW()/CURDATE(): add PROPERTIES ("enable_nondeterministic_function" = "true")
BOOLEAN defaults must be quoted: DEFAULT "true" not DEFAULT TRUE
BloomFilter index: use PROPERTIES ("bloom_filter_columns" = "col1,col2") — NOT inline INDEX ... USING BLOOM FILTER
AGGREGATE column syntax: aggregation function BEFORE default: col BIGINT SUM DEFAULT "0" — NOT col BIGINT DEFAULT "0" SUM
AGGREGATE DEFAULT "null" only works for VARCHAR — fails on INT, DATE, DECIMAL, BIGINT. Omit DEFAULT entirely for REPLACE_IF_NOT_NULL on non-string types: vip_level INT REPLACE_IF_NOT_NULL (not DEFAULT "null")
enable_unique_key_partial_update is a session variable, NOT a table property