Monitor Dynamic Tables
Workflow for checking health, status, and performance of dynamic tables. This is a READ-ONLY workflow.
When to Load
Main skill routes here when user wants to:
- Check dynamic table status or health
- View refresh history
- Understand pipeline dependencies
- Assess target lag compliance
Workflow
⛔ MANDATORY: Before any INFORMATION_SCHEMA query, set database context:
USE DATABASE <database_name>;
Without this, INFORMATION_SCHEMA functions will fail with "Invalid identifier" errors.
Step 1: Get Current State
Goal: Get current health status of dynamic table(s)
Load references/dt-state.md — SHOW DYNAMIC TABLES vs INFORMATION_SCHEMA.DYNAMIC_TABLES(), which columns each provides, and scheduling_state format differences.
Actions:
Get configuration via SHOW (for all DTs in a schema, or a specific DT):
SHOW DYNAMIC TABLES IN SCHEMA <database>.<schema>;
SHOW DYNAMIC TABLES LIKE '<dynamic_table_name>' IN SCHEMA <database>.<schema>;
| Metric |
Healthy |
Concern |
scheduling_state |
ACTIVE |
SUSPENDED |
refresh_mode |
INCREMENTAL |
FULL = may need optimization |
Get lag metrics via INFORMATION_SCHEMA (for all DTs, or a specific DT):
SELECT
name,
scheduling_state,
last_completed_refresh_state,
target_lag_sec,
maximum_lag_sec,
time_within_target_lag_ratio
FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLES())
ORDER BY name;
SELECT
name,
scheduling_state,
last_completed_refresh_state,
target_lag_sec,
maximum_lag_sec,
time_within_target_lag_ratio
FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLES(name=>'<database>.<schema>.<dynamic_table_name>'));
| Metric |
Healthy |
Concern |
last_completed_refresh_state |
SUCCEEDED |
FAILED, UPSTREAM_FAILED |
time_within_target_lag_ratio |
> 0.95 |
< 0.90 = not meeting freshness |
Written reports: When you summarize for a file or runbook, use the same literals Snowflake returns for last_completed_refresh_state (for example write UPSTREAM_FAILED or upstream failure when that is the state — not only generic words like "error" or "blocked") and for scheduling (write suspended / SUSPENDED when SHOW DYNAMIC TABLES shows suspension — not only "inactive" or "stopped").
Step 2: Check Refresh History
Goal: Understand recent refresh behavior
Actions:
Get recent refresh details (last 20): run the Recent refresh details with statistics query in references/dt-refresh-analysis.md — Example Queries with NAME_PREFIX => '<database>.<schema>' (or NAME => '<database>.<schema>.<dt_name>' for a single DT). Returns per-refresh state, refresh_action, refresh_trigger, query_id, and the unpacked statistics JSON fields (compilation/execution times, row and partition counts).
Check for errors only (last 7 days):
SELECT
name,
refresh_start_time,
state,
state_code,
state_message,
refresh_action
FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLE_REFRESH_HISTORY(
NAME_PREFIX => '<database>.<schema>',
ERROR_ONLY => TRUE
))
WHERE refresh_start_time > DATEADD('day', -7, CURRENT_TIMESTAMP())
ORDER BY refresh_start_time DESC
LIMIT 20;
Calculate refresh statistics (last 7 days): run the canonical Refresh statistics query from references/dt-refresh-analysis.md — Example Queries with NAME => '<database>.<schema>.<dt_name>'.
Interpreting refresh categories: See references/dt-refresh-analysis.md for how to categorize CREATION/REINITIALIZE vs steady-state refreshes. Exclude both from steady-state performance trends.
Comparing across REINITIALIZE boundaries: See references/dt-refresh-analysis.md for methodology. Always report pre-reinit and post-reinit steady-state metrics separately.
Step 3: View Pipeline Dependencies
Goal: Understand DAG structure and upstream/downstream relationships
Load references/dt-graph.md — DYNAMIC_TABLE_GRAPH_HISTORY() columns, parameters, and schema evolution tracking.
Actions:
Get dependency graph:
SELECT
name,
inputs,
scheduling_state,
target_lag_type,
target_lag_sec
FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLE_GRAPH_HISTORY())
WHERE name = '<dynamic_table_name>'
OR ARRAY_CONTAINS('<dynamic_table_name>'::VARIANT, inputs);
Interpret dependencies:
inputs array shows upstream tables
- Tables with
target_lag_type = 'DOWNSTREAM' refresh when downstream needs them
- Look for upstream tables with issues that could affect downstream
Step 4: Analyze Refresh Query Performance
Goal: Understand compute usage and identify potential bottlenecks
Actions:
Get refresh query details (using query_id from refresh history):
Load references/dt-refresh-analysis.md — covers which data source to use, when, and what privileges each requires.
Short-circuit: If the user already provided a query_id, skip the DYNAMIC_TABLE_REFRESH_HISTORY lookup in Step 2 and use the provided query_id directly.
Use the data sources in this order:
GET_QUERY_OPERATOR_STATS with the query_id — provides operator-level breakdowns for identifying bottlenecks. Verify warehouse access first (see reference doc).
QUERY_HISTORY_BY_WAREHOUSE — if you need query-level I/O metrics (bytes scanned, partition pruning, spill). Use the warehouse name from Step 2 or SHOW DYNAMIC TABLES.
SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY — if the query is outside the 7-day INFORMATION_SCHEMA retention or warehouse privileges are unavailable. Verify access before committing to this fallback (see reference doc).
Step 5: Historical comparison (optional)
Goal: Detect drift or regressions by comparing the Step 1–2 snapshot (lag, scheduling state, refresh aggregates) against a longer refresh-history window.
Load references/dt-refresh-analysis.md — Interpreting refresh categories (steady-state vs CREATION / REINITIALIZE) and Account-level refresh history (optional) (SNOWFLAKE.ACCOUNT_USAGE.DYNAMIC_TABLE_REFRESH_HISTORY, privileges, latency).
Prerequisite: Role can read SNOWFLAKE.ACCOUNT_USAGE (see Verify Warehouse Access). If that probe or the account-level rollup query fails, skip this step and report from Steps 1–2 only.
Actions:
Daily steady-state rollup: use the SQL under references/dt-refresh-analysis.md — Example: daily steady-state rollup (same steady-state filters as Step 2).
Compare to Step 2: highlight where the longer window disagrees with the last-7-day picture (avg duration trend, spikes in full_count or failed_count).
Further patterns (e.g. LAG(), BEFORE/AFTER cutoffs): keep the same steady-state rules from the reference doc; use the Snowflake view documentation linked under Account-level refresh history (optional) for additional predicates and columns.
Present Health Report
Summarize findings for the user (chat) or any file path they gave you.
Template router
Pick the template that matches the scope of the request:
Each template has placeholders to fill from Steps 1–2 (and Step 5 if it ran). Do not invent data — skip sections you could not fetch and note any skipped probe in Recommendations.
Output destination
Render in chat by default. Only write to a file (e.g. pipeline_health_report.md) when the user names a path or the calling environment exposes filesystem write tools — Snowsight worksheets do not, so default to chat there.
Snowflake-accurate wording
Always echo UPSTREAM_FAILED or upstream failure when that refresh outcome appears; echo suspended / SUSPENDED when SHOW reports it; echo FULL refresh mode when refresh_mode is FULL (performance or cost signal). Match INFORMATION_SCHEMA / SHOW vocabulary so automated readers align with query results.
Stopping Points
This is a READ-ONLY workflow. No mandatory stopping points.
- If issues found, offer to route to TROUBLESHOOT workflow
- If optimization opportunities found, offer to route to OPTIMIZE workflow
Output
- Health report with key metrics
- Optional account-level trend from Step 5 (when
ACCOUNT_USAGE is available)
- Recommendations for next steps (if issues found)
1---2name: dynamic-tables-monitor3description: "Monitor health, status, and refresh performance of Snowflake dynamic tables. Use when: checking DT status, viewing refresh history, assessing target lag compliance, DT health check. Triggers: check status, refresh history, is it healthy, target lag, DT state, DT health, trend, drift, week over week, before after tuning."4parent_skill: dynamic-tables5metadata:6 source: https://skillmd.com/skills/s-14-h/dynamic-tables-monitor7---89# Monitor Dynamic Tables1011Workflow for checking health, status, and performance of dynamic tables. This is a READ-ONLY workflow.1213## When to Load1415Main skill routes here when user wants to:16- Check dynamic table status or health17- View refresh history18- Understand pipeline dependencies19- Assess target lag compliance2021---2223## Workflow2425⛔ **MANDATORY:** Before any `INFORMATION_SCHEMA` query, set database context:26```sql27USE DATABASE <database_name>;28```29Without this, `INFORMATION_SCHEMA` functions will fail with "Invalid identifier" errors.3031### Step 1: Get Current State3233**Goal:** Get current health status of dynamic table(s)3435**Load** [references/dt-state.md](../references/dt-state.md) — `SHOW DYNAMIC TABLES` vs `INFORMATION_SCHEMA.DYNAMIC_TABLES()`, which columns each provides, and `scheduling_state` format differences.3637**Actions:**38391. **Get configuration** via SHOW (for all DTs in a schema, or a specific DT):40 ```sql41 SHOW DYNAMIC TABLES IN SCHEMA <database>.<schema>;42 ```43 ```sql44 SHOW DYNAMIC TABLES LIKE '<dynamic_table_name>' IN SCHEMA <database>.<schema>;45 ```4647 | Metric | Healthy | Concern |48 |--------|---------|---------|49 | `scheduling_state` | `ACTIVE` | `SUSPENDED` |50 | `refresh_mode` | `INCREMENTAL` | `FULL` = may need optimization |51522. **Get lag metrics** via INFORMATION_SCHEMA (for all DTs, or a specific DT):53 ```sql54 SELECT 55 name, 56 scheduling_state,57 last_completed_refresh_state,58 target_lag_sec,59 maximum_lag_sec,60 time_within_target_lag_ratio61 FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLES())62 ORDER BY name;63 ```64 ```sql65 SELECT 66 name,67 scheduling_state,68 last_completed_refresh_state,69 target_lag_sec,70 maximum_lag_sec,71 time_within_target_lag_ratio72 FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLES(name=>'<database>.<schema>.<dynamic_table_name>'));73 ```7475 | Metric | Healthy | Concern |76 |--------|---------|---------|77 | `last_completed_refresh_state` | `SUCCEEDED` | `FAILED`, `UPSTREAM_FAILED` |78 | `time_within_target_lag_ratio` | > 0.95 | < 0.90 = not meeting freshness |7980 **Written reports:** When you summarize for a file or runbook, **use the same literals Snowflake returns** for `last_completed_refresh_state` (for example write **`UPSTREAM_FAILED`** or **upstream failure** when that is the state — not only generic words like "error" or "blocked") and for scheduling (write **suspended** / **`SUSPENDED`** when `SHOW DYNAMIC TABLES` shows suspension — not only "inactive" or "stopped").8182---8384### Step 2: Check Refresh History8586**Goal:** Understand recent refresh behavior8788**Actions:**89901. **Get recent refresh details (last 20):** run the **Recent refresh details with statistics** query in [references/dt-refresh-analysis.md — Example Queries](../references/dt-refresh-analysis.md#example-queries) with `NAME_PREFIX => '<database>.<schema>'` (or `NAME => '<database>.<schema>.<dt_name>'` for a single DT). Returns per-refresh state, `refresh_action`, `refresh_trigger`, `query_id`, and the unpacked `statistics` JSON fields (compilation/execution times, row and partition counts).91922. **Check for errors only** (last 7 days):93 ```sql94 SELECT 95 name, 96 refresh_start_time,97 state, 98 state_code,99 state_message,100 refresh_action101 FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLE_REFRESH_HISTORY(102 NAME_PREFIX => '<database>.<schema>',103 ERROR_ONLY => TRUE104 ))105 WHERE refresh_start_time > DATEADD('day', -7, CURRENT_TIMESTAMP())106 ORDER BY refresh_start_time DESC107 LIMIT 20;108 ```1091103. **Calculate refresh statistics** (last 7 days): run the canonical **Refresh statistics** query from [references/dt-refresh-analysis.md — Example Queries](../references/dt-refresh-analysis.md#example-queries) with `NAME => '<database>.<schema>.<dt_name>'`.111112 **Interpreting refresh categories:** See [references/dt-refresh-analysis.md](../references/dt-refresh-analysis.md#interpreting-refresh-categories) for how to categorize CREATION/REINITIALIZE vs steady-state refreshes. Exclude both from steady-state performance trends.113114 **Comparing across REINITIALIZE boundaries:** See [references/dt-refresh-analysis.md](../references/dt-refresh-analysis.md#comparing-performance-across-reinitialize-boundaries) for methodology. Always report pre-reinit and post-reinit steady-state metrics separately.115116---117118### Step 3: View Pipeline Dependencies119120**Goal:** Understand DAG structure and upstream/downstream relationships121122**Load** [references/dt-graph.md](../references/dt-graph.md) — `DYNAMIC_TABLE_GRAPH_HISTORY()` columns, parameters, and schema evolution tracking.123124**Actions:**1251261. **Get dependency graph**:127 ```sql128 SELECT 129 name,130 inputs,131 scheduling_state,132 target_lag_type,133 target_lag_sec134 FROM TABLE(INFORMATION_SCHEMA.DYNAMIC_TABLE_GRAPH_HISTORY())135 WHERE name = '<dynamic_table_name>'136 OR ARRAY_CONTAINS('<dynamic_table_name>'::VARIANT, inputs);137 ```1381392. **Interpret dependencies**:140 - `inputs` array shows upstream tables141 - Tables with `target_lag_type = 'DOWNSTREAM'` refresh when downstream needs them142 - Look for upstream tables with issues that could affect downstream143144---145146### Step 4: Analyze Refresh Query Performance147148**Goal:** Understand compute usage and identify potential bottlenecks149150**Actions:**1511521. **Get refresh query details** (using query_id from refresh history):153 154 **Load** [references/dt-refresh-analysis.md](../references/dt-refresh-analysis.md) — covers which data source to use, when, and what privileges each requires.155 156 > **Short-circuit:** If the user already provided a `query_id`, skip the `DYNAMIC_TABLE_REFRESH_HISTORY` lookup in Step 2 and use the provided `query_id` directly.157 158 Use the data sources in this order:159 1. **`GET_QUERY_OPERATOR_STATS`** with the `query_id` — provides operator-level breakdowns for identifying bottlenecks. Verify warehouse access first (see reference doc).160 2. **`QUERY_HISTORY_BY_WAREHOUSE`** — if you need query-level I/O metrics (bytes scanned, partition pruning, spill). Use the warehouse name from Step 2 or `SHOW DYNAMIC TABLES`.161 3. **`SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY`** — if the query is outside the 7-day INFORMATION_SCHEMA retention or warehouse privileges are unavailable. Verify access before committing to this fallback (see reference doc).162163---164165### Step 5: Historical comparison *(optional)*166167**Goal:** Detect drift or regressions by comparing the Step 1–2 snapshot (lag, scheduling state, refresh aggregates) against a longer refresh-history window.168169**Load** [references/dt-refresh-analysis.md](../references/dt-refresh-analysis.md) — [Interpreting refresh categories](../references/dt-refresh-analysis.md#interpreting-refresh-categories) (steady-state vs `CREATION` / `REINITIALIZE`) and [Account-level refresh history (optional)](../references/dt-refresh-analysis.md#account-level-refresh-history-optional) (`SNOWFLAKE.ACCOUNT_USAGE.DYNAMIC_TABLE_REFRESH_HISTORY`, privileges, latency).170171**Prerequisite:** Role can read `SNOWFLAKE.ACCOUNT_USAGE` (see [Verify Warehouse Access](../references/dt-refresh-analysis.md#verify-warehouse-access-before-deep-diving)). If that probe or the account-level rollup query fails, skip this step and report from Steps 1–2 only.172173**Actions:**1741751. **Daily steady-state rollup:** use the SQL under [references/dt-refresh-analysis.md — Example: daily steady-state rollup](../references/dt-refresh-analysis.md#account-level-daily-rollup-example) (same steady-state filters as Step 2).1761772. **Compare to Step 2:** highlight where the longer window disagrees with the last-7-day picture (avg duration trend, spikes in `full_count` or `failed_count`).1781793. **Further patterns** (e.g. `LAG()`, BEFORE/AFTER cutoffs): keep the same steady-state rules from the reference doc; use the Snowflake view documentation linked under [Account-level refresh history (optional)](../references/dt-refresh-analysis.md#account-level-refresh-history-optional) for additional predicates and columns.180181---182183## Present Health Report184185Summarize findings for the user (chat) or any file path they gave you.186187### Template router188189Pick the template that matches the **scope** of the request:190191| Scope | Load | When |192|-------|------|------|193| Single dynamic table | [references/health-report-single-dt.md](../references/health-report-single-dt.md) | User named a specific DT, or scope resolves to one object. |194| Schema-wide / multi-pipeline | [references/health-report-pipeline.md](../references/health-report-pipeline.md) | Request covers every DT in a schema, or more than one pipeline (e.g. "audit our pipelines", "all DTs in MYDB.MYSCHEMA"). |195196Each template has placeholders to fill from Steps 1–2 (and Step 5 if it ran). Do not invent data — skip sections you could not fetch and note any skipped probe in Recommendations.197198### Output destination199200Render in chat by default. Only write to a file (e.g. `pipeline_health_report.md`) when the user names a path or the calling environment exposes filesystem write tools — Snowsight worksheets do not, so default to chat there.201202### Snowflake-accurate wording203204Always echo **`UPSTREAM_FAILED`** or **upstream failure** when that refresh outcome appears; echo **suspended** / **`SUSPENDED`** when SHOW reports it; echo **`FULL`** refresh mode when `refresh_mode` is `FULL` (performance or cost signal). Match `INFORMATION_SCHEMA` / `SHOW` vocabulary so automated readers align with query results.205206---207208## Stopping Points209210This is a READ-ONLY workflow. No mandatory stopping points.211- If issues found, offer to route to TROUBLESHOOT workflow212- If optimization opportunities found, offer to route to OPTIMIZE workflow213214---215216## Output217218- Health report with key metrics219- Optional account-level trend from Step 5 (when `ACCOUNT_USAGE` is available)220- Recommendations for next steps (if issues found)