Understanding costs for dynamic tables

Este tópico fornece uma visão geral dos custos de computação e armazenamento associados a tabelas dinâmicas. Para obter informações gerais sobre os custos do Snowflake, consulte Compreensão do custo total.

Compute costs

Há dois custos de computação associados a tabelas dinâmicas: warehouses virtuais e computação de serviços de nuvem.

Dynamic tables require at least one virtual warehouse to perform refreshes. You can optionally assign a second warehouse if you want to separate compute costs for different operations. For more information, see Understand warehouse usage for dynamic tables.

Dynamic table refreshes consume compute credits, and their frequency is determined by the configured target lag: lower target lag values trigger more frequent refreshes and therefore higher compute costs.

Dynamic tables also require Cloud Services compute to identify changes in underlying base objects and determine whether a virtual warehouse must run. If Cloud Services compute finds no changes, no warehouse compute credits are consumed because there’s no new data to refresh. If changes do exist, even if the dynamic table query filters them, the virtual warehouse consumes credits because the dynamic table refreshes to evaluate whether those changes apply.

If the associated virtual warehouses are suspended and Cloud Services compute detects no changes in the base tables, the warehouses remain suspended and the dynamic tables don’t consume any credits. When Cloud Services compute identifies changes in the base tables, the appropriate warehouse automatically resumes. If the changes support incremental refresh, the dynamic table refreshes by using the WAREHOUSE parameter. If reinitialization is required — for example, because of a base table schema change — the dynamic table uses the INITIALIZATION_WAREHOUSE to perform a full reinitialization. For information on how dynamic tables automatically suspend, see Suspensão dinâmica automática da tabela.

Check your consumption of virtual warehouse credits

To check whether your dynamic table refreshes consumed virtual warehouse credits, use the Refresh History tab in Snowsight:

  1. No menu de navegação, selecione Transformation » Dynamic tables.

  2. Select your dynamic table, and then select the Refresh History tab.

  3. To view refreshes that used the warehouse to update, select the Warehouse used only checkbox.

Dica

To better understand costs related to your dynamic table pipelines, Snowflake recommends that you test dynamic tables by using dedicated warehouses. This way, you can isolate the virtual warehouse consumption that is attributed to dynamic tables. You can move your dynamic tables to a shared warehouse after you establish a cost baseline.

For more information, see Understand warehouse usage for dynamic tables.

Calcular o custo de restrições de imutabilidade

If you use the IMMUTABLE WHERE constraint, Snowflake recomputes only the rows that don’t match the immutability condition, which helps reduce reinitialization costs. This is useful in situations where reinitialization can occur, such as the following scenarios:

  • Recriação de tabelas ou exibições a montante.

  • Alterações nas políticas de governança de dados a montante.

  • Failover para uma região secundária em um grupo de failover.

Using the IMMUTABLE WHERE constraint can help you reduce the cost of incremental and full refresh because the constraint ignores changes and data that match its predicate.

Adding immutability constraints to a dynamic table doesn’t trigger extra computation, but removing them does because it causes reinitialization on the next refresh. Modifying the predicate in an IMMUTABLE WHERE constraint might trigger reinitialization depending on whether Snowflake can determine the rows that are returned with the original condition are still returned with the new condition.

Por exemplo, as seguintes modificações não acionam a reinicialização:

  • De (ts < CURRENT_TIMESTAMP() - INTERVAL '2 days') para (ts < CURRENT_TIMESTAMP() - INTERVAL '1 days')

  • De (year <= 2023) para (year <= 2024)

As seguintes modificações acionam a reinicialização:

  • De (ts < '2025-01-02') para (ts < '2025-01-01')

  • De (year < 2024) para (month < 10)

Custo de armazenamento

Dynamic tables require storage to store the materialized results. Similar to regular tables, you might incur additional storage cost for Time Travel, fail-safe storage, and cloning features.

Dynamic Apache Iceberg™ tables don’t incur Snowflake storage costs. For more information, see Faturamento.

Esta seção discute as seguintes considerações de armazenamento para tabelas dinâmicas:

Para obter informações detalhadas sobre como esse armazenamento incorre em custos, consulte Explicação do custo de armazenamento e Considerações sobre armazenamento de dados.

Custos de Time Travel e fail-safe

With Snowflake Time Travel, you can access and query historical versions of dynamic tables at specific points in time, which can help provide insights into historical trends, changes, and anomalies in your data.

Frequent refreshes can increase buildup of Time Travel data, which adds to your overall storage usage. For more information, see Compreensão e uso do Time Travel.

Os recursos fail-safe ajudam a proteger suas tabelas dinâmicas contra perda ou corrupção de dados. Com base no período de fail-safe configurado, cobranças adicionais de armazenamento podem ser aplicadas.

Replicação de tabelas dinâmicas

Dynamic tables support cross-account, cross-region replication, which lets you copy data from a primary database to a secondary database for either disaster recovery or data sharing. It can serve as either a failover preparation strategy for disaster recovery or as a means of sharing data across deployments for read-only purposes. Using replication with dynamic tables is subject to replication costs. For more information, see Replicação e tabelas dinâmicas.

Tabelas dinâmicas suspensas

Suspended dynamic tables don’t incur additional costs beyond standard storage fees and don’t consume compute resources. If you have ongoing maintenance tasks or scheduled jobs that interact with the suspended table, your dynamic tables might consume compute resources.

Tabelas dinâmicas transitórias

Snowflake supports transient dynamic tables, similar to regular tables, that persist until explicitly dropped, and are available to all users with the appropriate privileges without a fail-safe period. Transient dynamic tables are best used for transitory data that doesn’t need the same level of data protection and recovery that permanent tables provide. Using them helps you save on storage charges for fail-safe storage.

Armazenamento adicional para operações de atualização incremental

For incremental refresh operations, dynamic tables maintain an additional internal metadata column for identifying each row within the table. Internal row identifiers consume a constant amount of storage per row and increase storage cost linearly to the number of rows in the table, independent of the number of columns.

For tables with very few columns, the increase in storage compared to an equivalent CTAS table can be significant, or even dominant. In wider dynamic tables, this effect is less pronounced.

Custo do cronograma de atualização

The schedule at which a dynamic table refreshes, whether full or incremental, has an effect on its overall cost. This section discusses the factors that you should consider when you decide on a refresh schedule, with the assumption that every refresh is non-empty:

Nota

As atualizações são relativamente baratas se as fontes não tiverem mudado. Para obter mais informações, consulte Compute costs (neste tópico).

Cronograma de atualização completo

The cost of a full refresh typically depends on how much data your dynamic table scans and how often it refreshes. To save on costs, you can refresh your dynamic tables only when you need to; for example, you can suspend your dynamic tables outside of business hours. For precise timing control, set the downstream target lag for your dynamic tables and use manual refresh from a task to automate your custom schedules.

Cronograma de atualização incremental

The cost of an incremental refresh is typically proportional to the volume of changes in the source objects, plus some fixed overhead.

If the overhead is low, you can set a high refresh frequency without much downside. This means that you can refresh often for best results. For instance, a simple SELECT ... FROM ... WHERE dynamic table only processes changed rows between refreshes, which has minimal overhead and the dynamic table can run frequently at low added cost.

If the overhead is high, you must balance the credit consumption of high refresh frequency with the business benefits of freshness. For example, in a dynamic table with a join, you must join the changes in one table with the other table. No matter how small the set of changes, this join usually involves a minimum cost for you to execute. If this overhead is significant, it can accumulate as the refresh frequency increases.