Home Database Cost Optimization: Managing Credits, Warehouses, and Storage
Advanced 3 min · July 17, 2026

Cost Optimization: Managing Credits, Warehouses, and Storage

Master Snowflake cost optimization with practical strategies for managing credits, warehouses, and storage.

N
Naren Founder & Principal Engineer

20+ years shipping high-throughput database systems. Notes here come from systems that actually shipped.

Follow
Production
production tested
July 17, 2026
last updated
2,439
articles · all by Naren
Before you start⏱ 15-20 min read
  • 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.
 ● Production Incident 🔎 Debug Guide ⚙ Triage Commands
Quick Answer
  • 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.
✦ Definition~90s read
What is Cost Optimization?

Snowflake cost optimization is the practice of managing compute credits, warehouse configurations, and storage to minimize your Snowflake bill while maintaining performance.

Think of Snowflake like a cloud kitchen.
Plain-English First

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).

⚙ Browser compatibility
Latest versions — ✓ supported
ChromeFirefoxSafariEdge

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.

cost_breakdown.sqlSQL
1
2
3
4
5
6
7
8
9
-- View credit usage by warehouse
SELECT WAREHOUSE_NAME,
       SUM(CREDITS_USED) AS total_credits,
       SUM(CREDITS_USED_COMPUTE) AS compute_credits,
       SUM(CREDITS_USED_CLOUD_SERVICES) AS cloud_credits
FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
WHERE START_TIME >= DATEADD('month', -1, CURRENT_TIMESTAMP)
GROUP BY WAREHOUSE_NAME
ORDER BY total_credits DESC;
Output
+-----------------+--------------+----------------+--------------+
| WAREHOUSE_NAME | total_credits| compute_credits| cloud_credits|
+-----------------+--------------+----------------+--------------+
| ANALYTICS_WH | 1200.5| 1180.2| 20.3|
| LOADING_WH | 800.1| 790.0| 10.1|
+-----------------+--------------+----------------+--------------+
🔥Cloud Services Credits
📊 Production Insight
Always use ACCOUNT_USAGE views for billing accuracy; they have a 2-hour delay but are authoritative.
🎯 Key Takeaway
Know your credit consumption per warehouse to identify the biggest cost drivers.

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.

create_optimized_warehouse.sqlSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Create an optimized warehouse for ad-hoc queries
CREATE WAREHOUSE ad_hoc_wh
  WAREHOUSE_SIZE = 'SMALL'
  AUTO_SUSPEND = 300
  AUTO_RESUME = TRUE
  MIN_CLUSTER_COUNT = 1
  MAX_CLUSTER_COUNT = 2
  SCALING_POLICY = 'ECONOMY'
  INITIALLY_SUSPENDED = TRUE;

-- Set a resource monitor to limit monthly credits
CREATE RESOURCE MONITOR monthly_cap
  WITH CREDIT_QUOTA = 500
  FREQUENCY = 'MONTHLY'
  START_TIMESTAMP = '2025-01-01 00:00:00'
  END_TIMESTAMP = '2025-12-31 23:59:59'
  NOTIFY_USERS = (admin@example.com)
  TRIGGERS ON 80 PERCENT DO NOTIFY
           ON 100 PERCENT DO SUSPEND;
Output
Warehouse AD_HOC_WH successfully created.
Resource Monitor MONTHLY_CAP successfully created.
💡Economy vs. Standard Scaling
📊 Production Insight
For production ETL, consider using a dedicated warehouse with auto-suspend disabled only during the load window, then suspend manually.
🎯 Key Takeaway
Right-size warehouses and set auto-suspend/resume to avoid paying for idle compute.

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).

storage_optimization.sqlSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
-- Check storage usage by table
SELECT TABLE_CATALOG,
       TABLE_SCHEMA,
       TABLE_NAME,
       ACTIVE_BYTES / (1024*1024*1024) AS active_gb,
       TIME_TRAVEL_BYTES / (1024*1024*1024) AS time_travel_gb,
       FAILSAFE_BYTES / (1024*1024*1024) AS failsafe_gb
FROM SNOWFLAKE.ACCOUNT_USAGE.TABLE_STORAGE_METRICS
ORDER BY active_gb DESC
LIMIT 10;

-- Reduce time travel retention for a staging table
ALTER TABLE staging.raw_events SET DATA_RETENTION_TIME_IN_DAYS = 1;
Output
+--------------+------------+------------+-----------+---------------+-------------+
| TABLE_CATALOG| TABLE_SCHEMA| TABLE_NAME | active_gb | time_travel_gb| failsafe_gb|
+--------------+------------+------------+-----------+---------------+-------------+
| PROD | PUBLIC | ORDERS | 50.2 | 10.1 | 7.0|
| PROD | STAGING | RAW_EVENTS | 30.5 | 6.0 | 4.2|
+--------------+------------+------------+-----------+---------------+-------------+
⚠ Time Travel and Fail-safe Costs
📊 Production Insight
Use CLUSTERING KEY on large tables (e.g., date) to improve query performance and reduce storage overhead from micro-partition pruning.
🎯 Key Takeaway
Monitor storage per table and adjust retention policies to minimize costs.

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.

mv_and_clustering.sqlSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
-- Create a materialized view for daily sales summary
CREATE MATERIALIZED VIEW daily_sales_mv AS
SELECT DATE_TRUNC('day', order_date) AS day,
       SUM(amount) AS total_sales,
       COUNT(*) AS order_count
FROM orders
GROUP BY day;

-- Set clustering key on orders table
ALTER TABLE orders CLUSTER BY (order_date);

-- Check clustering status
SELECT * FROM TABLE(INFORMATION_SCHEMA.CLUSTERING_INFORMATION('orders'));
Output
Materialized view DAILY_SALES_MV successfully created.
Table ORDERS altered.
+----------------+----------------+----------------+----------------+
| CLUSTERING_KEY | TOTAL_PARTITIONS| AVERAGE_DEPTH | CLUSTERING_RATIO|
+----------------+----------------+----------------+----------------+
| (ORDER_DATE) | 1000 | 1.2 | 0.95|
+----------------+----------------+----------------+----------------+
🔥MV Maintenance Cost
📊 Production Insight
For real-time dashboards, consider using a streaming service (e.g., Kafka) to update MVs incrementally instead of full refreshes.
🎯 Key Takeaway
Use MVs and clustering to reduce query compute costs at the expense of storage.

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.

resource_monitor.sqlSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- Create a resource monitor for a warehouse
CREATE RESOURCE MONITOR wh_monitor
  WITH CREDIT_QUOTA = 1000
  FREQUENCY = 'MONTHLY'
  START_TIMESTAMP = '2025-01-01 00:00:00'
  END_TIMESTAMP = '2025-12-31 23:59:59'
  NOTIFY_USERS = (dba@example.com)
  TRIGGERS ON 80 PERCENT DO NOTIFY
           ON 100 PERCENT DO SUSPEND_IMMEDIATE;

-- Assign monitor to warehouse
ALTER WAREHOUSE my_wh SET RESOURCE_MONITOR = wh_monitor;

-- Check monitor history
SELECT * FROM SNOWFLAKE.ACCOUNT_USAGE.RESOURCE_MONITORS;
Output
Resource Monitor WH_MONITOR successfully created.
Warehouse MY_WH altered.
+------------------+--------------+------------+------------+
| NAME | CREDIT_QUOTA | USED_CREDITS| STATUS |
+------------------+--------------+------------+------------+
| WH_MONITOR | 1000 | 200 | ACTIVE |
+------------------+--------------+------------+------------+
💡Multiple Triggers
📊 Production Insight
For development accounts, set a low credit quota (e.g., 100) with suspend to encourage developers to optimize.
🎯 Key Takeaway
Resource monitors prevent surprise bills by automatically suspending warehouses when quotas are exceeded.

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.

query_optimization.sqlSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
-- Profile a query to see scanned bytes
SELECT QUERY_ID,
       TOTAL_ELAPSED_TIME,
       BYTES_SCANNED,
       BYTES_WRITTEN,
       CREDITS_USED_CLOUD_SERVICES
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE QUERY_TEXT LIKE '%SELECT * FROM orders%'
ORDER BY START_TIME DESC
LIMIT 5;

-- Enable result caching (default on)
ALTER SESSION SET USE_CACHED_RESULT = TRUE;
Output
+----------+-------------------+--------------+--------------+----------------------+
| QUERY_ID | TOTAL_ELAPSED_TIME| BYTES_SCANNED| BYTES_WRITTEN| CREDITS_USED_CLOUD_SERV|
+----------+-------------------+--------------+--------------+----------------------+
| 12345 | 12000 | 1073741824 | 0 | 0.05|
+----------+-------------------+--------------+--------------+----------------------+
⚠ Result Caching Pitfall
📊 Production Insight
Set a query timeout (e.g., 1 hour) to prevent runaway queries from consuming unlimited credits.
🎯 Key Takeaway
Profile and rewrite expensive queries to reduce bytes scanned and credits used.

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.

automation.sqlSQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Create a task to suspend all warehouses at 10 PM daily
CREATE TASK suspend_warehouses
  WAREHOUSE = admin_wh
  SCHEDULE = 'USING CRON 0 22 * * * America/New_York'
AS
  ALTER WAREHOUSE my_wh SUSPEND;
  -- Add more ALTER statements for other warehouses

-- Create a stored procedure to drop old partitions
CREATE OR REPLACE PROCEDURE drop_old_partitions(table_name STRING, retention_days INT)
RETURNS STRING
LANGUAGE SQL
AS
$$
  DECLARE
    drop_stmt STRING;
  BEGIN
    drop_stmt := 'ALTER TABLE ' || table_name || ' DROP PARTITION IF EXISTS (date < DATEADD(day, -' || retention_days || ', CURRENT_DATE))';
    EXECUTE IMMEDIATE drop_stmt;
    RETURN 'Old partitions dropped';
  END;
$$;
Output
Task SUSPEND_WAREHOUSES successfully created.
Stored procedure DROP_OLD_PARTITIONS successfully created.
🔥Task Scheduling
📊 Production Insight
Combine tasks with resource monitors for a fully automated cost governance system.
🎯 Key Takeaway
Automate routine cost-saving actions to ensure they happen consistently.
● Production incidentPOST-MORTEMseverity: high

The $10,000 Overnight Warehouse

Symptom
The finance team noticed a $10,000 spike in Snowflake costs for a single weekend.
Assumption
The developer assumed the warehouse would auto-suspend after 10 minutes of inactivity.
Root cause
The warehouse was set to 'always resume' and had a minimum of 5 clusters, each XL, running 24/7.
Fix
Set auto-suspend to 5 minutes, reduced max clusters to 2, and implemented a resource monitor with 50% alert.
Key lesson
  • 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.
Production debug guideSymptom to Action3 entries
Symptom · 01
Unexpectedly high credit usage
Fix
Check WAREHOUSE_METERING_HISTORY and identify warehouses with high average credits per hour.
Symptom · 02
Storage costs increasing rapidly
Fix
Query STORAGE_USAGE to find large tables, then review time travel retention and clustering.
Symptom · 03
Queries running longer than expected
Fix
Check QUERY_HISTORY for heavy scans, missing filters, or poorly clustered tables.
★ Quick Debug Cheat SheetImmediate actions for common cost issues.
Warehouse never suspends
Immediate action
Check auto_suspend setting
Commands
SHOW WAREHOUSES;
ALTER WAREHOUSE my_wh SET AUTO_SUSPEND = 300;
Fix now
Set auto_suspend to 300 seconds.
High storage costs+
Immediate action
Check time travel retention
Commands
SHOW TABLES;
ALTER TABLE my_table SET DATA_RETENTION_TIME_IN_DAYS = 1;
Fix now
Reduce retention to 1 day for non-critical tables.
Credit spike from multi-cluster+
Immediate action
Check max_cluster_count
Commands
SHOW WAREHOUSES;
ALTER WAREHOUSE my_wh SET MAX_CLUSTER_COUNT = 2;
Fix now
Limit max clusters to 2.
FeatureCost ImpactBest Use Case
Auto-suspendReduces compute creditsInteractive and ad-hoc warehouses
Multi-clusterIncreases compute creditsHigh concurrency workloads
Time travel retentionIncreases storage costsData recovery needs
Materialized viewsReduces compute, increases storageFrequent aggregations on large tables
Clustering keysReduces compute, minimal storageLarge tables with selective queries
⚙ Quick Reference
7 commands from this guide
FileCommand / CodePurpose
cost_breakdown.sqlSELECT WAREHOUSE_NAME,Understanding Snowflake's Pricing Model
create_optimized_warehouse.sqlCREATE WAREHOUSE ad_hoc_whOptimizing Warehouse Configuration
storage_optimization.sqlSELECT TABLE_CATALOG,Reducing Storage Costs
mv_and_clustering.sqlCREATE MATERIALIZED VIEW daily_sales_mv ASLeveraging Materialized Views and Clustering
resource_monitor.sqlCREATE RESOURCE MONITOR wh_monitorMonitoring and Alerting with Resource Monitors
query_optimization.sqlSELECT QUERY_ID,Query Optimization to Reduce Compute
automation.sqlCREATE TASK suspend_warehousesAutomating Cost Governance with Tasks and Stored Procedures

Key takeaways

1
Monitor credit usage per warehouse and set resource monitors to cap spending.
2
Optimize warehouse configuration
auto-suspend, right-size, and limit multi-cluster.
3
Reduce storage costs by lowering time travel retention and using transient tables.
4
Use materialized views and clustering to trade storage for compute savings.
5
Automate cost governance with tasks and stored procedures.

Common mistakes to avoid

3 patterns
×

Leaving warehouses running 24/7

×

Using XL warehouses for small queries

×

Ignoring storage costs from time travel

INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

Q01JUNIOR
Explain how Snowflake's pricing model works.
Q02SENIOR
How would you reduce the cost of a warehouse that is used for ad-hoc que...
Q03SENIOR
Describe a scenario where using a materialized view might increase costs...
Q01 of 03JUNIOR

Explain how Snowflake's pricing model works.

ANSWER
Snowflake charges for compute (credits per warehouse per hour), storage (per TB per month for compressed data), and cloud services (metadata, etc.). Credits are consumed when warehouses are running.
FAQ · 5 QUESTIONS

Frequently Asked Questions

01
What is the difference between auto-suspend and auto-resume?
02
How do I find which queries are consuming the most credits?
03
Can I set a hard limit on monthly spending?
04
What is the best warehouse size for ETL?
05
How does time travel affect storage costs?
N
Naren Founder & Principal Engineer

20+ years shipping high-throughput database systems. Notes here come from systems that actually shipped.

Follow
Verified
production tested
July 17, 2026
last updated
2,439
articles · all by Naren
🔥

That's Snowflake. Mark it forged?

3 min read · try the examples if you haven't

Previous
Query Optimization: Clustering Keys, Search Optimization, and Profiling
12 / 33 · Snowflake
Next
Semi-Structured Data: JSON, Parquet, Avro, and VARIANT