Eliezer Talker
11/06/2026, 8:11 AMRocky
11/06/2026, 8:11 AMINSERT OVERWRITE query, so it consumes BE query-pool memory. The docs' troubleshooting guide lists "refresh task exceeds the memory limit" as a top cause of refresh failure, typically for large aggregations/joins, and lists "unnecessarily frequent refresh interval" plus "MV is unpartitioned (full refresh each time)" as causes of excessive resource consumption. You'd normally see tracked errors like Mem usage has exceed the limit of single query → exec_mem_limit, Mem usage has exceed the limit of query pool, or Mem usage has exceed the limit of BE. Note: a memory-tracked query failure is not the same as the BE process being OOM-killed — untracked/off-heap growth is where a real process kill can still happen.
FE (less direct, but real). FE isn't doing the scan/aggregation, it schedules the task runs and keeps metadata + task-run history in JVM heap. Two knobs matter here:
• partition_refresh_number defaults to 1 since v3.3 "to avoid potential OOM issues" — good for BE, but a frequently-refreshing MV over many partitions then generates a lot of subtask runs, which shows up as many task_runs rows.
• History retention is bounded by task_runs_ttl_second (default 7 days), task_runs_max_history_number (default 10000), enable_task_history_archive (default true — when on, retention moves to the persistent archive instead of those two in-memory limits), and per-run message size by max_mv_task_run_meta_message_values_length (default 100).
Built-in guardrails
1. Only one refresh per MV runs at a time. If the interval fires while a refresh is still running: if there are pending tasks the new trigger is merged (state MERGED); otherwise it waits for the running one to finish. So a 30s interval on a slow MV does not create overlapping refreshes of the same MV — it just queues/merges.
2. System resource group default_mv_wg is auto-assigned to MV refreshes that don't specify `resource_group`: cpu_weight 1, mem_limit 80%, concurrency_limit 0, spill_mem_limit_threshold 80%. Corresponding BE configs: default_mv_resource_group_memory_limit, default_mv_resource_group_cpu_limit, default_mv_resource_group_concurrency_limit, default_mv_resource_group_spill_mem_limit_threshold. Caveat: concurrency_limit default 0 means unlimited — so across many MVs, nothing caps total concurrent refreshes out of the box.
3. Spilling to disk for refresh intermediates, if enabled: PROPERTIES ('session.enable_spill'='true') at create time or ALTER MATERIALIZED VIEW ... SET ('session.enable_spill'='true'). In a resource group, spill kicks in when group usage exceeds mem_limit * spill_mem_limit_threshold or a query exceeds 80% of query_mem_limit.
4. Per-query and process caps: exec_mem_limit, query_mem_limit (per-BE, 0 = unlimited), BE mem_limit (default 90% hard / 80% soft), query_max_memory_limit_percent (90% of process limit for the query pool). Exceeding a group's mem_limit fails the query rather than consuming more.
5. Circuit breakers: ALTER MATERIALIZED VIEW mv1 INACTIVE; and CANCEL REFRESH MATERIALIZED VIEW mv1;.
Recommended setup for frequent refreshes
• Create a dedicated resource group for MV refreshes (docs explicitly recommend this instead of relying on default_mv_wg), e.g. mem_limit 0.9, concurrency_limit 10, spill_mem_limit_threshold 0.5, and assign it via 'resource_group' = 'rg_mv'.Rocky
11/06/2026, 8:11 AMpartition_refresh_number small.
• Enable session.enable_spill.
• Set a sane concurrency_limit so N MVs at 30s intervals can't all run at once.
• Monitor: audit-log query on INSERT OVERWRITE statements by memCostBytes per user identifies the heavy refreshers; get the query_id from information_schema.task_runs and inspect the profile. Check whether tasks queue up (processStartTime far from create time = it was queued) — queueing means your interval is faster than your refresh cost, which is the pattern to fix.
Bottom line: 30s/1min intervals are fine only if refreshes actually finish well within that window and the MV query is cheap/partitioned. Nothing in the docs guarantees protection against BE process-level OOM — the trackers fail queries first, but I'd treat frequent refresh over unpartitioned, join-heavy MVs as a genuine OOM risk. If you hit something version-specific in 4.1.7, the release notes and GitHub issues are the place to confirm, or ask in the StarRocks community Slack.
References
• administration/Meta_recovery.md
• knowledge/trouble_shooting/fe_memory_problems.md
• faq/fe_mem_faq.md
• faq/operation_maintenance_faq.mdEliezer Talker
11/06/2026, 8:15 AMRocky
11/06/2026, 8:16 AMdefault_mv_wg, whose concurrency_limit defaults to 0 = unlimited):
sql
CREATE RESOURCE GROUP rg_mv
TO (user = 'mv_user', query_type IN ('insert', 'select'))
WITH (
'cpu_weight' = '32',
'mem_limit' = '0.9',
'concurrency_limit' = '10',
'spill_mem_limit_threshold' = '0.5'
);
ALTER MATERIALIZED VIEW mv_example SET ('resource_group' = 'rg_mv');
• mem_limit 0.9 caps total group memory per BE; exceeding it fails the query rather than growing.
• spill_mem_limit_threshold 0.5 spills intermediates to disk earlier than the 0.8 default — this is the single most effective lever for join/aggregate-heavy refreshes.
• concurrency_limit is what actually stops "N MVs × 30s intervals" from all running at once. 0 is the default and is not what you want.
• Also set per-MV: 'session.enable_spill'='true'.
2. Fail-fast — make the refresh the thing that dies
Set session.insert_timeout (default 1h from v3.2) and a per-query memory cap so a runaway refresh errors out instead of pressing on. Note the interaction: with concurrency_limit set, a refresh that keeps failing or overrunning will queue (processStartTime far from CREATE_TIME in information_schema.task_runs, state `MERGED`/pending) — that's your signal, not a crash.
3. Observability — the part that replaces "guarantee"
• BE memory alert: starrocks_be_process_mem_bytes / (<mem_limit_gb> * 1024^3) > 0.9 for 30s. Docs' recommendation is threshold at 90% of BE's actual limit, since mem_limit defaults to 90% of server memory.
• FE heap alert: FE JVM heap ≥ 80% → raise `Xmx`; this is the documented FE OOM path.
• Refresh memory: audit-log query on INSERT OVERWRITE by memCostBytes (docs give the exact SQL) tells you what each MV refresh actually costs — that number is your capacity input.
• Queueing: information_schema.task_runs processStartTime vs. finish time.
4. Size the interval, don't guess it
Rule of thumb: interval ≥ 3–5× measured refresh duration, and only after the refresh is partitioned so it touches one partition per run (an unpartitioned MV does a full refresh every tick — that's the pattern the docs call out as an OOM/timeout cause). Keep default_mv_partition_refresh_number small. If tasks queue, the interval is faster than the work — fix the interval, not the memory.
5. FE side specifically
FE doesn't execute the refresh, but it accumulates task-run history: bound it with task_runs_ttl_second, task_runs_max_history_number, and per-run message size max_mv_task_run_meta_message_values_length. Hundreds of MVs at 30s intervals over many partitions generates a lot of rows — worth checking before you scale up the MV count.
Honest caveatRocky
11/06/2026, 8:16 AMmem_limit, exec_mem_limit, spill) act before the process limit and only account for tracked allocations. So: pilot with the real refresh, read its QueryMemCost from the profile, set the resource group from that, alert at 90%, and keep ALTER MATERIALIZED VIEW ... INACTIVE / CANCEL REFRESH MATERIALIZED VIEW as circuit breakers. I can't verify 4.1.7-specific defaults from the docs I have — confirm against the 4.1.7 release notes, and if you see a process kill that the trackers didn't catch, that's a GitHub issue worth filing.
References
• using_starrocks/async_mv/materialized_view_task_run_details.md
• administration/management/FE_configuration.mdEliezer Talker
11/06/2026, 8:20 AMRocky
11/06/2026, 8:20 AMcpu_weight just means it takes longer to get there. What does reduce memory:
• Spilling — 'session.enable_spill'='true' plus spill_mem_limit_threshold (set it lower, e.g. 0.5 instead of 0.8) moves intermediates to disk. This is the actual "slower but cheaper" lever.
• Smaller batches — partition_refresh_number (default 1 since v3.3, specifically "to avoid potential OOM issues") limits how much one refresh sub-task touches.
• Lower pipeline_dop for the refresh session — fewer parallel instances means less per-query peak memory, at the cost of throughput. (This one is my inference from how pipeline execution works, not a doc statement about MVs specifically.)
• Lower cpu_weight on the MV resource group — this protects foreground queries from the refresh, and caps the group's memory via mem_limit, which makes over-limit refreshes fail rather than grow. Protection, not reduction.
"Next refresh only after this one is done + the interval" — not a property I can find
That's fixed-delay semantics, and I don't see it as a documented MV option. Scheduling is REFRESH ASYNC [START(...)] EVERY (interval N ...) — cron-style, wall-clock aligned. But the behavior you're describing emerges anyway from trigger coalescing:
• Only one refresh per MV runs at a time.
• If the interval fires while a refresh is still running or queued, the new trigger is merged into the existing task (state MERGED for MV refresh tasks, since v3.1.12) rather than launching a second one.
So your effective cadence on a 30s interval with a 10-minute refresh is roughly "back-to-back refreshes", i.e. max(interval, duration) — not an unbounded pile of concurrent refreshes. That's the key thing you were worried about, and it's handled.
If you want exact "run → finish → sleep interval" semantics, do it outside the scheduler: REFRESH MANUAL on the MV plus an external loop (Airflow, cron, or SUBMIT TASK) calling REFRESH MATERIALIZED VIEW mv WITH SYNC MODE, which blocks until the refresh completes. Then you control the delay precisely. Downside: you own the orchestration and failure handling.
The tradeoff to watch
Slowing refreshes down buys memory headroom at the cost of freshness. If refresh lag grows, query_rewrite_consistency = 'checked' (the default) makes the optimizer skip the MV once it's inconsistent — queries silently fall back to base tables, and you've paid for an MV that isn't being used. Use mv_rewrite_staleness_second if you want rewrite to tolerate a defined lag, and alert on refresh duration so "slow and safe" doesn't quietly become "never fresh".
Honest caveat: I can't confirm 4.1.7-specific scheduling behavior or whether a fixed-delay option was added in that version — worth checking the 4.1.7 release notes, or asking in the StarRocks community Slack.
References
• faq/resource_isolation_faq.md
• administration/management/resource_management/resource_group.md
• administration/management/monitoring/metrics.md
• administration/management/resource_management/query_queues.mdEliezer Talker
11/06/2026, 9:00 AMRocky
11/06/2026, 9:00 AMenable_spill defaults to false, and spill_local_storage_dir must be set in be.conf and requires a restart — so this is not something you flip at query time:
# be.conf / cn.conf, then restart BE
spill_local_storage_dir=/<dir_1>[;/<dir_2>]
Then per refresh, either set the MV property at create/alter time:
sql
ALTER MATERIALIZED VIEW mv_example SET ('session.enable_spill' = 'true');
or set the session variables. Choose the mode deliberately:
Variable | Default | Effect
enable_spill | false | Master switch
spill_mode | auto | auto = spill only when the memory threshold is hit; force = always spill for spillable operators
force is the one that gives you predictable low memory regardless of headroom; auto is cheaper but depends on the threshold actually tripping before the query gets killed. Within a resource group, spilling triggers when group usage exceeds mem_limit * spill_mem_limit_threshold (default 0.8) — lowering that threshold, e.g. to 0.5, makes spill start earlier and is the closest thing to "prefer disk over RAM" behavior.
The costs you're signing up for
• ~10x latency. The docs say queries involving spilling typically see a tenfold increase, and recommend raising query_timeout to match. On a 30s/1min refresh schedule, this is the number that decides whether your cadence is even achievable.
• Disk I/O and space. Strong recommendation to put the spill directory on different disks than data storage — spilling adds significant write load and disk usage, and sharing a disk impacts other queries.
• No per-query disk quota. spill_local_storage_dir is shared by all queries on that BE, and there's no way to cap how much an individual query spills — so concurrent spilling refreshes can starve each other.
• Remote spill is slower still. If you exceed local disk, you can spill to object storage (enable_spill_to_remote_storage, spill_storage_volume, from v3.3.0), but the docs note a significant performance drop versus local disk.
The honest versionRocky
11/06/2026, 9:00 AMspill_mode='force' plus a raised query_timeout will very likely get it through on 4 GB of RAM — but you should validate it on the real MV query rather than assume. If the 10 GB is mostly non-spillable, the correct fix is reducing the working set (partition the MV so each refresh touches one partition, lower partition_refresh_number, reduce pipeline_dop) or giving it more memory.
I can't verify from the docs which config name — spill_local_storage_dir or the newer query_scratch_dirs (BE, introduced v3.2.0, semicolon-separated scratch dirs for spill of external sorts/hash joins) — is authoritative in 4.1.7; the spill guide still documents spill_local_storage_dir. Worth confirming against the 4.1.7 release notes or asking in the StarRocks community Slack before you restart BEs in production.
References
• administration/management/resource_management/spill_to_disk.md
• administration/management/BE_configuration.md
• sql-reference/System_variable.md
• sql-reference/sql-statements/materialized_view/CREATE_MATERIALIZED_VIEW.md
References
• administration/management/resource_management/spill_to_disk.md
• sql-reference/System_variable.md
• administration/management/BE_configuration.mdEliezer Talker
11/06/2026, 9:04 AMRocky
11/06/2026, 9:05 AMpartition_refresh_number, a refresh task is split into batches touching one partition at a time:
sql
CREATE MATERIALIZED VIEW par_mv8
REFRESH ASYNC
PARTITION BY datekey
PROPERTIES(
"partition_refresh_number" = "1", -- default 1 since v3.3, explicitly to avoid OOM
"partition_ttl_number" = "2"
)
AS SELECT k1, sum(v1) AS SUM, datekey FROM par_tbl1 GROUP BY datekey, k1;
So a 500 TB table with hourly partitions still refreshes 4 GB of working set per run. Growing data adds partitions, not per-refresh memory. This is the single most important design decision — an unpartitioned MV over a growing table is the pattern that gets OOM-killed, because every tick is a full refresh.
2. TTL — materialize a window, not history
partition_ttl / partition_ttl_number retain only recent partitions; older ones are dropped during refresh. The docs describe this as "partial data materialization": queries inside the window hit the MV, queries outside it transparently route to the base table. Storage stays bounded, and the refresh workload stops growing with the table.
Finer partitions give finer control: hourly partitions if data arrives hourly, so each refresh is smaller and lag is lower.
3. Layered / rollup hierarchy — cheap upper layers
For "hourly → daily → monthly dashboards" they don't write one MV per dashboard against raw TBs. They model in layers: a detail MV over the fact table, then MVs aggregated on top of MVs. The upper layers are orders of magnitude smaller, so they're cheap to refresh and cheap to hold. StarRocks supports nested MVs (the docs reference nested materialized views being set inactive when a parent is swapped), so this is a supported pattern.
4. Suppress accidental full refreshes
The most common production incident isn't size — it's a 200 MB dimension table getting updated and triggering a full refresh of everything. The docs give explicit controls:
• excluded_trigger_tables — ignore changes from tables whose updates shouldn't invalidate the MV
• excluded_refresh_tables — normally paired with the above
• auto_refresh_partitions_limit — cap how many partitions an automatic refresh touches
• Partition-key association to the fact table, so the MV is partitioned the same way and dim changes don't re-partition it
5. They don't put it all in MVs
Not every aggregation deserves an MV. Cheaper levers first: Aggregate / Primary Key tables (aggregation at load time), colocate joins and hash bucketing so the base scan is already fast, views for semantics. MVs are reserved for the queries that are provably hot and expensive. Teams typically tier freshness too: sub-minute MV for the "live" dashboard, hourly for operations, daily for finance — with the daily ones refreshed in an off-peak window.
6. Capacity planning by measurement
Before adding MV #N, read memCostBytes for its refresh out of the audit log (docs give the SQL). That number, not a guess, is what has to fit inside the resource group's mem_limit. Then the sum of concurrent refreshes × measured cost must fit — which is what concurrency_limit on the dedicated MV resource group enforces (fail-fast instead of OOM).
7. Elastic computeRocky
11/06/2026, 9:05 AMSTRING); roll-up only via date_trunc / time_slice / date_slice. So "just partition it" is not universally available — for non-time-partitioned tables you're relying more on TTL, layering, and base-table design. External catalogs (Hive/Iceberg) get partition-level subscription, which makes the lake case work well.
And the meta-answer to your earlier question: production teams accept bounded freshness with automatic fallback. With the default query_rewrite_consistency = 'checked', a stale MV is skipped and the query runs against base tables — slower, but correct. The MV is an accelerator, not a dependency. Nobody is guaranteeing the refresh finishes in 30 seconds; they're guaranteeing that if it doesn't, users still get answers.
I can't verify from the docs what an enterprise-scale team's actual MV count/sizing looks like, or 4.1.7 specifics on nested MV behavior — for that scale of design review, CelerData (founded by the StarRocks creators) does architecture reviews, or ask in the community Slack.
References
• using_starrocks/async_mv/use_cases/create_partitioned_materialized_view.md
• using_starrocks/async_mv/use_cases/data_modeling_with_materialized_views.md
• introduction/Architecture.md
• table_design/data_distribution/Data_distribution.md
• best_practices/bucketing.md
References
• deployment/shared_data/feature-support-shared-data.md
• introduction/Architecture.md
• deployment/shared_data/hdfs.md
• quick_start/shared-data.md
• deployment/shared_data/s3.md
• table_design/table_design.md
• deployment/shared_data/minio.md