How to Estimate Snowflake Pricing in PostgreSQL

Galaxy Glossary

How is Snowflake pricing calculated and reduced?

Snowflake pricing is a pay-as-you-go model based on compute credits and data storage, so total cost equals credits × rate + storage × rate.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

What drives Snowflake pricing?

Snowflake charges for two items: compute credits consumed by virtual warehouses and data storage billed per terabyte per month. Optional features like Snowpipe or Search Optimization Service add extra credits.

How many credits does a warehouse consume?

Credits depend on warehouse size. XS uses 1 credit/hour, S = 2, M = 4, L = 8, XL = 16, 2XL = 32. Suspended warehouses stop charging instantly.

How to calculate credits in SQL?

Query SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY to sum credits by warehouse, day, or SQL role.

SELECT DATE_TRUNC('day', start_time) AS usage_day,
warehouse_name,
SUM(credits_used) AS daily_credits
FROM snowflake.account_usage.warehouse_metering_history
WHERE start_time >= DATEADD(day,-30,CURRENT_DATE)
GROUP BY 1,2
ORDER BY 1;

How to translate credits to dollars?

Multiply total credits by your contracted per-credit rate (e.g., US $2.90).

SELECT daily_credits,
daily_credits * 2.90 AS daily_cost_usd
FROM (
-- query above
) q;

How to estimate storage cost?

Storage is billed on average compressed bytes. Use ACCOUNT_USAGE.STORAGE_USAGE.

SELECT usage_date,
average_bytes/POWER(1024,4) AS avg_tb,
avg_tb * 23 AS storage_cost_usd -- $23/TB/mo
FROM snowflake.account_usage.storage_usage
WHERE usage_date >= DATE_TRUNC('month',CURRENT_DATE);

How to allocate cost to ecommerce customers?

Tag queries or warehouses with customer IDs and join to Orders for show-back.

-- Tag warehouse for customer A
ALTER WAREHOUSE wh_cust_a SET TAG customer_id = 'A';

-- Monthly cost per customer via tags
SELECT t.value::text AS customer_id,
SUM(m.credits_used)*2.90 AS cost_usd
FROM snowflake.account_usage.warehouse_metering_history m
JOIN snowflake.account_usage.tag_references_all t
ON m.warehouse_id = t.object_id
WHERE t.tag_name = 'customer_id'
GROUP BY 1;

Best practices to reduce spend?

Auto-suspend warehouses after 60 seconds; auto-resume on demand. Use multi-cluster only for bursty loads. Size down warehouses when queries finish in <10 seconds. Purge unused stages. Compress staged files with GZIP or PARQUET.

Why How to Estimate Snowflake Pricing in PostgreSQL is important

How to Estimate Snowflake Pricing in PostgreSQL Example Usage


-- Allocate monthly Snowflake cost to each customer in an ecommerce platform
WITH wh_cost AS (
  SELECT w.name                                     AS warehouse,
         SUM(m.credits_used) * 2.90                 AS compute_cost
  FROM   snowflake.account_usage.warehouse_metering_history m
  JOIN   snowflake.account_usage.warehouses w
    ON   m.warehouse_id = w.id
  WHERE  DATE_TRUNC('month',m.start_time) = DATE_TRUNC('month',CURRENT_DATE)
  GROUP  BY 1
),
order_map AS (
  SELECT DISTINCT o.customer_id, 'WH_ORDERS' AS warehouse
  FROM   Orders o
)
SELECT c.id          AS customer_id,
       SUM(wh.compute_cost) AS snowflake_cost
FROM   order_map om
JOIN   wh_cost wh ON wh.warehouse = om.warehouse
JOIN   Customers c ON c.id = om.customer_id
GROUP  BY 1;

How to Estimate Snowflake Pricing in PostgreSQL Syntax


-- Compute usage per day
SELECT DATE(start_time) AS usage_day,
       warehouse_name,
       SUM(credits_used) AS credits
FROM   snowflake.account_usage.warehouse_metering_history
GROUP  BY 1,2;

-- Storage usage per month
SELECT usage_date,
       average_bytes/POWER(1024,4) AS terabytes
FROM   snowflake.account_usage.storage_usage;

Common Mistakes

Frequently Asked Questions (FAQs)

Does Snowflake charge while a warehouse is suspended?

No. Credit consumption stops immediately once the warehouse status becomes SUSPENDED.

How can I preview costs before running a query?

Use the ESTIMATE_QUERY_ACCELERATION function or run the query in a smaller warehouse and extrapolate.

Are failed queries billed?

Yes. Credits are charged for the compute time consumed until the error occurred.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.