
Skill
doris-debug-materialized-view
debug Apache Doris materialized view issues
Description
Use for Doris sync MV (rollup) miss or async MTMV refresh/rewrite issues. Commands: SHOW ALTER TABLE MATERIALIZED VIEW, mv_infos(), EXPLAIN, REFRESH MATERIALIZED VIEW.
SKILL.md
Materialized View
Kind comparison
| Kind | Code area | Check | Rewrite mechanism |
|---|---|---|---|
| Sync | MaterializedViewHandler / rollup | SHOW ALTER TABLE MATERIALIZED VIEW | Transparent — planner auto-selects |
| Async MTMV | fe/.../mtmv/ | mv_infos() RefreshState | CBO-based — EXPLAIN shows if matched |
Causes
| ID | Cause | Evidence | Kind |
|---|---|---|---|
| A | Sync MV build pending/stuck | SHOW ALTER TABLE MATERIALIZED VIEW State≠FINISHED | Sync |
| B | MTMV refresh failed | mv_infos() RefreshState=FAIL | Async |
| C | MTMV rewrite miss | EXPLAIN shows no MATERIALIZED_REWRITE | Async |
| D | MTMV data stale | mv_infos() LastRefreshTime old | Async |
| E | MV not selected by planner | EXPLAIN shows TABLE SCAN not MATERIALIZED | Either |
10 min triage
-- Sync MV status
SHOW ALTER TABLE MATERIALIZED VIEW FROM db;
-- Async MTMV status
SELECT * FROM mv_infos('database'='db') WHERE Name='mv'\G
-- Check rewrite eligibility
EXPLAIN VERBOSE SELECT ...;
-- Force refresh
REFRESH MATERIALIZED VIEW mv;
-- Enable external MV rewrite (for catalog queries)
SET materialized_view_rewrite_enable_contain_external_table = true;
Cause C — MTMV rewrite miss
Common reasons (see fe/.../mtmv/MTMVService.java rewrite matcher):
- Partition misalignment: MV has
partition_sync=falseand query partition doesn't match →ALTER MATERIALIZED VIEW mv SET ("partition_sync" = "true") - Aggregation granularity: MV groups by
(a, b)but query groups by(a)only → MV is not a valid rewrite target - Filter mismatch: MV WHERE clause doesn't cover query WHERE clause → check MV definition
- Session var off:
SET enable_materialized_view_rewrite = true
-- Debug: force the optimizer to log MV matching
SET enable_materialized_view_rewrite_debug_log = true;
EXPLAIN VERBOSE SELECT ...; -- check fe/log/fe.audit.log for MV match details
Cause A — Sync MV stuck
-- Cancel stuck build
CANCEL ALTER TABLE MATERIALIZED VIEW FROM db ON table;
-- Check BE compaction queue (MV build competes with compaction)
./scripts/doris-debug be-metrics --be http://$BE:8040 --grep compaction
Source
fe/.../mtmv/MTMVService.java— MTMV lifecyclefe/.../alter/MaterializedViewHandler.java— sync MV alterfe/.../materializedview/MaterializedViewRewriter.java— rewrite logicSessionVariable.java—enable_materialized_view_rewrite,materialized_view_rewrite_enable_contain_external_table
More skills from the doris-skills repository
View all 14 skillsdoris-architecture-advisor
design Apache Doris data architectures
Jul 12ArchitectureData EngineeringData PipelineDatabasedoris-best-practices
optimize Apache Doris table design and clusters
Jul 12DatabaseEngineeringPerformancedoris-debug
diagnose Apache Doris production issues
Jul 25DebuggingMonitoringOperationsdoris-debug-cloud
debug Apache Doris cloud mode issues
Jul 25CloudDebuggingPerformancedoris-debug-compaction
resolve Apache Doris compaction lag
Jul 25DatabaseDebuggingPerformancedoris-debug-data-lake
debug Apache Doris data lake connectivity
Jul 25Data EngineeringDatabaseDebugging
More from Apache Software Foundation
View publisherdatafusion-python
write Apache DataFusion Python code
datafusion-python
Jul 12Data AnalysisPythonSQLbydbql
generate and execute BanyanDB BydbQL queries
skywalking-banyandb
Jul 12AnalyticsDatabaseSQLcompiling
compile and build BanyanDB projects
skywalking-banyandb
Jul 12BuildEngineeringgh-pull-request
create GitHub pull requests for BanyanDB
skywalking-banyandb
Jul 12GitHubPull Requestsvendor-update
update Go and Node.js vendor dependencies
skywalking-banyandb
Jul 12GoNode.jscayenne-cgen
generate Cayenne entity Java classes
cayenne
Jul 12Data ModelingJavaORM