What you will be able to do
- Choose between a view, a materialized view, a dynamic table and a hand-built table for a transformation, based on read speed, freshness and cost
- Weigh the benefits, limitations and properties of views and materialized views, including recursion, schema resolution and SECURE
- Configure a dynamic table's target lag and refresh mode, and recognise what it cannot contain
- Explain when a stream's offset advances and how tasks consume streams on a schedule or trigger
- Place staging tables and change capture correctly in a layered pipeline
Key concept
Declarative versus imperative transformation — With a dynamic table you declare the result you want as a SELECT, plus how fresh it must be, and Snowflake works out the dependencies and refreshes. With streams and tasks you write the change capture, the scheduling and the processing logic yourself.
1.Views, materialized views and tables: who pays for freshness
Most transformations in Snowflake end up in one of four forms. A view recomputes on every read. A materialized view stores its result and keeps it current. A dynamic table materializes one step of a pipeline. A plain table is filled by code you write. Choosing among them means trading read speed and freshness against who pays to keep the result current, and how.
A standard view is a named query and nothing more. Its results come from running the query each time the view is referenced, and nothing is kept for later. It uses no storage, but every read spends warehouse compute. That makes views the right tool for modular SQL, for reuse, and for access control: you can grant a role privileges on a view without granting it anything on the tables underneath. The view's owner role must still be able to read those tables.
A materialized view behaves more like a table than a view. Its result is pre-computed and stored, so reads are fast. That pays off most for expensive aggregation, projection and selection that run often on large data sets. The cost has two parts. The stored result adds to the account's monthly storage. Whenever the base table changes, a background service updates every materialized view defined on it. That service runs on Snowflake-provided compute billed in 1-second increments and appears under a warehouse named MATERIALIZED_VIEW_MAINTENANCE. Resource monitors cannot cap that warehouse. Materialized views also require Enterprise Edition or higher.
Clustering a materialized view is allowed, but it multiplies maintenance. Take an append-only base table and a view clustered by postal code. A load of 100 new rows that fills one or two base-table micro-partitions can force rewrites of 100 micro-partitions in the view. Suspending the view does not save that money. It only defers maintenance, which builds up while the view is suspended. Schema changes are the other risk: changing or dropping any existing base-table column suspends every materialized view on that table, even views that never used the column. A suspended view cannot be resumed. You recreate it, usually with CREATE OR REPLACE MATERIALIZED VIEW ... COPY GRANTS.
| Object | How results are produced | Storage | Keeping it current | Main drawback |
|---|---|---|---|---|
| View | Query runs each time the view is referenced | None | Nothing to maintain; compute is spent on every read | Slow and inflexible for heavy queries |
| Materialized view | Pre-computed and stored | Consumes storage | Always up to date; compute is spent on background maintenance | Maintenance compute and storage cost |
| Dynamic table | Materialized from a SELECT and refreshed automatically | Consumes storage | Refreshed according to the criteria you set | You must decide how often, when and how to refresh |
A standard view's benefits are simplicity and reuse; its limitation is paying for every read. It is easy to define and consumes no storage. One definition can serve many queries or be stacked into hierarchies, such as a medical_staff view built from doctors and nurses views, and each layer can be debugged on its own. Because nothing is stored, though, a view over an expensive join or aggregation repeats that work for every caller. When the same heavy query runs many times an hour, that is the signal to move to a stored result.
Several properties change how a view behaves. A standard view can be recursive, through a recursive CTE or the RECURSIVE keyword, while materialized views carry restrictions that standard views do not. A table named without a schema resolves to the view's own schema rather than the session's active one, so the view reads the same table whoever queries it. SECURE can be set on either kind of view. It shows the definition only to the owner role and keeps the optimizer from reordering filters, which blocks the trick of provoking a divide-by-zero error to learn that hidden rows exist. The price is slower execution, so reserve it for privacy and not for views built only for convenience.
Checkpoint 1 of 7· Match them up
Match each way of producing a transformation result to how it is kept current and who pays for that.
Tap a term, then the definition that fits it.
A view keeps no results, so you pay compute on every read. A materialized view and a dynamic table both store their result and pay to keep it fresh: the materialized view through background maintenance, the dynamic table through refreshes on criteria you choose. A plain table changes only when your own code writes to it.
“A non-materialized view’s results are created by executing the query at the time that the view is referenced in a query.”Source: docs.snowflake.com
Checkpoint 2 of 7· Exam question
A team needs a view over a frequently queried aggregation that must return sub-second results, and they are willing to pay ongoing storage and maintenance credits to get that speed. Which properties correctly describe the object they should create?
Correct answer: A — It stores the query result physically like a table, supports clustering keys for tuning, and uses background compute credits to stay current with the base table.
- A. Correct - a materialized view stores its result set like a table, can define its own clustering key for query tuning, and Snowflake runs background maintenance that consumes compute credits whenever the base table changes to keep the stored result current.
- B. Incorrect - materialized views do support independent clustering keys, and background maintenance credits are charged continuously as base data changes, not only at creation.
- C. Incorrect - describing plan caching without physical storage misrepresents materialized views, which persist actual result rows rather than only caching a compiled plan.
- D. Incorrect - a materialized view can be granted independently of the base table privileges, so a querying role does not need direct access to the underlying tables to query the materialized view.
2.Dynamic tables: declare the result and a target lag
A dynamic table applies the stored-result idea to a whole pipeline. You write a SELECT and a target lag. Snowflake finds the base tables, watches them, and refreshes the result. Each refresh is applied atomically, so readers never see a half-finished refresh. When dynamic tables read from one another, Snowflake works out the dependency graph from their queries. It then refreshes them in dependency order against a consistent snapshot, so you never script the execution order.
CREATE OR ALTER DYNAMIC TABLE dt_orders
TARGET_LAG = '10 minutes'
WAREHOUSE = transform_wh
REFRESH_MODE = INCREMENTAL
AS
SELECT
order_id,
customer_id,
order_date,
TRIM(UPPER(product_name)) AS product_name,
quantity,
unit_price,
quantity * unit_price AS line_total,
order_status
FROM raw_orders
WHERE order_status != 'returned';TARGET_LAG is a freshness goal, not a schedule. A lag of ten minutes means Snowflake tries to keep the data no more than ten minutes behind its sources. A slow refresh can still overshoot. Intermediate tables can use TARGET_LAG = DOWNSTREAM, which makes them refresh only when a dynamic table further down the pipeline needs fresh data. This avoids refreshes that nothing reads. Moving a batch pipeline toward near-real-time is largely a matter of lowering that one parameter, and the cost table below shows the price of doing so.
| REFRESH_MODE | Behaviour |
|---|---|
| INCREMENTAL | Processes only the rows that changed since the last refresh |
| FULL | Refreshes the entire result set |
| AUTO | Snowflake chooses at creation time, based on whether the definition supports incremental refresh |
| ADAPTIVE | Incremental by default, but reinitializes automatically when large upstream changes are detected |
| CUSTOM_INCREMENTAL | You define the refresh logic yourself with DML statements |
| Cost category | What drives it |
|---|---|
| Warehouse compute | Warehouse size, how often refreshes run, query complexity, data volume |
| Cloud Services | Compiling refreshes, tracking dependencies, monitoring changes; grows with pipeline depth, number of tables and shorter target lag |
| Storage | Micro-partitions added or replaced by refreshes, table size, Time Travel retention |
The limits mark where dynamic tables stop being the answer. The minimum target lag is 60 seconds and refresh timing is not guaranteed, so data that must be fresher, or refreshed at an exact time, needs another tool. The definition cannot call stored procedures or external functions, and UDTFs are allowed only inside lateral joins. The working rule is this: logic you can write as a SQL SELECT is a candidate. Setting SCHEDULER = DISABLE hands refresh control to an external tool such as dbt or Airflow. Compared with a materialized view, a dynamic table is the more flexible option. It supports joins, window functions and multi-step chains with automatic dependency tracking, and gives you finer control over refresh.
Checkpoint 3 of 7· Check yourself
A team plans to replace its stream-and-task pipelines with dynamic tables. Which of these pipelines has to stay on streams and tasks?
A dynamic table's definition cannot call stored procedures or external functions, so the scoring step has to stay on streams and tasks. Dynamic tables support joins, window functions and multi-step chains. TARGET_LAG = DOWNSTREAM covers the intermediate step. A five-minute lag is above the 60-second minimum.
“Need stored procedures or external functions in the definition.”Source: docs.snowflake.com
Checkpoint 4 of 7· Exam question
A finance team currently maintains a nightly stored procedure and task pair that recomputes a summary table from three source tables using full recomputation logic the team wrote by hand. They want to replace this with a declarative object that automatically tracks dependencies and refreshes on a lag target, without them writing custom orchestration code. Which options correctly describe capabilities of the object they should adopt? (Select all that apply.)(Select 3)
Correct answers: A, B, C — A TARGET_LAG setting tells Snowflake how current the result must be, and Snowflake schedules refreshes to try to meet that freshness target automatically.; The refresh mode can be set to INCREMENTAL so only changed rows since the last refresh are reprocessed, reducing compute compared to full recomputation.; Setting TARGET_LAG to DOWNSTREAM on an intermediate object lets it refresh only when a dependent object actually needs the data, rather than on its own fixed schedule.
- A. Correct - dynamic tables use a TARGET_LAG parameter that expresses the maximum acceptable staleness, and Snowflake's scheduler works to refresh the table often enough to stay within that target.
- B. Correct - dynamic tables support an incremental refresh mode that processes only the rows affected by upstream changes since the previous refresh, which is typically far cheaper than a full recompute.
- C. Correct - setting TARGET_LAG to DOWNSTREAM on an intermediate dynamic table defers its refresh timing to whatever cadence its dependents require, avoiding redundant refreshes on a fixed schedule.
- D. Incorrect - dynamic tables cannot reference stored procedures or external functions in their defining query, which is a documented restriction distinguishing them from ordinary tables populated by procedural code.
- E. Incorrect - dynamic table costs include cloud services charges for dependency tracking and scheduling in addition to warehouse compute during refreshes, so cost is not limited to compute alone.
Sources6
3.Streams and tasks: capturing and processing changes yourself
Streams and tasks are the imperative alternative. You capture changes and decide yourself when and how to process them. A stream records inserts (including COPY INTO), updates and deletes on a source object and exposes them as a change table. Supported sources include standard tables, views, dynamic tables and external tables. A stream holds no table data, only an offset. Creating the first stream on a table adds hidden change-tracking columns to that table, which use a small amount of storage.
Each change row has the source's columns plus METADATA$ACTION, METADATA$ISUPDATE and METADATA$ROW_ID. An UPDATE appears as a DELETE and INSERT pair with METADATA$ISUPDATE set to TRUE. A stream returns the net difference between two offsets, so a row inserted and then updated since the offset appears as one new row.
The offset moves only when DML consumes the stream. CREATE TABLE AS SELECT also counts as consuming it. Several queries can read the same changes without moving the offset. To make several DML statements process the same change set, wrap them in BEGIN ... COMMIT. The stream advances when the transaction commits and stays where it was if the transaction fails.
A task supplies the scheduling. It can run SQL, a stored procedure, or code in Python, Java, Scala, JavaScript or Snowflake Scripting. It runs on an interval or a CRON schedule, or when a trigger fires. Every new task starts suspended until you run ALTER TASK ... RESUME. Snowflake runs only one instance of a scheduled task at a time: if a run is still going when the next slot arrives, that slot is skipped. A WHEN SYSTEM$STREAM_HAS_DATA condition ties a task to a stream, so the task does nothing when nothing has changed. Task graphs link tasks in series or in parallel for multi-step workflows.
CREATE TASK triggered_task_stream
WHEN SYSTEM$STREAM_HAS_DATA('orders_stream')
AS
INSERT INTO completed_promotions
SELECT order_id, order_total, order_time, promotion_id
FROM orders_stream;| Factor | Serverless task | User-managed task |
|---|---|---|
| Setup | Omit WAREHOUSE; Snowflake sizes the compute from recent runs | Include WAREHOUSE |
| Billing | Actual compute resource usage | Warehouse size, with a 60-second minimum each time the warehouse resumes |
| Schedule adherence | Recommended when keeping to the interval matters; compute grows if a run overruns | Recommended when keeping to the interval matters less |
| Size ceiling | Equivalent to XXLARGE, bounded by SERVERLESS_TASK_MAX_STATEMENT_SIZE | Any warehouse size you choose |
Checkpoint 5 of 7· Check yourself
An hourly task loads a stable volume of data, and its runs must keep to the hourly interval. Its current warehouse is mostly idle between runs, and the workload fits well within an XXLARGE warehouse. How should the task be set up?
Serverless tasks are recommended when keeping to the schedule interval matters. You omit WAREHOUSE, and Snowflake adds compute when a run overruns. The 60-second minimum applies to user-managed warehouses, and setting WAREHOUSE makes a task user-managed.
“Recommended when adherence to the schedule interval is highly important.”Source: docs.snowflake.com
Checkpoint 6 of 7· Check yourself
Two INSERT ... SELECT statements must each load the same change records from orders_stream, into two different target tables. When they run one after another in autocommit mode, the second INSERT finds the stream empty. What fixes this?
In autocommit mode, the first INSERT commits and moves the offset, so the second INSERT sees no changes. Inside one BEGIN ... COMMIT, both statements read the same change set, and the offset moves only when the transaction commits. A plain SELECT neither locks nor consumes the stream, and recreating it throws away the pending changes.
“To ensure multiple statements access the same change records in the stream, surround them with an explicit transaction statement (BEGIN .. COMMIT).”Source: docs.snowflake.com
4.Staging tables and choosing a pipeline pattern
Landed data waits in a staging layer before it is transformed into the next zone, as described in Data warehouse zones/layers and data lake directory structure. Staging and intermediate tables are usually transient, because their contents can be rebuilt from the source and so do not need to pay for Fail-safe storage. See Table types: permanent, transient, temporary.
Change capture works well on the staging layer. A stream on a staging table lets the next step transform only the rows that changed since the last extraction, and a triggered task runs that step only when there is something to process. A dynamic table that reads from the same staging table does the same job without any stream or task code. The choice between them depends on what the logic contains, not on how much data there is.
| Requirement | Fits best | Why |
|---|---|---|
| Reusable logic or a role-scoped subset of columns, no storage | View | Consumes no storage; computed when queried |
| Very fast reads on a frequent, expensive aggregation | Materialized view | Pre-computed result kept current in the background |
| Multi-step SQL with joins, aggregations or window functions, freshness of 60 seconds or more | Dynamic table | Declarative; Snowflake infers dependencies and schedules refreshes |
| Stored procedures, external functions, or strictly guaranteed timing | Streams and tasks | Dynamic tables do not support these workloads |
Consider a nightly task that runs a stored procedure to recompute a summary from scratch, even on nights when no data arrived. There are two ways to stop paying for empty runs. A dynamic table with a 15-minute target lag and incremental refresh rebuilds only what changed, keeps the summary close to current, and removes the orchestration code. If the logic really needs a stored procedure, keep the task but put a stream on the source tables and add a WHEN SYSTEM$STREAM_HAS_DATA condition, so the task skips runs with no new data.
Checkpoint 7 of 7· Match them up
Four downstream needs read from one staging layer. Pair each transformation object with the need it fits best.
Tap a term, then the definition that fits it.
Which object fits depends on what the logic contains. A view stores nothing and suits reuse and role-scoped access. A materialized view suits fast reads on a frequent, expensive aggregation. Multi-step SQL with freshness of 60 seconds or more suits a dynamic table. A dynamic table's definition cannot call a stored procedure, so that step needs a stream and a triggered task.
“As a general rule, if your logic is expressible as a SQL SELECT statement, it is a candidate for a dynamic table.”Source: docs.snowflake.com
Sources
(8)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“A non-materialized view’s results are created by executing the query at the time that the view is referenced in a query.”
↩︎ Views, materialized views and tables: who pays for freshness“you can grant privileges on a particular view to a particular role, without the grantee role having privileges on the table(s) underlying the view.”
↩︎ Views, materialized views and tables: who pays for freshness“A materialized view’s results are stored, almost as though the results were a table.”
↩︎ Views, materialized views and tables: who pays for freshness“A non-materialized view can be recursive (i.e. the view can refer to itself).”
↩︎ Views, materialized views and tables: who pays for freshness“materialized views have some restrictions that non-materialized views do not have.”
↩︎ Views, materialized views and tables: who pays for freshness“then Snowflake assumes that the table is in the same schema as the view.”
↩︎ Views, materialized views and tables: who pays for freshness - 2.
“Secure views can execute more slowly than non-secure views.”
↩︎ Views, materialized views and tables: who pays for freshness - 3.
“Simple, easily defined, consumes no storage.”
↩︎ Views, materialized views and tables: who pays for freshness“Because the result is pre-computed, querying a materialized view is faster than executing a query against the base table of the view.”
↩︎ Views, materialized views and tables: who pays for freshness - 4.
“Maintaining clustering (of either a table or a materialized view) adds costs.”
↩︎ Views, materialized views and tables: who pays for freshness“If a base table is altered so that existing columns are changed or dropped, then all materialized views on that base table are suspended”
↩︎ Views, materialized views and tables: who pays for freshness“you cannot use them to control credit usage for the Snowflake-provided warehouses, including the MATERIALIZED_VIEW_MAINTENANCE warehouse.”
↩︎ Views, materialized views and tables: who pays for freshness“suspending maintenance typically only defers costs, rather than reducing them.”
↩︎ Exam trap 3“Snowflake performs automatic background maintenance of materialized views.”
↩︎ Prediction - 5.
“The Search Optimization Service and materialized views also require the Enterprise Edition or higher”
↩︎ Views, materialized views and tables: who pays for freshness - 6.
“The new results are applied to the dynamic table atomically, so readers never see a partial refresh.”
↩︎ Dynamic tables: declare the result and a target lag“actual lag can exceed the target when refreshes take longer than expected”
↩︎ Dynamic tables: declare the result and a target lag“You can also set TARGET_LAG = DOWNSTREAM on intermediate tables so they refresh only when their downstream dependents need fresh data.”
↩︎ Dynamic tables: declare the result and a target lag“Require data fresher than 60 seconds (the minimum target lag) or strictly guaranteed refresh timing.”
↩︎ Dynamic tables: declare the result and a target lag“target lag (shorter lag means more scheduling work)”
↩︎ Dynamic tables: declare the result and a target lag“if your logic is expressible as a SQL SELECT statement, it is a candidate for a dynamic table.”
↩︎ Staging tables and choosing a pipeline pattern“Prefer a declarative approach where you define the desired result and let Snowflake handle scheduling.”
↩︎ Key concept“Need stored procedures or external functions in the definition.”
↩︎ Exam trap 2“Need stored procedures or external functions in the definition.”
↩︎ Checkpoint“As a general rule, if your logic is expressible as a SQL SELECT statement, it is a candidate for a dynamic table.”
↩︎ Checkpoint - 7.
“Note that a stream itself does not contain any table data.”
↩︎ Streams and tasks: capturing and processing changes yourself“Updates to rows in the source object are represented as a pair of DELETE and INSERT records in the stream”
↩︎ Streams and tasks: capturing and processing changes yourself“only the data in staging tables that has changed since the last extraction is transformed and copied into other tables.”
↩︎ Staging tables and choosing a pipeline pattern“Querying a stream alone does not advance its offset, even within an explicit transaction”
↩︎ Exam trap 1“A stream advances the offset only when it is used in a DML transaction.”
↩︎ Prediction“To ensure multiple statements access the same change records in the stream, surround them with an explicit transaction statement (BEGIN .. COMMIT).”
↩︎ Checkpoint - 8.https://docs.snowflake.com/en/user-guide/tasks-introOfficial docs
“If a task is still running when the next scheduled run time occurs, then that scheduled time is skipped.”
↩︎ Streams and tasks: capturing and processing changes yourself“Task graphs can use logic to perform dynamic behavior, running tasks in parallel or in series.”
↩︎ Streams and tasks: capturing and processing changes yourself“The maximum compute size for a serverless task is equivalent to an XXLARGE virtual warehouse.”
↩︎ Streams and tasks: capturing and processing changes yourself“it eliminates frequent polling of the source when new data arrival is unpredictable.”
↩︎ Staging tables and choosing a pipeline pattern“Recommended when adherence to the schedule interval is highly important.”
↩︎ Checkpoint