Optimizing Snowflake warehouses for cost and performance
Astrato does not copy your data. Every dashboard load, filter change and business question sends a query to your Snowflake warehouse, so the warehouse’s settings decide how fast answers come back and how many credits they use. This page covers the settings that matter for that workload and the trade-off each one makes. Snowflake defines every setting named here; follow the links to Snowflake’s documentation for the full rules and for what your edition supports.
Which warehouse Astrato uses
Section titled “Which warehouse Astrato uses”Astrato runs its queries on the warehouse set on the data connection:
- With Private key (Recommended) or Password (legacy), it is the Warehouse you choose under Session when you create or edit the connection.
- With Sign in with Snowflake, Warehouse reads User default, so each person’s queries run on their own Snowflake user’s default warehouse, unless you select Advanced beside the Session heading and choose one warehouse for everyone.
See Create the connection for the form, and
Shared or per-person access to Snowflake
for what each sign-in method means. The role Astrato uses needs USAGE on that warehouse; see
Role and privileges.
Astrato sets the Snowflake query tag Astrato on its sessions, so you can find its queries in
Snowflake’s query history and attribute their cost; see Watch what Astrato costs.
Warehouse sizing
Section titled “Warehouse sizing”A warehouse’s size sets its compute and memory. Each size up doubles both, and doubles the credits the warehouse uses per hour while it runs. For standard warehouses, X-Small uses 1 credit per hour; Snowflake lists every size and warehouse type in Understanding compute cost.
Start with X-Small or Small for dashboards over a reporting layer of modest tables, then size up only when queries show they need it:
- A query spills. When a query runs out of memory, Snowflake writes intermediate results to local disk and then to remote storage, which is much slower. A larger warehouse has more memory. See Queries too large to fit in memory.
- A single large query is slow even when nothing else is running. More compute shortens it, often by about as much as the extra cost, so the credits per query stay similar.
A larger size can reduce queuing when concurrent queries run short of the warehouse’s compute, but Snowflake does not intend resizing for concurrency: for many queries at once, it recommends additional warehouses or a multi-cluster warehouse. Before sizing up, check whether the query reads more data than it needs to: filtering earlier, or clustering the table on the column you filter by, can cut the work more cheaply. Snowflake’s Warehouse considerations covers how to experiment with sizes.
Auto-suspend
Section titled “Auto-suspend”Snowflake bills a running warehouse per second, with a minimum of 60 seconds each time it starts or resumes. Auto-suspend stops the warehouse after it has been idle for the time you set, and auto-resume starts it again when the next query arrives. Keep both on for the Astrato warehouse: without auto-resume, a suspended warehouse rejects Astrato’s queries until someone resumes it.
CREATE WAREHOUSE defaults to an auto-suspend of 600 seconds. The right value is a trade-off:
- Shorter stops paying for idle time sooner. Settings below 60 seconds rarely save anything, because each resume is billed for at least 60 seconds.
- Longer keeps the warehouse’s local cache of table data, which suspending clears, so the next dashboard load reads from cache instead of remote storage. See Caching.
For dashboards used in bursts, start around 60 seconds to a few minutes. For dashboards in steady use through the day, a longer suspend keeps the cache warm. A warehouse used only for loading data or scheduled tasks can suspend as soon as it finishes. Snowflake explains the setting in Warehouse considerations.
Multi-cluster warehouses
Section titled “Multi-cluster warehouses”When more queries arrive than one warehouse can run at once, Snowflake queues them, and every person waiting sees a slower dashboard. A multi-cluster warehouse, available in Snowflake Enterprise Edition and higher, starts extra clusters of the same size while the load lasts and stops them afterwards. Each running cluster uses credits, so you pay for extra clusters only while they run. See Multi-cluster warehouses.
Set MIN_CLUSTER_COUNT = 1 and a MAX_CLUSTER_COUNT above 1 to let Snowflake scale out. The
scaling policy decides how quickly it adds clusters:
- Standard, the default, starts a cluster as soon as queries begin to queue. It favours response times, which suits interactive dashboards.
- Economy starts a cluster only when Snowflake estimates there is enough load to keep it busy for several minutes. It favours credits, and lets queries queue for longer first.
This creates an X-Small warehouse for Astrato that suspends after 60 seconds idle and scales out to two clusters:
-- X-Small warehouse for Astrato dashboardsCREATE WAREHOUSE ASTRATO_WH WAREHOUSE_SIZE = 'XSMALL' AUTO_SUSPEND = 60 -- seconds idle before suspending AUTO_RESUME = TRUE -- start again when a query arrives INITIALLY_SUSPENDED = TRUE MIN_CLUSTER_COUNT = 1 -- multi-cluster settings need Enterprise Edition MAX_CLUSTER_COUNT = 2 SCALING_POLICY = 'STANDARD'; -- or 'ECONOMY' to favour credits over wait timeWithout Enterprise Edition, give Astrato a dedicated warehouse so other workloads do not queue in front of its queries.
Query acceleration
Section titled “Query acceleration”The query acceleration service, available in Enterprise Edition and higher, offloads parts of eligible queries, typically large scans with selective filters or aggregation, to serverless compute. It helps occasional heavy queries on a warehouse sized for the usual light ones, without sizing the whole warehouse up. Accelerated work is billed as serverless credits on top of the warehouse’s own.
Turn it on with ENABLE_QUERY_ACCELERATION = TRUE on the warehouse, and cap it with
QUERY_ACCELERATION_MAX_SCALE_FACTOR. To check whether a slow query would benefit first, pass its
query ID to SYSTEM$ESTIMATE_QUERY_ACCELERATION. See
Using the Query Acceleration Service.
Caching
Section titled “Caching”Snowflake has two caches that make repeat queries cheaper:
- The result cache. When a query is identical to one run before and the data it reads has not
changed, Snowflake returns the stored result without running it, and without using warehouse
credits. Results are kept for 24 hours, and each reuse extends that, up to 31 days. Queries that
call functions returning a different value on each run, such as
RANDOM, are not reused. See Using persisted query results for every condition. - The warehouse cache. A running warehouse keeps table data it has read on local storage, so later queries on the same tables read less from remote storage. Suspending the warehouse clears it. See Optimizing the warehouse cache.
The result cache is why a dashboard that several people open with the same filters costs little after the first load. Data loaded often, for example every few minutes, invalidates cached results just as often.
To see whether a query was answered from the cache, open it in Data Explorer and select View query insights: under Query profile insights, the dialog reads Cached result used. See Download the result and see the query.
Clustering
Section titled “Clustering”Snowflake stores a table in micro-partitions and skips the ones a query’s filters rule out. When the rows a query needs are spread across most partitions, it reads most of the table. A clustering key tells Snowflake to keep rows with similar values in that column together, so filtering on it reads far fewer partitions. See Clustering keys and clustered tables.
Clustering costs credits: Snowflake’s automatic clustering reorganises the table in the background as data changes, billed as serverless credits. It pays off when:
- the table is large: Snowflake aims clustering keys at multi-terabyte tables;
- queries filter on the same columns often, such as a date, region or customer column used by your dashboard filters;
- the table is queried far more often than it changes. Frequent
MERGE,UPDATEorDELETEwork causes reclustering that can cost more than it saves.
Choose columns with enough distinct values to separate the data, but not so many that every row
is different: cluster a timestamp as TO_DATE(<column>) rather than the raw value. Snowflake
recommends at most three or four columns or expressions per key; one or two is usual.
In Data Explorer, View query insights flags Pruning when a query on a table of more than 2,000 partitions scanned more than 40% of them, a sign the table is not organised by the column you filtered on.
Pre-compute heavy queries
Section titled “Pre-compute heavy queries”A Snowflake view, or a SQL view in your semantic layer, runs its whole query, joins and aggregations included, inside every query that reads it. Behind a dashboard, that means on every load and every filter change. When those queries are slow or costly, store the result once and let Astrato read the stored result instead. Snowflake offers three ways to do that:
| Option | What it stores | How it stays current |
|---|---|---|
| Materialized view | The result of a query on a single table: no joins. Needs Enterprise Edition. | Snowflake maintains it automatically, billed as serverless credits. |
| Dynamic table | The result of a query, joins included, within Snowflake’s supported queries. | Snowflake aims to refresh it within the TARGET_LAG you set, using a warehouse you name. |
| Scheduled task that rebuilds a table | The result of any query, as a plain table. | Rebuilt on your schedule; between runs, it shows the data as of the last run. |
A dynamic table is usually the simplest choice for a joined, aggregated reporting table:
-- Daily sales per region; Snowflake aims to keep it within an hour of its sourcesCREATE OR REPLACE DYNAMIC TABLE SALES.REPORTING.DAILY_SALES TARGET_LAG = '1 hour' WAREHOUSE = TRANSFORM_WHASSELECT o.ORDER_DATE, c.REGION, SUM(o.AMOUNT) AS REVENUE, COUNT(*) AS ORDERSFROM SALES.RAW.ORDERS oJOIN SALES.RAW.CUSTOMERS c ON c.CUSTOMER_ID = o.CUSTOMER_IDGROUP BY o.ORDER_DATE, c.REGION;TARGET_LAG is a target, not a guarantee: when refreshes take longer, the table falls further
behind its sources. Monitor its actual lag; see Snowflake’s
target lag guide.
A task gives you full control of when the work runs. This one rebuilds the table at 07:00, 10:00, 13:00 and 16:00 UTC. A new task is created suspended, so resume it once:
CREATE OR REPLACE TASK SALES.REPORTING.REBUILD_DAILY_SALES WAREHOUSE = TRANSFORM_WH SCHEDULE = 'USING CRON 0 7,10,13,16 * * * UTC'AS CREATE OR REPLACE TABLE SALES.REPORTING.DAILY_SALES COPY GRANTS AS SELECT o.ORDER_DATE, c.REGION, SUM(o.AMOUNT) AS REVENUE, COUNT(*) AS ORDERS FROM SALES.RAW.ORDERS o JOIN SALES.RAW.CUSTOMERS c ON c.CUSTOMER_ID = o.CUSTOMER_ID GROUP BY o.ORDER_DATE, c.REGION;
ALTER TASK SALES.REPORTING.REBUILD_DAILY_SALES RESUME;SHOW TASKS IN SCHEMA SALES.REPORTING;COPY GRANTS keeps the privileges already granted on the table when the task replaces it. The
names are examples; running a task needs the EXECUTE TASK privilege, as Snowflake describes in
Introduction to tasks.
The role on the Astrato connection needs SELECT on the new object. The ALL grants in
Role and privileges cover only objects that
existed when they ran, and COPY GRANTS only keeps grants the table already has, so a table the
task creates for the first time is not readable yet. Grant it explicitly after the first build. A
future grant does not replace this: it does not cover a table that already exists, and a table
replaced with COPY GRANTS does not inherit future grants. For a dynamic table or materialized
view, set future grants before you create it, or grant SELECT on it afterwards:
-- After the task's first buildGRANT SELECT ON TABLE SALES.REPORTING.DAILY_SALES TO ROLE ASTRATO_READER;
-- Before you create dynamic tables or materialized views in the schemaGRANT SELECT ON FUTURE DYNAMIC TABLES IN SCHEMA SALES.REPORTING TO ROLE ASTRATO_READER;GRANT SELECT ON FUTURE MATERIALIZED VIEWS IN SCHEMA SALES.REPORTING TO ROLE ASTRATO_READER;Then add the table to your semantic layer as you would any other; see Bring tables and model items in.
Pre-computing trades freshness for speed: dashboards show the data as of the last refresh, and the refresh itself uses credits. Run it on a separate warehouse so it does not compete with dashboard queries.
Dedicated or shared warehouse
Section titled “Dedicated or shared warehouse”Snowflake bills a warehouse for the time it runs, not for how busy it is. A warehouse that answers a one-second query every minute never reaches its auto-suspend time, so it runs, and is billed, for the whole hour while working for one minute of it.
Shared warehouse
Section titled “Shared warehouse”Running several light workloads on one warehouse uses its running time better: queries from Astrato and other tools can run in time already paid for, and share the warehouse cache. With a multi-cluster warehouse, extra clusters start only when the combined load needs them. The cost of a shared warehouse is that heavy work from another tool can queue Astrato’s queries, and its bill does not say which workload used what.
Dedicated warehouse
Section titled “Dedicated warehouse”A warehouse used only by Astrato shows Astrato’s cost directly, and other workloads cannot queue in front of its queries. It can also be sized and suspended for dashboard use alone. The cost is more idle running time across your warehouses. Set it as the connection’s Warehouse; see Which warehouse Astrato uses.
On a shared warehouse, the Astrato query tag still lets you attribute cost per query; see
Watch what Astrato costs.
Set guardrails
Section titled “Set guardrails”These Snowflake settings stop runaway queries and spending before they surprise you:
- Statement timeouts.
STATEMENT_TIMEOUT_IN_SECONDScancels a query that runs longer than the limit, andSTATEMENT_QUEUED_TIMEOUT_IN_SECONDScancels one that waits in the queue too long. Set them on the warehouse, user or account; see Parameters. Astrato itself stops waiting for a query after 120 seconds by default, so a Snowflake timeout shorter than that ends Astrato’s queries sooner. Over MCP, the query tools accept a longerqueryTimeout, up to 600 seconds. A timed-out read can be retried once automatically, so it may run on Snowflake twice; see Results and resources. - Resource monitors. A resource monitor tracks the credits warehouses use against a quota per day, week, month or year. At thresholds you set, it notifies administrators, suspends the warehouse once running queries finish, or suspends it at once and cancels them. Resource monitors cover warehouses only, not serverless features such as query acceleration, automatic clustering or materialized view maintenance. See Working with resource monitors.
Even without hard limits, a monitor that only notifies on every warehouse tells you when usage jumps unexpectedly, for example after someone sizes a warehouse up and leaves it that way.
Watch what Astrato costs
Section titled “Watch what Astrato costs”Snowflake’s SNOWFLAKE.ACCOUNT_USAGE schema records queries and credits for the account. Because
Astrato tags its queries Astrato, you can filter them out of the rest. This query, run with a
role that can read ACCOUNT_USAGE, totals the compute credits attributed to Astrato’s queries per
warehouse over the last seven days:
SELECT WAREHOUSE_NAME, COUNT(*) AS QUERIES, SUM(CREDITS_ATTRIBUTED_COMPUTE) AS CREDITSFROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_ATTRIBUTION_HISTORYWHERE QUERY_TAG = 'Astrato' AND START_TIME >= DATEADD(day, -7, CURRENT_TIMESTAMP())GROUP BY WAREHOUSE_NAMEORDER BY CREDITS DESC;Attributed credits cover the time queries ran, not the warehouse’s idle time before it suspends;
compare WAREHOUSE_METERING_HISTORY for the full bill. The attribution view can also lag by
several hours, leaves out very short queries, and has no rows for queries answered from the result
cache, so soon after setup it can show little or nothing; for the full figure, give Astrato a
dedicated warehouse and read WAREHOUSE_METERING_HISTORY for it. Snowflake describes the limits in
QUERY_ATTRIBUTION_HISTORY view
and both views in Account Usage.
To break Astrato’s queries down by workbook, sheet and user, read the metadata Astrato attaches to each query; see Query telemetry: Snowflake.
Snowflake also bills cloud services, the work outside warehouses such as compiling queries and answering metadata requests, but only the part of each day’s cloud services use above 10% of that day’s warehouse credits. See Understanding compute cost.
To look into one slow query, open it in Data Explorer and select View query insights: it shows the SQL Astrato ran, the query ID, and from Snowflake’s query profile the Cartesian, Union, Memory and Pruning checks, Estimated credits and Rows scanned. Memory flags a query that spilled, a sign the warehouse is too small for it. See Download the result and see the query, and Snowflake’s Query Profile for the full breakdown.
What next
Section titled “What next”- Connect to Snowflake to set the warehouse and role a connection uses.
- Explore a semantic layer in Data Explorer to run a question and read its query insights.
- Query performance for keeping a Data App fast, where the number of queries a page sends matters as much as each one’s cost.