Cost Optimization: Managing Credits, Warehouses, and Storage
Master Snowflake cost optimization with practical strategies for managing credits, warehouses, and storage.
20+ years shipping high-throughput database systems. Notes here come from systems that actually shipped.
- ✓Basic SQL knowledge (SELECT, CREATE, ALTER).
- ✓Access to a Snowflake account with ACCOUNTADMIN or similar privileges.
- ✓Familiarity with Snowflake's web interface or SnowSQL CLI.
- Use auto-suspend and auto-resume to avoid paying for idle warehouses.
- Choose the right warehouse size and multi-cluster settings for workload patterns.
- Leverage materialized views and clustering to reduce storage and query costs.
- Monitor credit usage with ACCOUNT_USAGE views and set resource monitors.
- Compress and purge old data to minimize storage costs.
Think of Snowflake like a cloud kitchen. You pay for the ingredients (storage) and the chefs (warehouses). If you keep chefs idle, you waste money. So you only call chefs when orders come in (auto-suspend), and you choose the right number of chefs based on how busy you are (multi-clustering). Also, you store leftovers efficiently (compression) and throw away expired ingredients (time travel).
| Chrome | Firefox | Safari | Edge |
|---|---|---|---|
| ✓ | ✓ | ✓ | ✓ |
Snowflake's pay-as-you-go model is a double-edged sword. While it offers elasticity and near-zero maintenance, runaway costs are a common pain point for teams. A single misconfigured warehouse can burn thousands of dollars per month. This tutorial dives deep into the three pillars of Snowflake cost: credits, warehouses, and storage. You'll learn how to monitor usage, set guardrails, and optimize each component. By the end, you'll have a production-ready cost optimization playbook that can reduce your bill by 30-50% without sacrificing performance.
Understanding Snowflake's Pricing Model
Snowflake charges for compute (credits), storage (per TB per month), and cloud services (metadata, etc.). Compute credits are consumed by virtual warehouses (clusters) while they are running. Storage costs are for compressed data, including time travel and fail-safe. Cloud services are usually <10% of total. The key to optimization is minimizing active warehouse time and storage footprint. For example, a Medium warehouse (4 credits/hour) running 24/7 costs ~2,880 credits/month. At $2/credit, that's $5,760. With auto-suspend after 5 minutes of idle, you might only pay for 8 hours/day, reducing cost to ~$1,920.
Optimizing Warehouse Configuration
Warehouses are the main cost driver. Key settings: size (X-Small to 6X-Large), auto-suspend (seconds of idle before shutdown), auto-resume (start on query), and multi-cluster (up to 10 clusters). Best practices: Use X-Small for development, Small/Medium for ETL, Large+ for heavy analytics. Set auto-suspend to 300 seconds (5 min) for interactive, 60 seconds for automated. For multi-cluster, start with 1 and increase only if queuing occurs. Use resource monitors to cap credit usage per warehouse or account.
Reducing Storage Costs
Storage costs are driven by compressed data size, time travel (7 days default, up to 90), and fail-safe (7 days). To reduce: compress data before loading (Snowflake does this automatically), drop unnecessary tables, reduce time travel retention for non-critical tables, and use clustering keys to improve pruning (which reduces storage overhead from micro-partitions). Also, consider using transient or temporary tables for intermediate data (no fail-safe).
Leveraging Materialized Views and Clustering
Materialized views (MVs) pre-compute and store results, reducing query compute costs. They are ideal for aggregations on large tables. However, MVs incur storage and maintenance costs. Use them when queries are frequent and the underlying data changes slowly. Clustering keys physically order data in micro-partitions, improving query performance and reducing credits spent on scanning. Both features trade storage for compute savings.
Monitoring and Alerting with Resource Monitors
Resource monitors are the first line of defense against cost overruns. They can be set at account, warehouse, or user level. You can define credit quotas and actions (notify, suspend, abort) when thresholds are reached. Best practice: set a monthly account-level monitor with 80% notify and 100% suspend. Also, set warehouse-level monitors for critical warehouses. Use the ACCOUNT_USAGE views to build custom dashboards.
Query Optimization to Reduce Compute
Poorly written queries waste credits. Use query profiling to identify heavy scans, missing filters, and inefficient joins. Enable result caching to avoid re-executing identical queries. Use automatic clustering and search optimization for faster scans. Also, consider using the 'USE_CACHED_RESULT' session parameter. For long-running queries, break them into smaller batches or use incremental materialization.
Automating Cost Governance with Tasks and Stored Procedures
Use Snowflake tasks and stored procedures to automate cost management. For example, schedule a task to suspend idle warehouses after hours, or to drop old partitions. You can also automate the creation of resource monitors for new warehouses. This reduces manual overhead and ensures consistent governance.
The $10,000 Overnight Warehouse
- Always set auto-suspend (5-10 min) for non-critical warehouses.
- Use resource monitors to alert on unusual credit consumption.
- Limit warehouse size and multi-cluster settings to match actual workload.
- Review warehouse configurations quarterly.
SHOW WAREHOUSES;ALTER WAREHOUSE my_wh SET AUTO_SUSPEND = 300;| File | Command / Code | Purpose |
|---|---|---|
| cost_breakdown.sql | SELECT WAREHOUSE_NAME, | Understanding Snowflake's Pricing Model |
| create_optimized_warehouse.sql | CREATE WAREHOUSE ad_hoc_wh | Optimizing Warehouse Configuration |
| storage_optimization.sql | SELECT TABLE_CATALOG, | Reducing Storage Costs |
| mv_and_clustering.sql | CREATE MATERIALIZED VIEW daily_sales_mv AS | Leveraging Materialized Views and Clustering |
| resource_monitor.sql | CREATE RESOURCE MONITOR wh_monitor | Monitoring and Alerting with Resource Monitors |
| query_optimization.sql | SELECT QUERY_ID, | Query Optimization to Reduce Compute |
| automation.sql | CREATE TASK suspend_warehouses | Automating Cost Governance with Tasks and Stored Procedures |
Key takeaways
Common mistakes to avoid
3 patternsLeaving warehouses running 24/7
Using XL warehouses for small queries
Ignoring storage costs from time travel
Interview Questions on This Topic
Explain how Snowflake's pricing model works.
Frequently Asked Questions
20+ years shipping high-throughput database systems. Notes here come from systems that actually shipped.
That's Snowflake. Mark it forged?
3 min read · try the examples if you haven't