Cloud Warehouse · Cost Optimization · Snowflake · BigQuery · Guide + 25 Interview Questions

Cloud Warehouse Query Cost Optimization: Snowflake, BigQuery & Redshift

Cloud data warehouses like Snowflake, BigQuery, and Redshift charge based on compute and storage. Query cost optimization reduces these costs through better query design, clustering, partitioning, query pruning, caching, and materialized views. This guide covers the cost models of major cloud warehouses, optimization techniques, and the 25 interview questions that actually come up — with deep, descriptive theory aligned to the topic.

🎯 Key Takeaways
25 Interview Questions Beginner to Advanced Snowflake, BigQuery, Redshift Updated Dec 3, 2026
Kailas Warade ✓ Verified Author
Data Engineer · Oracle Certified · SQL & PL/SQL
Kailas works with SQL, PL/SQL, Python, and PySpark to build data pipelines. He writes the SQL interview guides at Sankalan Data Tech, focused on practical, real-world answers.
🏆 Oracle Certified 💼 Data Engineer 📝 SQL & PL/SQL Guides 📍 Pune, India
📤 Share:

On This Page

What Cost Optimization Really Is

Cloud data warehouse cost optimization is the practice of reducing query and storage costs in cloud data warehouses like Snowflake, BigQuery, and Redshift.

-- Cost optimization levers
Query design → Clustering → Partitioning → Caching → Materialized views

The core insight is that cloud warehouses charge based on usage — compute time, bytes scanned, or slots used. Reducing usage reduces cost.

Cost optimization is not just about writing faster queries. It is about writing queries that scan less data, use less compute, and leverage caching.

Cost optimization is a critical skill for data engineers working with cloud warehouses, where costs can escalate quickly.

Cloud Warehouse Pricing Models

Each cloud warehouse has a different pricing model.

Warehouse Compute Pricing Storage Pricing
Snowflake Warehouse compute time Storage used
BigQuery Bytes scanned or slots Storage used
Redshift Node hours Storage used

Snowflake charges based on warehouse compute time — larger warehouses cost more per second.

BigQuery charges based on bytes scanned or slots used — reducing bytes scanned reduces cost.

Redshift charges based on node hours — smaller clusters cost less.

Understanding the pricing model is the first step to cost optimization.

Query Pruning in Depth

Query pruning is the ability of a warehouse to skip reading irrelevant data based on filters.

-- Query with filter enables pruning
SELECT *
FROM sales
WHERE order_date = '2026-12-01';
-- Only scans relevant partition/cluster

Query pruning is the single biggest cost optimization lever. If a query only needs 1% of the data, pruning ensures only 1% is scanned.

Pruning works through partitioning, clustering, and zone maps.

Always include filters on partition/cluster columns to enable pruning.

Clustering in Depth

Clustering in Snowflake organizes data within a table based on one or more columns.

-- Clustering in Snowflake
CREATE TABLE sales (
    order_date DATE,
    amount DECIMAL
) CLUSTER BY (order_date);

Clustering improves query pruning by co-locating related data. Queries filtering on the cluster key scan less data.

Clustering is automatic in Snowflake — it re-clusters as needed.

Choose cluster keys based on common query filters.

Partitioning in Depth

Partitioning in BigQuery divides a table into segments based on a column (like date).

-- Partitioning in BigQuery
CREATE TABLE sales (
    order_date DATE,
    amount DECIMAL
)
PARTITION BY DATE(order_date);

Partitioning enables query pruning by allowing queries to scan only relevant partitions.

Partitioning is explicit in BigQuery — you must define it at table creation.

Choose partition keys based on common query filters, usually date.

Caching in Depth

Caching stores query results or data in memory to speed up repeated queries.

-- Cached query: same query, faster and cheaper
SELECT * FROM sales WHERE order_date = '2026-12-01';
-- Second run: cached, faster and cheaper

Caching is automatic in most cloud warehouses. Repeated queries hit the cache and cost less.

Cache is invalidated when underlying data changes.

Caching is a free cost optimization — just structure queries to leverage it.

Materialized Views

A materialized view is a pre-computed result set stored physically.

-- Materialized view
CREATE MATERIALIZED VIEW mv_daily_sales AS
SELECT order_date, SUM(amount) AS total
FROM sales
GROUP BY order_date;

Materialized views improve query performance and reduce cost for repeated queries.

Materialized views must be refreshed when underlying data changes.

Materialized views are ideal for expensive, frequently-run aggregations.

25 Cloud Warehouse Cost Optimization Interview Questions and Answers

These are the cloud warehouse cost optimization questions that come up most often in data engineering interviews. Every answer stands on its own — read them in any order, or work through them in sequence to build a complete understanding of cost optimization, query pruning, clustering, partitioning, caching, and materialized views.

🔍

No matching questions found

Try a keyword like Snowflake, BigQuery, clustering, or pruning.

Cloud warehouse cost optimization is the practice of reducing query and storage costs in cloud data warehouses.

-- Cost optimization levers
Query design → Clustering → Partitioning → Caching

The core insight is that cloud warehouses charge based on usage. Reducing usage reduces cost.

Cost optimization is critical for data engineers working with cloud warehouses.

Query pruning is the ability of a warehouse to skip reading irrelevant data based on filters.

SELECT *
FROM sales
WHERE order_date = '2026-12-01';
-- Only scans relevant partition

Query pruning is the single biggest cost optimization lever.

It works through partitioning, clustering, and zone maps.

Clustering in Snowflake organizes data within a table based on one or more columns.

CREATE TABLE sales (
    order_date DATE,
    amount DECIMAL
) CLUSTER BY (order_date);

Clustering improves query pruning by co-locating related data.

Clustering is automatic in Snowflake.

Partitioning in BigQuery divides a table into segments based on a column.

CREATE TABLE sales (
    order_date DATE,
    amount DECIMAL
)
PARTITION BY DATE(order_date);

Partitioning enables query pruning by allowing queries to scan only relevant partitions.

Partitioning is explicit in BigQuery.

Partitioning divides a table into physical segments. Clustering organizes data within segments.

Aspect Partitioning Clustering
What it does Divides into segments Organizes within segments
Granularity Coarse Fine
Example By date By customer within date

Both improve query pruning. Use both for best results.

A warehouse in Snowflake is a compute cluster that executes queries.

-- Warehouse sizes
X-Small, Small, Medium, Large, X-Large

Cost is based on warehouse size and runtime.

Larger warehouses cost more per second but may finish faster.

A slot in BigQuery is a unit of computational capacity used to execute queries.

-- Slot-based pricing
Slots: 100, 500, 1000, etc.

Cost can be based on slots or bytes scanned.

Slot-based pricing is better for predictable, high-volume workloads.

Caching stores query results or data in memory to speed up repeated queries.

-- Cached query
SELECT * FROM sales WHERE order_date = '2026-12-01';
-- Second run: cached, faster and cheaper

Caching is automatic in most cloud warehouses.

Cache is invalidated when underlying data changes.

A materialized view is a pre-computed result set stored physically.

CREATE MATERIALIZED VIEW mv_daily_sales AS
SELECT order_date, SUM(amount) AS total
FROM sales
GROUP BY order_date;

Materialized views improve performance and reduce cost for repeated queries.

They must be refreshed when underlying data changes.

A view is a stored query executed on demand. A materialized view is a pre-computed result stored physically.

Aspect View Materialized View
Storage Query only Pre-computed result
Performance Slower Faster
Freshness Always current May be stale

Materialized views trade freshness for performance.

Reduce cost in Snowflake by using appropriate warehouse size, clustering, query pruning, caching, and avoiding SELECT *.

-- Cost optimization in Snowflake
-- 1. Right-size warehouse
-- 2. Cluster on filter columns
-- 3. Use filters for pruning
-- 4. Avoid SELECT *

Snowflake charges based on warehouse compute time, so reducing runtime reduces cost.

Reduce cost in BigQuery by using partitioning, clustering, query pruning, and avoiding SELECT *.

-- Cost optimization in BigQuery
-- 1. Partition on date
-- 2. Cluster on filter columns
-- 3. Use filters for pruning
-- 4. Avoid SELECT *

BigQuery charges based on bytes scanned, so reducing bytes scanned reduces cost.

Reduce cost in Redshift by using appropriate node size, sort keys, distribution keys, and query optimization.

-- Cost optimization in Redshift
-- 1. Right-size cluster
-- 2. Use sort keys
-- 3. Use distribution keys
-- 4. Optimize queries

Redshift charges based on node hours, so reducing runtime reduces cost.

Snowflake charges based on warehouse compute time. BigQuery charges based on bytes scanned or slots used.

-- Snowflake: compute time
-- BigQuery: bytes scanned or slots

The pricing model affects optimization strategy.

A query profile shows how a query was executed, including time spent, data scanned, and operators used.

-- Query profile shows
Time, data scanned, operators, bottlenecks

Query profiles help identify cost optimization opportunities.

They are the starting point for optimization.

A partitioned table divides data into segments. A clustered table organizes data within segments.

-- Partitioned: by date
-- Clustered: by customer within date

Use both for best pruning.

A materialized view is a pre-computed result from a query. A table is a base storage structure.

-- Table: base data
-- Materialized view: pre-computed from table

Materialized views are derived from tables.

A cached query is a temporary in-memory result. A materialized view is a permanent physical result.

-- Cached query: temporary, in-memory
-- Materialized view: permanent, physical

Cached queries are automatic. Materialized views are explicit.

Snowflake is a cloud-native, multi-cloud warehouse. Redshift is AWS-specific.

-- Snowflake: multi-cloud, separate compute/storage
-- Redshift: AWS-specific, integrated compute/storage

Snowflake separates compute and storage. Redshift integrates them.

BigQuery is serverless and charges per query. Snowflake uses warehouses and charges per compute time.

-- BigQuery: serverless, per query
-- Snowflake: warehouses, per compute time

BigQuery is simpler for sporadic queries. Snowflake is better for continuous workloads.

A sort key orders data within a node. A distribution key distributes data across nodes.

-- Sort key: orders data within node
-- Distribution key: distributes across nodes

Both improve query performance in Redshift.

A cluster key organizes data within a table. A partition key divides a table into segments.

-- Cluster key: within table
-- Partition key: divides table

Both improve query pruning.

A query is a single SQL statement. A job is a broader unit that can include multiple queries, transformations, and steps.

-- Query: single SQL
-- Job: multiple queries/steps

Jobs are common in data pipelines.

A query is a SQL statement. A report is a formatted presentation of query results.

-- Query: SQL statement
-- Report: formatted presentation

Reports are built on queries.

Well-designed cost optimization follows a few key principles.

  • Use partitioning/clustering — for query pruning.
  • Avoid SELECT * — scan only needed columns.
  • Use filters — enable pruning.
  • Use caching — for repeated queries.
  • Use materialized views — for expensive aggregations.
  • Monitor cost — identify and fix expensive queries.
-- Well-designed query
SELECT order_date, SUM(amount)
FROM sales
WHERE order_date = '2026-12-01'
GROUP BY order_date;

These principles produce queries that are fast and cheap.

Mistakes I Keep Seeing in Interviews

These come up repeatedly. None of them are exotic, and every one of them is easy to avoid once you know it is coming.

Mistake one: not understanding the pricing model. Each warehouse charges differently, and optimization strategy depends on it.
Mistake two: confusing clustering with partitioning. They are related but different — know the difference.
Mistake three: using SELECT *. This scans all columns, increasing cost.
Mistake four: not using filters. Filters enable pruning, which reduces cost.
Mistake five: not using caching. Repeated queries should hit the cache.
Mistake six: not monitoring cost. Without monitoring, expensive queries go unnoticed.

Follow-Up Questions Interviewers Ask

Getting the first answer right is only half the interview. What usually decides the outcome is what happens next. Here is what to prepare for on the cost optimization topic.

After “What is cost optimization?” — expect

  • “What is the pricing model of Snowflake/BigQuery/Redshift?”
  • “What is query pruning?”
  • “What is clustering?”
  • “What is partitioning?”

After “Query pruning” — expect

  • “How does pruning work?”
  • “What enables pruning?”
  • “How do you measure pruning?”
  • “What is a zone map?”

After “Clustering” — expect

  • “How does clustering work?”
  • “How do you choose cluster keys?”
  • “What is automatic clustering?”
  • How does clustering affect cost?”

After “Materialized views” — expect

  • “What is the difference from a view?”
  • “How do you refresh?”
  • “When would you use one?”
  • “What are the trade-offs?”

For every question above, prepare a second-level answer. The candidates who pass are not the ones who memorized the first answer — they are the ones who kept going for another thirty seconds and said something useful about why it matters.

Quick Quiz

Five questions to check whether the topics above have landed.

1. What is the biggest cost optimization lever in cloud warehouses?
2. What does Snowflake charge based on?
3. What does BigQuery charge based on?
4. What is the difference between a view and a materialized view?
5. What should you avoid to reduce cost?