Snowflake Cost Management and Optimization
Effective cost management in Snowflake requires understanding the cost drivers and implementing optimization strategies across compute, storage, and data transfer.
Cost Components Deep Dive
Compute Costs
Compute is typically 60-80% of total Snowflake spend. Costs accrue per-second (with a 60-second minimum) while a warehouse is running, regardless of query activity. A warehouse running idle still consumes credits.
| Warehouse Size | Credits per Hour | Credits per Minute | Typical Use Case |
|---|---|---|---|
| X-Small | 1 | 0.0167 | Dev/Test, light queries |
| Small | 2 | 0.0333 | Standard analytics |
| Medium | 4 | 0.0667 | Complex BI queries |
| Large | 8 | 0.1333 | Data engineering |
| X-Large | 16 | 0.2667 | Large transformations |
| 2X-Large | 32 | 0.5333 | Heavy ETL workloads |
| 3X-Large | 64 | 1.0667 | Enterprise workloads |
| 4X-Large | 128 | 2.1333 | Maximum parallelism |
Storage Costs
Snowflake storage includes active data, Time Travel storage, and Fail-safe storage. Time Travel retention directly impacts storage costs.
-- Check current storage usage by database
SELECT
DATABASE_NAME,
SUM(ACTIVE_BYTES) / 1024 / 1024 / 1024 / 1024 AS ACTIVE_TB,
SUM(TIME_TRAVEL_BYTES) / 1024 / 1024 / 1024 / 1024 AS TIME_TRAVEL_TB,
SUM(FAILSAFE_BYTES) / 1024 / 1024 / 1024 / 1024 AS FAILSAFE_TB,
(SUM(ACTIVE_BYTES) + SUM(TIME_TRAVEL_BYTES)) / 1024 / 1024 / 1024 / 1024 AS BILLABLE_TB
FROM DATABASE_STORAGE_USAGE_HISTORY
WHERE USAGE_DATE = CURRENT_DATE()
GROUP BY 1
ORDER BY BILLABLE_TB DESC;
Data Transfer Costs
Cross-region data transfer and public internet egress incur per-GB charges. Same-region transfers within the same cloud provider are free.
Serverless Feature Costs
Features like Snowpipe, Search Optimization, and materialized view maintenance consume credits automatically. These are billed separately from warehouse compute.
Resource Monitors and Alerts
-- Create a resource monitor with credit quota
CREATE OR REPLACE RESOURCE MONITOR monthly_budget
WITH
CREDIT_QUOTA = 5000
FREQUENCY = MONTHLY
START_TIMESTAMP = IMMEDIATELY
TRIGGERS
ON 50% DO NOTIFY
ON 75% DO NOTIFY
ON 90% DO SUSPEND
ON 100% DO SUSPEND_IMMEDIATELY;
-- Assign monitor to warehouse
ALTER WAREHOUSE analytics_wh
SET RESOURCE_MONITOR = monthly_budget;
-- Create a monitor for a specific department
CREATE OR REPLACE RESOURCE MONITOR dept_marketing
WITH
CREDIT_QUOTA = 1000
FREQUENCY = MONTHLY
TRIGGERS
ON 80% DO SUSPEND
ON 100% DO SUSPEND_IMMEDIATELY;
-- Check current credit usage
SELECT
WAREHOUSE_NAME,
SUM(CREDITS_USED) AS TOTAL_CREDITS,
SUM(CREDITS_USED_COMPUTE) AS COMPUTE_CREDITS,
SUM(CREDITS_USED_CLOUD_SERVICES) AS CLOUD_SERVICES_CREDITS
FROM ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
WHERE START_TIME >= DATE_TRUNC('month', CURRENT_DATE())
GROUP BY 1
ORDER BY TOTAL_CREDITS DESC;
Warehouse Sizing and Optimization Queries
-- Analyze query performance vs warehouse size
SELECT
w.WAREHOUSE_NAME,
w.WAREHOUSE_SIZE,
COUNT(q.QUERY_ID) AS query_count,
AVG(q.EXECUTION_TIME_MS) / 1000 AS avg_exec_seconds,
SUM(q.CREDITS_USED) AS total_credits,
SUM(q.CREDITS_USED) / COUNT(q.QUERY_ID) AS credits_per_query
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY q
JOIN SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY w
ON q.WAREHOUSE_NAME = w.WAREHOUSE_NAME
WHERE q.START_TIME >= CURRENT_DATE() - 30
GROUP BY 1, 2
ORDER BY total_credits DESC;
-- Find warehouses with low utilization
SELECT
WAREHOUSE_NAME,
WAREHOUSE_SIZE,
SUM(CREDITS_USED) AS credits_used,
SUM(AVG_RUNNING) / 60 AS avg_running_minutes,
CASE
WHEN SUM(AVG_RUNNING) < 300 THEN 'LOW - Consider smaller size'
WHEN SUM(AVG_RUNNING) < 1800 THEN 'MEDIUM'
ELSE 'HIGH - Good utilization'
END AS utilization_assessment
FROM TABLE(WAREHOUSE_LOAD_HISTORY(
DATE_RANGE_START => DATEADD('day', -7, CURRENT_DATE()),
DATE_RANGE_END => CURRENT_DATE()
))
GROUP BY 1, 2
ORDER BY credits_used DESC;
Cost Optimization Checklist
| Category | Action | Potential Savings |
|---|---|---|
| Compute | Set auto-suspend to 60-300 seconds | 20-40% |
| Compute | Right-size warehouses based on query patterns | 15-30% |
| Compute | Use scaling policies (ECONOMY) for non-critical workloads | 10-20% |
| Compute | Schedule ETL during off-peak hours | 10-15% |
| Storage | Reduce Time Travel retention for non-critical databases | 5-15% |
| Storage | Drop unused tables and stages | 5-10% |
| Storage | Use TRANSIENT tables where appropriate | 5-10% |
| Transfer | Use same-region storage locations | 100% transfer savings |
| Transfer | Minimize data egress with in-database transformations | Varies |
| Serverless | Monitor and limit Snowpipe usage | 5-10% |
| Serverless | Review Search Optimization costs vs benefit | Varies |
Common Cost Mistakes
| Mistake | Impact | Solution |
|---|---|---|
| Leaving warehouses running 24/7 | Maximum credit burn | Set auto-suspend to 60-300s |
| Using oversized warehouses | Paying for unused capacity | Monitor and right-size regularly |
| No resource monitors set | No visibility into spending | Create monitors with quotas |
| Excessive Time Travel retention | Higher storage costs | Reduce to business requirement |
| Running queries on XL warehouse for simple lookups | Wasted credits on small queries | |
| Not using query results caching | Re-running identical queries | Enable result caching, review cache hits |
| Ignoring cloud services costs | 10% of credits can accumulate | Monitor CLOUD_SERVICES credits |
See Also
- Architecture - Understand the architecture driving cost components
- Warehouse Management - Configure warehouses for optimal cost-performance
- Monitoring - Track costs and usage with monitoring views
- Optimization - Optimize queries to reduce compute costs