Cost Management#

Using RelationalAI (RAI) on Snowflake incurs costs from both Snowflake and RAI itself. Similar to Snowflake, RAI’s cloud architecture separates storage and compute usage, allowing for cost optimization based on specific needs.

Table Of Contents#

How Costs Are Calculated#

Snowflake costs are based on compute and storage resource usage, detailed in the Snowflake User Guide. RAI costs appear as a surcharge for compute usage, primarily from engines. There’s no surcharge for storage usage.

The following resources all contribute to costs generated by the RAI Native App:

ResourceDescriptionSnowflake ChargeRAI SurchageNotes
App DatabaseStores data used by the app.YesNoThis database is named RELATIONALAI unless you customized the app name during install.
App WarehouseUsed for Snowflake interopability.YesNoThe RELATIONAL_AI_ERP_WAREHOUSE is automatically created the first time you activate the app. It is suspended when you deactivate the app and automatically resumed when reactivated.
Serverless tasksUsed to schedule billing, garbage collection, upgrades, and other tasks.YesNoSome tasks, like those related to billing, may generate small amounts of compute consumption even when the app is deactivated.
Compute PoolsUsed for internal app operations and to host engines.NoNoThere’s no cost for compute pools themselves. Costs are only incurred by engines hosted by each compute pool. See Compute Pools for the names and instance families of each compute pool managed by the app.
CDC EngineUsed by the CDC Service to process data streams.YesNoCosts are based on uptime and are determined by the host compute pool’s instance family and the number of compute nodes used by the engine.
User EnginesUsed to evaluate queries from RAI Python models.YesYesCosts are based on uptime and are determined by the host compute pool’s instance family and the number of compute nodes used by the engine.

Optimize Costs#

Configure Engines To Auto-Suspend#

Engines consume compute resources even when they’re not actively processing queries. To reduce costs, you can configure engines to auto-suspend after a period of inactivity. See Engine Suspension for more information.

Suspended engines do not consume compute resources, but they retain their configuration and data. Delete an engine when it’s no longer needed to eliminate costs entirely.

Suspend Data Streams That Don’t Require Real-Time Processing#

Streams that don’t require minute-by-minute processing can be suspended to reduce costs. You may also disable the CDC Service to delete the CDC engine and stop processing change tracking data.

NOTE

While the CDC service is disabled, some compute is consumed as changes to data streams are tracked and queued for processing. To eliminate all costs associated with data streams, you must delete the streams.

Deactivate the App When Not In Use#

You can deactivate the app to reduce costs while the app is not in use. When the app is deactivated, the CDC service is disabled and all engines are deleted. Tasks related to diagnostics and billing are still active and will generate small amounts of compute consumption.

Monitor Costs#

Use the queries below to monitor costs associated with your RAI Native App. For more detailed monitoring, administrators may tag the native app’s storage and compute resources to track RAI costs with Snowflake’s cost management framework.

NOTE

COMING SOON: Snowflake will add support for detailed cost monitoring for native apps through standard cost monitoring tools.

Credits Consumed By All Engines Per Month#

Requires the billing_admin application role.

SELECT
  DATE_TRUNC('MONTH', hour) AS first_day_of_month,
  SUM(credits) AS sum_of_rai_units
FROM
  relationalai.consumption.engine_credit_hours
GROUP BY
  first_day_of_month
ORDER BY
  first_day_of_month DESC;

Credits Consumed By All Engines Per Day#

Requires the billing_admin application role.

SELECT
  DATE_TRUNC('day',c.HOUR) as day, sum(c.credits) AS total_daily_rai_units
FROM
  relationalai.consumption.engine_credit_hours c
WHERE
  hour >= DATEADD(month, -1, CURRENT_TIMESTAMP())
GROUP BY all ORDER BY 1 DESC;

Credits Consumed Per Engine In The Past Month#

Requires the billing_admin application role and USAGE_VIEWER database role.

WITH engine_ownership AS (
    SELECT DISTINCT
        REPLACE(REPLACE(REGEXP_SUBSTR(QUERY_TEXT, $$'.*',$$, 1, 1, 'e'), '\'',''), ',','') AS engine_name,
        max(USER_NAME) AS user_name
    FROM
        SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
    WHERE
        QUERY_TEXT ILIKE '%create_engine%'
        AND start_time >= DATEADD(month, -1, CURRENT_TIMESTAMP())
    GROUP BY engine_name
)
SELECT
    c.engine_name,
    o.user_name,
    sum(c.credits) AS total_rai_units_by_engine
FROM
    relationalai.consumption.engine_credit_hours c
INNER JOIN
    engine_ownership o ON c.engine_name = o.engine_name
WHERE
    hour >= DATEADD(month, -1, CURRENT_TIMESTAMP())
GROUP BY 1, 2 ORDER BY 3 DESC;
NOTE

If multiple users created an engine with the same name during the selected period, the name in the USER_NAME column reflects the name of the last user who created the engine.

Credits Consumed Per Compute Pool Per Month#

Requires the USAGE_VIEWER database role.

SELECT
    DATE_TRUNC('MONTH', START_TIME) AS first_day_of_month,
    compute_pool_name,
    SUM(credits_used) as total_credits
FROM
   SNOWFLAKE.ACCOUNT_USAGE.SNOWPARK_CONTAINER_SERVICES_HISTORY
WHERE
    APPLICATION_NAME = 'RELATIONALAI'
GROUP BY
    first_day_of_month, compute_pool_name
ORDER BY
    first_day_of_month DESC,
    compute_pool_name;

Credits Consumed By the App Warehouse Per Month#

Requires the USAGE_VIEWER database role.

SELECT
    DATE_TRUNC('MONTH', START_TIME) AS first_day_of_month,
    SUM(credits_used) as total_credits
FROM
    SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
WHERE
    WAREHOUSE_NAME = 'RELATIONAL_AI_ERP_WAREHOUSE'
GROUP BY
  first_day_of_month
ORDER BY
  first_day_of_month DESC;