Semantic View Materialization Recommendations

Generated by the suggest-sv-materializations skill

Account: {{ACCOUNT}} Scope: {{SCOPE}} Window: last {{LOOKBACK_DAYS}} days, queries >5s Generated: {{DATE}}

Summary

#Semantic ViewCandidateDimsMetricsHours saved (est)IMMUTABLE WHEREReminders
1 {{SV_FQN}} {{CANDIDATE_NAME}} {{DIMS}} {{METRICS}} {{HOURS_SAVED}}h {{IMMUTABLE_WHERE}} {{REMINDERS}}
{{SV_SHORT_NAME_1}} {{SV_SHORT_NAME_2}}

Workload Overview

Semantic ViewSlow queriesAvg secMax secHours wastedUsers / Roles
{{SV_FQN}} {{NUM_SLOW}} {{AVG_SEC}} {{MAX_SEC}} {{HOURS}} {{USERS_ROLES}}

{{SV_FQN}}

Workload: {{NUM_SLOW}} slow queries, {{HOURS}} hours wasted
Owner: role {{OWNER_ROLE}} · last DDL by {{LAST_DDL_USER}} ({{LAST_DDL_TYPE}} on {{LAST_DDL_TIME}}) · dbt node: {{DBT_NODE_ID}}

Pre-flight checklist

Metric classification

MetricKindMaterializable?
{{METRIC_NAME}}additive (SUM)yes
{{METRIC_NAME}}non-additive (AVG)yes (exact dims only)
{{METRIC_NAME}}semi-additiveNO — excluded

Candidate: {{CANDIDATE_NAME}}

Covers {{NUM_COVERED}} queries, ~{{HOURS_SAVED}}h saved

Dimensions: {{DIMS}}

Metrics: {{METRICS}}

IMMUTABLE WHERE proposal (refresh-cost optimization):
{{IMMUTABLE_WHERE_PREDICATE}} — {{IMMUTABLE_WHERE_RATIONALE}}

This tells the engine that source rows matching the predicate are frozen (no updates, deletes, or late-arriving inserts). Refresh skips those rows, making both full and incremental refresh substantially cheaper.

Before keeping this clause, confirm: "Will any rows matching {{IMMUTABLE_WHERE_PREDICATE}} ever be updated, deleted, or joined by new rows that change their aggregated values?" If yes → remove the IMMUTABLE WHERE line.

DDL

-- If MAX_STALENESS is missing, run first:
-- ALTER SEMANTIC VIEW {{SV_FQN}} SET MAX_STALENESS = '1 hour';

ALTER SEMANTIC VIEW {{SV_FQN}} ADD MATERIALIZATION {{CANDIDATE_NAME}}
    WAREHOUSE = {{WAREHOUSE}}
    IMMUTABLE WHERE ({{IMMUTABLE_WHERE_PREDICATE}})  -- REMOVE IF CANNOT CONFIRM
AS
    DIMENSIONS {{DIMS}}
    METRICS {{METRICS}};

How to test this materialization

  1. Set MAX_STALENESS if not already set:
    ALTER SEMANTIC VIEW {{SV_FQN}} SET MAX_STALENESS = '1 hour';
  2. Run the ADD MATERIALIZATION DDL above.
  3. Wait for the initial refresh to complete. Monitor via:
    SELECT * FROM TABLE(INFORMATION_SCHEMA.SEMANTIC_VIEW_MATERIALIZATION_REFRESH_HISTORY(
      NAME => '{{CANDIDATE_NAME}}'
    ));
  4. Re-run one of the slow queries and compare execution time:
    -- Sample covered query (was {{SAMPLE_DURATION}}s):
    {{SAMPLE_QUERY}}
  5. Verify the materialization was used via the query profile — look for SemanticViewMaterializationScan in the plan.
  6. If performance is satisfactory, keep it. If not, drop:
    ALTER SEMANTIC VIEW {{SV_FQN}} DROP MATERIALIZATION {{CANDIDATE_NAME}};

Covered queries (sample)

Query IDDurationUserDimsMetrics
{{QUERY_ID}}{{DURATION}}s{{USER}}{{QUERY_DIMS}}{{QUERY_METRICS}}

Excluded queries

Query IDDurationReason
{{QUERY_ID}}{{DURATION}}s{{REASON}}

Action items before applying

Required confirmations

Reminders (handle before running DDL)

IMMUTABLE WHERE confirmations

Caveats