doris-debug-materialized-view
Skill50 starsChanged 13 days agoApache-2.0View on GitHub
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.
In this repository16 other files it gives its agents.
- develop-with-evidenceSkill
- doris-architecture-advisorSkill
- doris-best-practicesSkill
- doris-debug-cloudSkill
- doris-debug-compactionSkill
- doris-debug-data-lakeSkill
- doris-debug-deploymentSkill
- doris-debug-importSkill
- doris-debug-nodeSkill
- doris-debug-querySkill
- doris-debug-resource-isolationSkill
- doris-debugSkill
- doris-debug-tabletSkill
- doris-pr-descriptionSkill
- doris-profile-readerSkill
- doris-repo-reviewSkill
The file
Files
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 detailsCause 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 compactionSource
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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

