How to Follow Snowflake Best Practices

Galaxy Glossary

What are the essential Snowflake best practices?

Actionable rules that keep Snowflake workloads fast, affordable, and secure.

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

Why focus on Snowflake best practices?

Following published guidelines avoids slow queries, runaway costs, and security gaps. The payoff is predictable performance, smaller invoices, and peace of mind.

How to size virtual warehouses?

Start Small (X-Small or Small) and auto-suspend after 60 s. Scale up only when concurrency or scan time requires it.Monitor credits used via ACCOUNT_USAGE views.

Example sizing query

create or replace warehouse wh_reporting
with warehouse_size = 'SMALL'
auto_suspend = 60
auto_resume = true;

When should I enable multi-cluster?

Turn on multi-cluster only for high-concurrency dashboards. Set MIN_CLUSTER_SIZE=1 and MAX_CLUSTER_SIZE to the lowest number that eliminates queueing.

How do clustering keys speed up queries?

Define CLUSTER BY columns used in large table filters.For Orders, clustering on (customer_id, order_date) reduces micro-partitions scanned in customer-centric reports.

Clustering example

create or replace table Orders (
id number,
customer_id number,
order_date date,
total_amount number,
cluster by (customer_id, order_date)
);

What are result-, metadata-, and data-caches?

Result cache is free and lasts 24 h; reuse it with identical SQL and role.Metadata and data caches live in warehouse memory; keep them warm by avoiding unnecessary resumes.

How to control storage costs?

Stage data with compression (GZIP/Parquet), partition large files, and drop transient tables once queries finish. Schedule automatic RETENTION_TIME trims for historical tables.

Storage trim example

alter table OrderItems set data_retention_time_in_days = 7;

How to secure data quickly?

Use role hierarchy: ACCOUNTADMIN → SECURITYADMIN → custom roles. Mask PII columns (Customers.email) with dynamic data masking policies. Enforce network policies to whitelist corporate IPs.

.

Why How to Follow Snowflake Best Practices is important

How to Follow Snowflake Best Practices Example Usage


-- Daily sales total by customer with prune-friendly filters
SELECT   c.name,
         SUM(o.total_amount) AS lifetime_spend
FROM     Customers c
JOIN     Orders    o ON o.customer_id = c.id
WHERE    o.order_date >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY c.name
ORDER BY lifetime_spend DESC;

How to Follow Snowflake Best Practices Syntax


-- Warehouse sizing
CREATE WAREHOUSE warehouse_name
  [WITH] [WAREHOUSE_SIZE = {XSMALL | SMALL | MEDIUM | LARGE | XLARGE | XXLARGE}]
  [AUTO_SUSPEND = seconds]
  [AUTO_RESUME = {TRUE | FALSE}]
  [MIN_CLUSTER_COUNT = n] [MAX_CLUSTER_COUNT = n];

-- Clustering large tables
CREATE TABLE table_name (
  ...columns...
) CLUSTER BY (column1, column2);

-- Data retention for cost control
ALTER TABLE table_name SET DATA_RETENTION_TIME_IN_DAYS = n;

Common Mistakes

Frequently Asked Questions (FAQs)

How do I know if clustering is helping?

Run EXPLAIN; the PRUNED_PARTITIONS column should be high. Also check QUERY_HISTORY for PARTITIONS_SCANNED vs PARTITIONS_TOTAL.

Can I mix Snowpipe and bulk COPY?

Yes, but avoid loading the same files twice. Name each file uniquely and stage them in separate folders.

Is auto-suspend safe for dashboards?

With resume times <500 ms, auto-suspend rarely hurts user experience. Keep it at 60–300 s to save credits without noticeable lag.

Want to learn about other SQL terms?

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