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
- 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_HISTORYandQUERY_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.
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:
| Feature | View |
|---|---|
| Automatic Clustering | AUTOMATIC_CLUSTERING_HISTORY |
| Snowpipe | PIPE_USAGE_HISTORY |
| Materialized view maintenance | MATERIALIZED_VIEW_REFRESH_HISTORY |
| Search optimization service | SEARCH_OPTIMIZATION_HISTORY |
| Query acceleration service | QUERY_ACCELERATION_HISTORY |
| Serverless tasks | SERVERLESS_TASK_HISTORY |
| Replication and failover groups | REPLICATION_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.
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_USAGE | Shows |
|---|---|
CORTEX_AI_FUNCTIONS_USAGE_HISTORY | Credits for AI functions called from SQL, with columns such as FUNCTION_NAME, MODEL_NAME, CREDITS, QUERY_ID, USER_ID, QUERY_TAG |
CORTEX_FUNCTIONS_USAGE_HISTORY | Credits consumed to call Cortex LLM functions |
CORTEX_FUNCTIONS_QUERY_USAGE_HISTORY | Credits for queries that use Cortex LLM functions |
CORTEX_ANALYST_USAGE_HISTORY | Cortex Analyst usage |
CORTEX_SEARCH_DAILY_USAGE_HISTORY | Cortex Search usage |
CORTEX_AGENT_USAGE_HISTORY | Cortex Agent usage |
DOCUMENT_AI_USAGE_HISTORY | Document 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_TAGper 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.
| Part | Compute | Where cost shows |
|---|---|---|
| SQL cells and Snowpark queries from Python cells | Warehouse | WAREHOUSE_METERING_HISTORY |
| Python code in a container runtime | Compute 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:
- In Snowsight, use Cost Management (Admin, Cost management, Consumption) and filter by service or by tag.
- In SQL, combine the Cortex views above with
METERING_HISTORYrows for AI services. - In the organization account,
ORGANIZATION_USAGE.USER_AI_USAGE_HISTORYis a premium view that shows AI usage per user across accounts. - Attach a budget to the AI services and tag the objects that use them.
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_HISTORYandQUERY_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_HISTORYis 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 toUSERSonUSER_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_SECONDSor 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.