🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Snowflake Cost Management and Optimization

đŸŸĸ Free Lesson

Advertisement

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.

Snowflake Cost Components & OptimizationComputeWarehouse CreditsStorageData + Time TravelTransferCross-Region/EgressServerlessSnowpipe, SearchAlertsBudget LimitsAuto-Suspend WarehousesReduce idle compute costsRight-Size WarehousesMatch size to workloadUse Resource MonitorsSet credit quotasCost = Compute (credits) + Storage (TB) + Transfer (GB) + Serverless
Cost Optimization Decision TreeHigh Compute?Right-Size WHAuto-SuspendHigh Storage?Reduce TTUse Scaling PolicySet Resource MonitorReview Query PatternsMonitor daily via ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY

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 SizeCredits per HourCredits per MinuteTypical Use Case
X-Small10.0167Dev/Test, light queries
Small20.0333Standard analytics
Medium40.0667Complex BI queries
Large80.1333Data engineering
X-Large160.2667Large transformations
2X-Large320.5333Heavy ETL workloads
3X-Large641.0667Enterprise workloads
4X-Large1282.1333Maximum 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

CategoryActionPotential Savings
ComputeSet auto-suspend to 60-300 seconds20-40%
ComputeRight-size warehouses based on query patterns15-30%
ComputeUse scaling policies (ECONOMY) for non-critical workloads10-20%
ComputeSchedule ETL during off-peak hours10-15%
StorageReduce Time Travel retention for non-critical databases5-15%
StorageDrop unused tables and stages5-10%
StorageUse TRANSIENT tables where appropriate5-10%
TransferUse same-region storage locations100% transfer savings
TransferMinimize data egress with in-database transformationsVaries
ServerlessMonitor and limit Snowpipe usage5-10%
ServerlessReview Search Optimization costs vs benefitVaries

Common Cost Mistakes

MistakeImpactSolution
Leaving warehouses running 24/7Maximum credit burnSet auto-suspend to 60-300s
Using oversized warehousesPaying for unused capacityMonitor and right-size regularly
No resource monitors setNo visibility into spendingCreate monitors with quotas
Excessive Time Travel retentionHigher storage costsReduce to business requirement
Running queries on XL warehouse for simple lookupsWasted credits on small queries
Not using query results cachingRe-running identical queriesEnable result caching, review cache hits
Ignoring cloud services costs10% of credits can accumulateMonitor CLOUD_SERVICES credits

See Also

Need Expert Snowflake Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement