Performance Monitoring and Tuning · Topic 16 of 16

Serverless, AI and Notebook Costs

Track credits from cloud services, serverless features, AI and ML functions and Notebooks, with the views and controls an administrator uses.

  • 5 min
In a nutshell
  • Cloud services billing starts above 10 percent of daily warehouse credits; see METERING_DAILY_HISTORY.
  • Serverless features have their own history views and are not capped by resource monitors.
  • AI functions bill by tokens or pages; use CORTEX_AI_FUNCTIONS_USAGE_HISTORY and QUERY_TAG.

What it is

Not all credits come from warehouses. Snowflake runs some work for you on serverless compute, bills a cloud services layer, and charges AI features by tokens or pages. Each one has its own views, and none is stopped by a resource monitor.

An administrator must know where each kind of spend appears so that a surprise on the bill can be traced to a feature, a user and a query.

CreditstotalwarehousesWAREHOUSE_METERING_HISTORYcloud servicesMETERING_DAILY_HISTORYserverless and AIFeature viewsper feature

How it works

Cloud services credits

The cloud services layer does metadata work, authentication, query compilation and optimization. Cloud services are billed only when daily consumption exceeds 10 percent of daily warehouse credits. The adjustment is shown in METERING_DAILY_HISTORY through CREDITS_USED_CLOUD_SERVICES and CREDITS_ADJUSTMENT_CLOUD_SERVICES.

A high cloud services share usually comes from very many small queries, single row inserts, and frequent SHOW or other metadata commands. Batch the work where you can.

Serverless feature credits

Serverless features run on compute managed by Snowflake, billed as credits to the account. Common ones and their views:

FeatureView
Automatic ClusteringAUTOMATIC_CLUSTERING_HISTORY
SnowpipePIPE_USAGE_HISTORY
Materialized view maintenanceMATERIALIZED_VIEW_REFRESH_HISTORY
Search optimization serviceSEARCH_OPTIMIZATION_HISTORY
Query acceleration serviceQUERY_ACCELERATION_HISTORY
Serverless tasksSERVERLESS_TASK_HISTORY
Replication and failover groupsREPLICATION_GROUP_USAGE_HISTORY

You can also filter METERING_HISTORY or METERING_DAILY_HISTORY on the SERVICE_TYPE column to see all serverless spend in one result.

Watch out

Resource monitors apply to warehouses. Serverless features, including Snowpipe, materialized views and automatic clustering, are not capped by them. Use Budgets to watch this spend.

A materialized view costs credits to keep up to date every time its base table changes, as well as storage. A Snowpipe or serverless task that runs on a short schedule accumulates credits quietly. Review each feature view monthly.

AI and ML function costs

Snowflake Cortex AI functions (the Cortex AISQL functions) consume credits based on token or page usage, not on warehouse size.

View in ACCOUNT_USAGEShows
CORTEX_AI_FUNCTIONS_USAGE_HISTORYCredits for AI functions called from SQL, with columns such as FUNCTION_NAME, MODEL_NAME, CREDITS, QUERY_ID, USER_ID, QUERY_TAG
CORTEX_FUNCTIONS_USAGE_HISTORYCredits consumed to call Cortex LLM functions
CORTEX_FUNCTIONS_QUERY_USAGE_HISTORYCredits for queries that use Cortex LLM functions
CORTEX_ANALYST_USAGE_HISTORYCortex Analyst usage
CORTEX_SEARCH_DAILY_USAGE_HISTORYCortex Search usage
CORTEX_AGENT_USAGE_HISTORYCortex Agent usage
DOCUMENT_AI_USAGE_HISTORYDocument AI usage

CORTEX_AI_FUNCTIONS_USAGE_HISTORY has a maximum latency of five minutes, which is far fresher than most usage views.

SELECT u.name, h.function_name, h.model_name, SUM(h.credits) AS credits
FROM snowflake.account_usage.cortex_ai_functions_usage_history h
JOIN snowflake.account_usage.users u ON u.user_id = h.user_id
WHERE h.start_time >= DATEADD('day', -7, CURRENT_TIMESTAMP())
GROUP BY u.name, h.function_name, h.model_name
ORDER BY credits DESC;

Ways to control AI cost:

  • Encourage a QUERY_TAG per team or project and group on it.
  • Restrict which roles may use Cortex functions.
  • Test prompts on a small sample before running them over a whole table.
  • Set a budget that includes the AI services.

Snowflake ML functions that run on a warehouse, such as forecasting and anomaly detection, use warehouse compute, so their cost appears in the usual warehouse views.

Notebooks consumption

A notebook can use two kinds of compute, and both can bill.

PartComputeWhere cost shows
SQL cells and Snowpark queries from Python cellsWarehouseWAREHOUSE_METERING_HISTORY
Python code in a container runtimeCompute pool (Snowpark Container Services)Snowpark Container Services usage views and METERING_HISTORY

An active session shows as an EXECUTE NOTEBOOK query in Query History, which is where you find and cancel a forgotten one.

Idle sessions are the usual leak. The default idle timeout is 30 minutes on a warehouse runtime and 1 hour on a container runtime, adjustable up to 72 hours in the notebook settings or with IDLE_AUTO_SHUTDOWN_TIME_SECONDS on CREATE NOTEBOOK or ALTER NOTEBOOK. Users can also choose End session to free resources at once.

Controls: shorter idle timeouts, a small dedicated warehouse for notebooks, and limits on who may create compute pools.

AI usage overall

To see all AI spend in one place:

  1. In Snowsight, use Cost Management (Admin, Cost management, Consumption) and filter by service or by tag.
  2. In SQL, combine the Cortex views above with METERING_HISTORY rows for AI services.
  3. In the organization account, ORGANIZATION_USAGE.USER_AI_USAGE_HISTORY is a premium view that shows AI usage per user across accounts.
  4. Attach a budget to the AI services and tag the objects that use them.
AI spend riseswhich function?CORTEX_AI_FUNCTIONS_USAGE_HISTORYfunction, model, userwhich team?QUERY_TAGor tagslimitBudget and role limits

Common mistakes

Expecting a resource monitor to stop Snowpipe or clustering spend. It does not apply to serverless features.

Assuming cloud services are always free. They are billed once they exceed 10 percent of daily warehouse credits.

Looking in WAREHOUSE_METERING_HISTORY for AI function cost. It is billed by tokens or pages and shown in the Cortex views.

Leaving notebook sessions open. An idle compute pool or warehouse session keeps consuming until it ends.

What to remember for the exam

  • Cloud services billing starts above 10 percent of daily warehouse credits; see METERING_DAILY_HISTORY.
  • Serverless features have their own history views and are not capped by resource monitors.
  • AI functions bill by tokens or pages; use CORTEX_AI_FUNCTIONS_USAGE_HISTORY and QUERY_TAG.
  • Notebooks use a warehouse, a compute pool, or both; idle timeout default is 30 minutes (warehouse runtime) or 1 hour (container runtime), up to 72 hours.
  • USER_AI_USAGE_HISTORY is a premium organization view for AI usage per user.

Check yourself

  • Which view attributes AI function credits to users and models?

    CORTEX_AI_FUNCTIONS_USAGE_HISTORY, joined to USERS on USER_ID.

  • Can a resource monitor limit Snowpipe credits?

    No. Resource monitors apply to warehouses; use a budget to watch serverless spend.

  • How do you stop idle notebook sessions from running up cost?

    Set a short IDLE_AUTO_SHUTDOWN_TIME_SECONDS or end the session.

Topic 16 of 16 in Performance Monitoring and Tuning

Test yourself on Performance Monitoring and Tuning

The full Snowflake ADA-C02 question bank has 814 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Snowflake. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.