Snowflake Data Cloud
Module 02 • Under the Hood

Snowflake Internals

Why does one filter make a query 50× faster? Why is there no VACUUM? What happens when an availability zone goes down? You can answer all of these once you understand micro-partitions, the three caches and how Snowflake keeps old versions of data.

~60 min Pruning simulator Recovery playbook
01

Architecture: shared-disk storage with shared-nothing compute

Classic databases are either shared-disk (all nodes read one storage system, which is simple but hits contention) or shared-nothing (each node owns a slice of data, which is fast but makes resizing a data-reshuffling project). Snowflake combines them:

Shared-disk for storage

One central copy of every table in object storage. Any warehouse can read any table, and resizing compute never moves data.

Shared-nothing (MPP) for compute

Inside a warehouse, each node works on its own set of micro-partitions in parallel and caches them on local SSD, like an MPP database.

Analogy

Storage is a library that never closes. Warehouses are study groups. Any number of groups can borrow the same books at once, a bigger group reads faster, and when a group goes home the books stay on the shelf.

02

Micro-partitions: how a table is really stored

Facts to memorise

  • Each micro-partition holds 50–500 MB of uncompressed data, which is much smaller once compressed.
  • Columnar inside: each column is stored and compressed separately, so SELECT a, b reads only columns a and b.
  • Immutable: an UPDATE or DELETE writes new micro-partitions and marks the old ones as no longer current.
  • Created automatically in the order data arrives. You never declare partitions.
  • Cloud Services keeps metadata per micro-partition and column: min/max values, distinct value count, null count and more.

What "pruning" means

Before any warehouse starts work, the optimizer compares your WHERE predicates against each micro-partition's min/max metadata. Any partition that cannot contain a match is skipped entirely and never read.

The Query Profile shows this as Partitions scanned vs Partitions total. Good pruning is the single biggest performance lever in Snowflake.

Pruning breaks when you wrap the filter column in a function the optimizer can't reason about, compare against a sub-query result, or when values are scattered across all partitions.

Pruning simulator
A 24-partition ORDERS table holds one year of data. Change how it was loaded and the date range you query. Highlighted partitions are the ones Snowflake must read. Faded ones were pruned using min/max metadata.
How the data landed
SELECT SUM(amount) FROM orders
WHERE order_date BETWEEN '2026-03-01' AND '2026-03-30';
Partitions scanned
–
Pruned
–
Avg clustering depth
–
lower is better (min 1)

See it in a real account

-- How well is this table organised for a date filter?
SELECT SYSTEM$CLUSTERING_INFORMATION('sales.public.orders', '(order_date)');
-- Returns JSON: total_partition_count, average_overlaps, average_depth,
-- and a histogram of partition depth. Depth near 1 = excellent pruning.

-- After running a query, check pruning in the profile or via SQL:
SELECT query_id, partitions_scanned, partitions_total, bytes_scanned
FROM TABLE(information_schema.query_history())
ORDER BY start_time DESC LIMIT 5;
03

How CPU and memory are used

Snowflake doesn't publish exact node hardware, and it changes over time. The model you need: each warehouse size up doubles the compute resources (CPU, memory and local SSD) and the credit rate. Inside a warehouse:

  1. Work is split by micro-partitionsThe partitions left after pruning are spread across the nodes and their CPU threads. More nodes means more partitions are scanned in parallel, which is why big scans speed up almost linearly with size.
  2. Columnar, vectorised executionOperators process batches of column values at once, which uses CPU caches efficiently. Reading fewer columns means less CPU and I/O.
  3. Memory holds the hard partsHash tables for joins and GROUP BY, sort buffers for ORDER BY and window functions, and data redistributed between nodes during joins.
  4. When memory runs out, it spillsFirst to the node's local SSD (bytes spilled to local storage), then to remote object storage (bytes spilled to remote storage). Remote spilling is very slow. It is the clearest sign a query needs a bigger warehouse or a rewrite.
  5. Concurrent queries share the clusterQueries running at the same time on one cluster split its CPU and memory. Too many heavy ones lead to queuing or spilling, which is the signal to scale out.

The three caches

CacheLives inWhat it storesLifetimeWarehouse needed?
Result cacheCloud ServicesFinal result sets of queries24 h, extended each time it's reused, up to 31 days. Invalidated if the underlying data changes.No
Metadata cacheCloud ServicesRow counts, min/max, partition statisticsAlways currentNo (for COUNT(*), MIN, MAX)
Warehouse (local disk) cacheEach warehouse's SSD and memoryRaw micro-partition column data read from storageUntil the warehouse suspends or is resizedYes

The result cache is only reused if the query text is the same, the data hasn't changed, the query has no functions evaluated at run time such as RANDOM(), UUID_STRING() or CURRENT_TIMESTAMP() (CURRENT_DATE() is the documented exception), and the role has access. To test real performance, turn it off for your session:

ALTER SESSION SET USE_CACHED_RESULT = FALSE;

-- Find queries that spilled (ACCOUNT_USAGE, last 7 days)
SELECT query_id, warehouse_name, warehouse_size,
       bytes_spilled_to_local_storage  / POWER(1024,3) AS gb_local_spill,
       bytes_spilled_to_remote_storage / POWER(1024,3) AS gb_remote_spill,
       total_elapsed_time / 1000 AS seconds
FROM snowflake.account_usage.query_history
WHERE start_time >= DATEADD(day, -7, CURRENT_TIMESTAMP())
  AND bytes_spilled_to_remote_storage > 0
ORDER BY bytes_spilled_to_remote_storage DESC
LIMIT 20;
04

"How do I VACUUM in Snowflake?" You don't.

In Postgres, an UPDATE leaves dead row versions inside the table file, and VACUUM reclaims them. Redshift needs VACUUM to re-sort and remove deleted rows. Snowflake never edits a micro-partition in place, so there is nothing to compact. Old versions move through a storage lifecycle and are purged automatically.

Active current version, queryable Time Travel 0–90 days, you can query / UNDROP Fail-safe 7 days, Snowflake support only Purged storage freed UPDATE / DELETE / DROP replaces it retention expires 7 days pass
You pay storage for all three billed stages. Transient and temporary tables skip Fail-safe.
Maintenance task elsewhereSnowflake equivalent
Postgres VACUUM / Redshift VACUUM DELETEAutomatic. Replaced micro-partitions age out through Time Travel and Fail-safe.
Redshift VACUUM SORT / index rebuildAutomatic Clustering re-organises tables that have a clustering key, as a serverless background service.
ANALYZE / gather statisticsAutomatic. Metadata is maintained on every write.
Shrinking a bloated tableLower DATA_RETENTION_TIME_IN_DAYS, use transient tables for staging, or avoid tiny frequent DML.
The real-world "bloat" problem

A table updated every 5 minutes with MERGE rewrites micro-partitions constantly. With 90-day Time Travel, you may store far more historical bytes than active bytes. Check with:

SELECT table_catalog, table_schema, table_name,
       active_bytes        / POWER(1024,3) AS active_gb,
       time_travel_bytes   / POWER(1024,3) AS time_travel_gb,
       failsafe_bytes      / POWER(1024,3) AS failsafe_gb,
       retained_for_clone_bytes / POWER(1024,3) AS clone_gb
FROM snowflake.account_usage.table_storage_metrics
WHERE deleted = FALSE
ORDER BY time_travel_bytes + failsafe_bytes DESC
LIMIT 20;
05

Backup and recovery

Snowflake has no RMAN or pg_dump. Instead you get layers of protection, each with different reach.
LayerProtects againstWho restoresHow far back
Time TravelBad UPDATE/DELETE, dropped table, schema or databaseYou, with SQL0–90 days (edition and table type dependent)
Zero-copy cloneNeed for a point-in-time snapshot you keep beyond Time TravelYouAs long as you keep the clone
Fail-safeDisaster after Time Travel expiredSnowflake Support only, best effort7 days after Time Travel (permanent tables only)
Replication / failover groupsRegion or cloud outageYou (promote secondary)Up to the last refresh
Snapshots / backup sets (newer feature)Ransomware, accidental purge, compliance (WORM-style retention locks)YouPer backup policy
Unload to your own bucketRegulatory need for an independent copy outside SnowflakeYou (re-load)As long as you keep files

Snapshot/backup-set features are newer than the rest of this table, and availability depends on your account and region. Confirm in the current docs before you design around them.

The recovery playbook

-- A. Someone ran DELETE without WHERE 20 minutes ago
CREATE OR REPLACE TABLE orders_restored CLONE orders AT (OFFSET => -60*25) COPY GRANTS;
-- verify, then swap atomically:
ALTER TABLE orders SWAP WITH orders_restored;

-- B. Find the exact bad statement and restore to just before it
SELECT query_id, query_text, start_time
FROM TABLE(information_schema.query_history())
WHERE query_text ILIKE 'delete from orders%' ORDER BY start_time DESC;

CREATE OR REPLACE TABLE orders_restored CLONE orders
  BEFORE (STATEMENT => '01b2c3d4-0000-1234-0000-0001a2b3c4d5');

-- C. A table (or schema / database) was dropped
UNDROP TABLE orders;
UNDROP SCHEMA staging;
UNDROP DATABASE sales;

-- D. Nightly "backup" clone created by a task
--    (add a second step that drops clones older than your retention)
CREATE OR REPLACE TASK nightly_clone
  WAREHOUSE = admin_wh
  SCHEDULE  = 'USING CRON 0 2 * * * UTC'
AS
  EXECUTE IMMEDIATE $$
  BEGIN
    LET stmt STRING := 'CREATE DATABASE SALES_BKP_' ||
                       TO_CHAR(CURRENT_DATE, 'YYYYMMDD') || ' CLONE sales';
    EXECUTE IMMEDIATE :stmt;
  END;
  $$;

ALTER TASK nightly_clone RESUME;   -- tasks are created suspended

Why clone + SWAP instead of INSERT … SELECT? A clone is a metadata operation, so it is instant at any size. SWAP WITH exchanges the two tables in one atomic step, so readers never see a half-restored table. Swap moves privilege grants along with the table contents, so clone with COPY GRANTS to keep the restored table's privileges identical.

06

High availability and failover

Inside one region (automatic, all editions)
  • Storage: the cloud provider replicates objects across multiple availability zones.
  • Cloud Services: run across several availability zones.
  • Warehouses: if a node fails while a query runs, Snowflake replaces it and retries the failed work, so you usually see a slower query rather than an error.
  • You configure nothing. This covers hardware and zone failures, not a whole-region outage.
Across regions / clouds (you configure)
  • Replication group: copies databases and account objects to another account (read-only replicas). Available on all editions.
  • Failover group: a replication group whose secondary can be promoted to primary. Business Critical.
  • Client Redirect: one connection URL that you re-point to the new primary, so apps don't change config. Business Critical.
  • RPO is set by REPLICATION_SCHEDULE. RTO is how fast you run the promote and redirect.
PRIMARY account • AWS us-east-1 Failover group: DBs, roles, users, warehouses read / write SECONDARY account • Azure East US 2 Replica of the failover group read-only until promoted REFRESH every 10 min (RPO) Client Redirect URL org-prod_conn.snowflakecomputing.com
Replication can cross clouds. During an outage you promote the secondary and point the connection object at it.
-- On the PRIMARY account
CREATE FAILOVER GROUP prod_fg
  OBJECT_TYPES = USERS, ROLES, WAREHOUSES, RESOURCE MONITORS, DATABASES, INTEGRATIONS
  ALLOWED_DATABASES = sales, finance
  ALLOWED_INTEGRATION_TYPES = STORAGE INTEGRATIONS
  ALLOWED_ACCOUNTS = myorg.dr_account
  REPLICATION_SCHEDULE = '10 MINUTE';

CREATE CONNECTION prod_conn;
ALTER CONNECTION prod_conn ENABLE FAILOVER TO ACCOUNTS myorg.dr_account;

-- On the SECONDARY account
CREATE FAILOVER GROUP prod_fg AS REPLICA OF myorg.prod_account.prod_fg;
CREATE CONNECTION prod_conn AS REPLICA OF myorg.prod_account.prod_conn;

-- Disaster! On the SECONDARY account:
ALTER FAILOVER GROUP prod_fg PRIMARY;   -- databases become writable here
ALTER CONNECTION prod_conn PRIMARY;     -- apps using the connection URL follow

Remember for interviews: replication copies data and objects, but warehouses on the secondary start suspended and are billed only when used. Replication itself uses serverless compute plus data transfer, so frequent refreshes of big, churny databases cost real money. Pick the RPO the business actually needs.

07

Interview check: internals