What you will be able to do
- Name the account usage views that hold ML credit data and say what each one can and cannot attribute
- Attribute dedicated warehouses and compute pools to a team with object tags
- Split a shared warehouse's cost by department by tagging users and joining QUERY_ATTRIBUTION_HISTORY
- Attribute an application's queries to the right cost centers with the QUERY_TAG session parameter
- Isolate the refresh cost of managed feature views and attribute costs across several accounts
- Trace credits down to a recurring feature-build query, a stored procedure or a served model, and know where that figure stops being exact
- Tune a dedicated warehouse and set compute pool node limits so ML performance is bought only where it pays for itself
Key concept
Object tags for owners, query tags for shared applications — Cost is attributed by attaching a label to whatever really belongs to a team. An object tag goes on a dedicated resource or on a user. A query tag goes on each query when one application runs work on behalf of several teams.
1.Where ML credits come from and where they are recorded
ML spend in Snowflake comes from two kinds of compute, and each is metered in its own place. Virtual warehouses run feature engineering SQL, Snowpark training stored procedures and the dynamic table refreshes behind feature views. Compute pools run Snowpark Container Services jobs and services, such as GPU training or a scoring service. Finance wants a chargeback or showback model: a bill split by team, model or feature. To build one, you first need to know which view records which kind of credit.
For warehouses, three ACCOUNT_USAGE views do the work. WAREHOUSE_METERING_HISTORY gives credits per warehouse. TAG_REFERENCES lists which objects carry which tags. QUERY_ATTRIBUTION_HISTORY gives a credit figure for each query, along with the query's USER_NAME and QUERY_TAG. Compute pool credits live in their own view, SNOWPARK_CONTAINER_SERVICES_HISTORY, which reports hourly credits per COMPUTE_POOL_NAME.
| View | Granularity | Use it to |
|---|---|---|
| WAREHOUSE_METERING_HISTORY | Credits per warehouse | Charge a whole warehouse to the team that owns it |
| TAG_REFERENCES | Tag values on objects such as warehouses and users | Map a warehouse_id or user name to a cost_center value |
| QUERY_ATTRIBUTION_HISTORY | Credits per query, with USER_NAME and QUERY_TAG | Split a shared warehouse by user or by query tag |
How you attribute depends on how the resource is used. There are three cases. A resource used by one team only is tagged directly. A warehouse shared by several teams is split by tagging the users. An application that queries on behalf of many teams is split by query tags. The next three sections take these cases in order.
Attribution can go finer than a team: down to a single feature or model. Recurring statements, such as the query that rebuilds one feature table every night, share a QUERY_PARAMETERIZED_HASH in QUERY_ATTRIBUTION_HISTORY, so grouping credits by that hash prices the feature pipeline step by step and surfaces the most expensive recurring statements. A Snowpark training stored procedure issues many child queries; find its ROOT_QUERY_ID through ACCESS_HISTORY and sum the credits of every query under that root to get the cost of one run.
Served models have a view of their own. MODEL_SERVING_USAGE_HISTORY reports estimated credits per model, model version and function, with COMPUTE_POOL_NAME on rows served from a pool and QUERY_TAG on rows served from a warehouse. Treat the pool rows as an apportionment, not an invoice. The pool itself carries the real charge, and it also accrues idle time, so the per-model figures will not add up to the pool total. Queries of about 100 ms or less are too short for per-query attribution and do not appear in QUERY_ATTRIBUTION_HISTORY at all.
Checkpoint 1 of 9· Match them up
An ML platform team is building a chargeback model. Match each ACCOUNT_USAGE view to the attribution question it answers.
Tap a term, then the definition that fits it.
Warehouse credits are recorded per warehouse in WAREHOUSE_METERING_HISTORY and per query in QUERY_ATTRIBUTION_HISTORY. TAG_REFERENCES connects objects to their tag values. Compute pool credits are recorded separately, in SNOWPARK_CONTAINER_SERVICES_HISTORY.
“WAREHOUSE_METERING_HISTORY view: Provides credit usage for warehouses. QUERY_ATTRIBUTION_HISTORY view: Provides the compute costs for queries.”Source: docs.snowflake.com
2.Dedicated resources: tag the warehouse or pool itself
When a team has its own warehouse, the warehouse's whole bill belongs to that team, so one object tag on the warehouse is enough. Create the tag once, ideally in a dedicated database such as cost_management.tags. Using ALLOWED_VALUES limits the tag to a fixed list of cost centers, so a typo cannot create a new, orphaned bucket.
CREATE TAG cost_center
ALLOWED_VALUES 'finance', 'marketing', 'engineering', 'product';To report, join WAREHOUSE_METERING_HISTORY to TAG_REFERENCES on warehouse_id = object_id, with the domain set to 'WAREHOUSE'. The COALESCE(..., 'untagged') shows warehouses that nobody has tagged yet. A growing untagged line usually means warehouses are being created outside your provisioning workflow.
SELECT
TAG_REFERENCES.tag_name,
COALESCE(TAG_REFERENCES.tag_value, 'untagged') AS tag_value,
SUM(WAREHOUSE_METERING_HISTORY.credits_used_compute) AS total_credits
FROM
SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
LEFT JOIN SNOWFLAKE.ACCOUNT_USAGE.TAG_REFERENCES
ON WAREHOUSE_METERING_HISTORY.warehouse_id = TAG_REFERENCES.object_id
AND TAG_REFERENCES.domain = 'WAREHOUSE'
WHERE
WAREHOUSE_METERING_HISTORY.start_time >= DATE_TRUNC('MONTH', DATEADD(MONTH, -1, CURRENT_DATE))
AND WAREHOUSE_METERING_HISTORY.start_time < DATE_TRUNC('MONTH', CURRENT_DATE)
GROUP BY TAG_REFERENCES.tag_name, COALESCE(TAG_REFERENCES.tag_value, 'untagged')
ORDER BY total_credits DESC;Compute pools follow the same rule: give each team its own pool. ALTER COMPUTE POOL accepts a TAG tag_name = 'tag_value' clause. Because SNOWPARK_CONTAINER_SERVICES_HISTORY reports credits per COMPUTE_POOL_NAME, one pool per team gives you a per-team monthly total directly. Two teams on one pool cannot be separated in that view.
A dedicated resource is also the easiest one to tune, because nothing else competes with the workload you are tuning for. A warehouse that runs one kind of job can be adjusted against that job and the change judged by re-running the query and comparing execution time. A mixed warehouse pays for an optimization that most of its queries never use. Six levers trade cost for speed:
- Queuing. A query waits in a queue when the warehouse is busy. Waiting costs no credits, but a feature build stuck behind other work finishes late, and
STATEMENT_QUEUED_TIMEOUT_IN_SECONDScancels statements that wait too long. - Memory spillage. A query that runs out of memory spills bytes onto storage and runs substantially slower. More memory comes from a larger size or from a Snowpark-optimized warehouse, whose default configuration gives 16x the memory per node of a standard one.
- Size. A larger warehouse has more compute for each query, at a higher hourly credit rate.
- Query acceleration. The service offloads portions of a query to serverless compute, which speeds the query up and lightens the load on the warehouse. It is billed on top: the credits appear in
CREDITS_USED_QUERY_ACCELERATION. - Cache reuse. A query that can read from the warehouse's cache instead of from tables runs faster, so it favors a warehouse that runs similar queries.
- Concurrency cap. Limiting how many queries run at once leaves fewer of them competing for the warehouse's resources, so each runs faster while the rest wait.
A nightly feature build that spills to storage is the typical case: add memory, then keep the larger size only if the shorter run offsets the higher hourly rate.
A compute pool is a collection of virtual machine nodes, and its instance family fixes the hardware of every node: vCPU, memory, storage and egress bandwidth. That hardware sets the credit rate, which is why choosing an instance family is the pool's version of choosing a warehouse size. A pool is tuned through its node limits and instance family instead of a size. Raise MIN_NODES above 1 only for a service with sudden bursts, so nodes are ready instead of waiting for autoscaling to add them. Treat MAX_NODES as the ceiling on spend: it stops a load spike or a bug from adding nodes without limit. Lowering it later can force Snowflake to terminate service instances, and a job service on a terminated node fails and is not restarted. INSTANCE_FAMILY can be altered only when the pool is fully suspended, so changing machine type means suspend, alter, resume.
Checkpoint 2 of 9· Check yourself
Two ML teams run their GPU training jobs on the same Snowpark Container Services compute pool. Finance now wants a separate monthly compute pool total for each team. What setup gives them that?
SNOWPARK_CONTAINER_SERVICES_HISTORY records credits per compute pool, so two teams on one pool cannot be separated in it. A dedicated pool per team, tagged like a dedicated warehouse, gives a per-team total directly. QUERY_ATTRIBUTION_HISTORY and WAREHOUSE_METERING_HISTORY only cover warehouse credits.
“COMPUTE_POOL_NAME | VARCHAR | Name of the compute pool which incurred the credit usage.”Source: docs.snowflake.com
3.Shared warehouses: tag the users and attribute per query
A warehouse shared by three departments can carry only one cost_center value at a time, so tagging the warehouse cannot split its bill. Tagging it with each department in turn does not help either: WAREHOUSE_METERING_HISTORY still records only the warehouse total for each hour, whoever ran the work. Instead, tag each user with their department and attribute cost per query. Each query's credits are tied to the user who ran it, and the user's tag tells you the department.
ALTER WAREHOUSE warehouse1 SET TAG cost_management.tags.cost_center='SALES';
ALTER WAREHOUSE warehouse2 SET TAG cost_management.tags.cost_center='SALES';
ALTER WAREHOUSE warehouse3 SET TAG cost_management.tags.cost_center='FINANCE';
ALTER USER finance_user SET TAG cost_management.tags.cost_center='FINANCE';
ALTER USER sales_user SET TAG cost_management.tags.cost_center='SALES';The join for users differs from the warehouse join. QUERY_ATTRIBUTION_HISTORY.user_name matches TAG_REFERENCES.object_name where the domain is 'USER'. Summing credits_attributed_compute by tag_value gives the departmental chargeback. The variant below finds credits from users with no tag, which is a useful audit to run before you send the bill to finance. You can automate user tagging with SCIM provisioning from an identity provider such as Okta or Microsoft Entra ID. That way new data scientists arrive already tagged.
SELECT qah.user_name, SUM(qah.credits_attributed_compute) as total_credits
FROM
SNOWFLAKE.ACCOUNT_USAGE.QUERY_ATTRIBUTION_HISTORY qah
LEFT JOIN snowflake.account_usage.tag_references tr
ON qah.user_name = tr.object_name AND tr.DOMAIN = 'USER'
WHERE
start_time >= dateadd(month, -1, current_date)
AND qah.user_name IS NULL OR tr.object_name IS NULL
GROUP BY qah.user_name
ORDER BY total_credits DESC;The gap between the two totals is idle time. A warehouse that stays up between bursts of feature queries, waiting for its auto-suspend timer, still bills for those minutes, but no query owns them. You have to decide how to handle that remainder. One option is to share it out in proportion to each department's per-query credits. Another is to report it as its own line, which also shows that the auto-suspend setting is too generous. Query acceleration credits sit in a separate column, CREDITS_USED_QUERY_ACCELERATION. An accelerated query's full cost is that column plus CREDITS_ATTRIBUTED_COMPUTE.
Checkpoint 3 of 9· Check yourself
Three data science departments run feature engineering on the same warehouse, and finance wants a monthly bill for each department. Which approach produces that split?
A shared warehouse can hold only one cost_center value, and WAREHOUSE_METERING_HISTORY records only a warehouse total for each hour. Per-query credits in QUERY_ATTRIBUTION_HISTORY are tied to the user who ran the query, so a tag on each user lets you group those credits by department.
“In this case, you use object tags to associate each user with a department. The costs of queries are attributed to the users.”Source: docs.snowflake.com
Checkpoint 4 of 9· Exam question
A shared warehouse ML_SHARED_WH serves data scientists from three departments. Finance wants a monthly chargeback that reflects each department's actual query consumption on that warehouse. Which approach delivers this?
Correct answer: A — Tag each user with a COST_CENTER object tag, then join QUERY_ATTRIBUTION_HISTORY to TAG_REFERENCES by user name and sum credits per tag value.
- A. Correct: user-level cost tags joined to per-query credits in QUERY_ATTRIBUTION_HISTORY apportion a shared warehouse by who ran each query.
- B. Incorrect: a warehouse can carry only one tag value at a time, so rotating values gives time-slice guesses instead of per-query consumption.
- C. Incorrect: an even split ignores real usage, and the history view reports credits by day, not per department, so it cannot justify a chargeback.
- D. Incorrect: WAREHOUSE_LOAD_HISTORY reports load (running, queued queries), not credits, and an account-level query tag cannot differ per department.
Checkpoint 5 of 9· Exam question
A team sums CREDITS_ATTRIBUTED_COMPUTE from QUERY_ATTRIBUTION_HISTORY for a month on its ML warehouse and finds the total noticeably lower than the warehouse's credits in WAREHOUSE_METERING_HISTORY. What explains the gap?
Correct answer: B — Per-query attribution excludes warehouse idle time, so credits burned while the warehouse ran with no active queries appear only in the metering history.
- A. Incorrect: short queries are still attributed their share of compute; rounding to zero is not how the view works.
- B. Correct: attributed compute covers only time queries actually ran, so idle time (such as the auto-suspend wait) is missing and explains the gap.
- C. Incorrect: the view covers queries from all roles in the account, not just the administrator role, and all warehouse usage is billed as warehouse credits.
- D. Incorrect: both views report credits in the same unit; no size-factor conversion is applied to reconcile them.
Sources1
4.Applications that query for many teams: query tags
User tags stop working when every query comes from one service user. Take an inference application that scores requests for marketing, risk and support through a single service user. If you tag that user, every credit lands in one bucket, and TAG_REFERENCES holds only tag assignments, not query text or credits. The fix is to label each query with the cost center of the person it runs for.
QUERY_TAG is a session parameter, not an object tag. The application sets it before it issues a request's queries. Every later query in that session carries the value, and QUERY_ATTRIBUTION_HISTORY stores it in its QUERY_TAG column. Grouping that view's credits by QUERY_TAG gives the departmental split. When the application switches to a request from another department, it resets the parameter.
ALTER SESSION SET QUERY_TAG = 'COST_CENTER=finance';Checkpoint 6 of 9· Match them up
For each ML cost situation, pick the mechanism that handles it.
Tap a term, then the definition that fits it.
The label goes on whatever really belongs to a team: the dedicated resource, the user, or, when one service user serves many departments, each query through QUERY_TAG. A service user's object tag would put all of its credits in one bucket. Resource monitors cap spending but do not split it.
“Use query tags to associate individual queries with departments or projects when the queries are made by the same application”Source: docs.snowflake.com
Checkpoint 7 of 9· Exam question
A single application submits inference queries on behalf of marketing, risk, and support users, all using one application service user and one warehouse. Which technique lets cost reports separate the departments?
Correct answer: A — Set the QUERY_TAG session parameter to the requester's cost center before each query, then group QUERY_ATTRIBUTION_HISTORY credits by QUERY_TAG.
- A. Correct: a per-request QUERY_TAG travels with each query and QUERY_ATTRIBUTION_HISTORY exposes it, so one user and one warehouse can still be split by cost center.
- B. Incorrect: WAREHOUSE_METERING_HISTORY is hourly per warehouse and has no role column, so it cannot be grouped by role.
- C. Incorrect: a resource monitor is assigned to a warehouse or account and tracks that scope's credits; it does not split usage by department.
- D. Incorrect: a tag on the single service user labels all queries with one value, so it cannot distinguish departments.
5.Attributing the cost of individual features
A managed feature view is backed by a dynamic table, so its cost is the credits its refreshes use on the warehouse you assign (Feature views: managed (dynamic-table-backed) and external). The cleanest way to see what a feature costs is to give its refreshes a warehouse of their own. Then every credit on that warehouse belongs to the feature pipeline, and a warehouse object tag attributes it to the owning team with the dedicated-resource join shown earlier.
Once you have a cost baseline, you can move the refreshes onto a shared warehouse. From then on, attribute by the user or query tag that runs them. Refresh frequency is the main lever on that baseline (Dynamic table refresh policies and target lag). A shorter target lag means more refresh cycles. Each active dynamic table also runs its own change-detection checks on every cycle, even when no data has changed, and those use cloud services credits. Take 200 dynamic tables at a 1-minute target lag: that is about 288,000 checks a day. When consumers only need data a few hours old, a longer lag is the cheapest fix.
Checkpoint 8 of 9· Check yourself
Before moving a managed feature view onto a shared warehouse, the owning team wants a clean figure for what its refreshes cost. Which setup gives that figure most directly?
A managed feature view's cost is the credits its refreshes use on the assigned warehouse. On a dedicated warehouse, every credit belongs to that pipeline, so an object tag on the warehouse attributes the whole bill to the owning team. WAREHOUSE_METERING_HISTORY records credits per warehouse, not per dynamic table. Resource monitors cap spending but do not split it, and SNOWPARK_CONTAINER_SERVICES_HISTORY covers only compute pools.
“You can use these object tags to attribute the costs incurred by those warehouses to that department entirely.”Source: docs.snowflake.com
Sources12
6.Attributing across accounts in an organization
When ML workloads span several accounts, create the tags once in a key account, such as the organization account, and replicate the tag database to the others. Each account then applies the same cost_center values, so totals from different accounts add up cleanly.
CREATE REPLICATION GROUP cost_management_repl_group
OBJECT_TYPES = DATABASES
ALLOWED_DATABASES = cost_management
ALLOWED_ACCOUNTS = my_org.my_account_1, my_org.my_account_2
REPLICATION_SCHEDULE = '10 MINUTE';Organization-level reporting has two limits. In the ORGANIZATION_USAGE schema, TAG_REFERENCES is available only in the organization account, so cross-account tag reports have to run there. The bigger limit is that QUERY_ATTRIBUTION_HISTORY exists only in each account's ACCOUNT_USAGE schema, with no organization-wide version. Organization-level attribution therefore covers dedicated resources. Per-user and per-query splits must be computed in each account and then combined.
Checkpoint 9 of 9· Fill the gap
ML workloads run in several accounts, and every account needs the same cost_center values so cross-account totals add up. Which database belongs in this primary replication group, created in the organization account?
CREATE REPLICATION GROUP cost_management_repl_group
OBJECT_TYPES = DATABASES
ALLOWED_DATABASES = ?
ALLOWED_ACCOUNTS = my_org.my_account_1, my_org.my_account_2
REPLICATION_SCHEDULE = '10 MINUTE';You create the tags once in a key account and replicate the database that holds them, cost_management, to the other accounts. Every account then applies the same cost_center values. Usage data is not replicated: QUERY_ATTRIBUTION_HISTORY stays in each account's ACCOUNT_USAGE schema, so per-user and per-query splits are still computed in each account.
Source: docs.snowflake.comSources1
Sources
(12)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“QUERY_ATTRIBUTION_HISTORY view: Provides the compute costs for queries.”
↩︎ Where ML credits come from and where they are recorded“For recurrent or similar queries, use the query_hash or query_parameterized_hash to group costs by query.”
↩︎ Where ML credits come from and where they are recorded“Resources used exclusively by a single cost center or department: An example of this is using object tags to associate warehouses with a department.”
↩︎ Dedicated resources: tag the warehouse or pool itself“The costs of queries are attributed to the users.”
↩︎ Shared warehouses: tag the users and attribute per query“Ideally, you should have workflows that automate the process of applying these tags when you create resources and users.”
↩︎ Shared warehouses: tag the users and attribute per query“This associates the COST_CENTER=finance tag with all subsequent queries executed during the session.”
↩︎ Applications that query for many teams: query tags“In the ORGANIZATION_USAGE schema, the TAG_REFERENCES view is only available in the organization account.”
↩︎ Attributing across accounts in an organization“you make those tags available in other accounts through replication.”
↩︎ Attributing across accounts in an organization“Use object tags to associate resources and users with departments or projects.”
↩︎ Key concept“each query executed by the application is assigned a query tag that identifies the team or cost center of the user”
↩︎ Exam trap 2“There is no organization-wide equivalent of the view.”
↩︎ Exam trap 3“WAREHOUSE_METERING_HISTORY view: Provides credit usage for warehouses. QUERY_ATTRIBUTION_HISTORY view: Provides the compute costs for queries.”
↩︎ Checkpoint“In this case, you use object tags to associate each user with a department. The costs of queries are attributed to the users.”
↩︎ Checkpoint“Use query tags to associate individual queries with departments or projects when the queries are made by the same application”
↩︎ Checkpoint“You can use these object tags to attribute the costs incurred by those warehouses to that department entirely.”
↩︎ Checkpoint - 2.https://docs.snowflake.com/en/sql-reference/account-usage/snowpark_container_services_historyOfficial docs
“can be used to return the hourly compute pool credit usage for an account within the last 365 days (1 year).”
↩︎ Where ML credits come from and where they are recorded“COMPUTE_POOL_NAME | VARCHAR | Name of the compute pool which incurred the credit usage.”
↩︎ Checkpoint - 3.
“For SPCS rows, the estimated credits shown are an attribution of compute pool usage to a model, not a precise, standalone charge.”
↩︎ Where ML credits come from and where they are recorded“For SPCS rows, the estimated credits shown are an attribution of compute pool usage to a model, not a precise, standalone charge.”
↩︎ Exam trap 4 - 4.
“Specifies the tag name and the tag string value.”
↩︎ Dedicated resources: tag the warehouse or pool itself“INSTANCE_FAMILY can be altered only when a compute pool is fully suspended.”
↩︎ Dedicated resources: tag the warehouse or pool itself“INSTANCE_FAMILY can be altered only when a compute pool is fully suspended.”
↩︎ Exam trap 5 - 5.
“Optimizing a warehouse for query performance is more straightforward when the warehouse runs similar workloads.”
↩︎ Dedicated resources: tag the warehouse or pool itself“The query acceleration service offloads portions of query processing to serverless compute resources”
↩︎ Dedicated resources: tag the warehouse or pool itself“Query performance improves if a query can read from the warehouse’s cache instead of from tables.”
↩︎ Dedicated resources: tag the warehouse or pool itself - 6.
“SQL statements that are in a queue to use a warehouse do not consume credits.”
↩︎ Dedicated resources: tag the warehouse or pool itself - 7.
“The default configuration for a Snowpark-optimized warehouse provides 16x memory per node compared to a standard warehouse.”
↩︎ Dedicated resources: tag the warehouse or pool itself - 8.https://docs.snowflake.com/en/developer-guide/snowpark-container-services/instance-familiesOfficial docs
“An instance family specifies the vCPU, memory, storage, and egress bandwidth available to nodes in a compute pool.”
↩︎ Dedicated resources: tag the warehouse or pool itself - 9.https://docs.snowflake.com/en/developer-guide/snowpark-container-services/accounts-orgs-usage-viewsOfficial docs
“The number and type (instance family) of the nodes in the compute pool”
↩︎ Dedicated resources: tag the warehouse or pool itself - 10.https://docs.snowflake.com/en/developer-guide/snowpark-container-services/working-with-compute-poolOfficial docs
“Setting a maximum node limit prevents an unexpectedly large number of nodes from being added to your compute pool by Snowflake autoscaling.”
↩︎ Dedicated resources: tag the warehouse or pool itself - 11.
“Query tag set for this statement through the QUERY_TAG session parameter.”
↩︎ Applications that query for many teams: query tags“Includes only the credit usage for the query execution and doesn’t include any warehouse idle time.”
↩︎ Exam trap 1“Includes only the credit usage for the query execution and doesn’t include any warehouse idle time.”
↩︎ Prediction - 12.
“To isolate dynamic table costs during testing, use a dedicated warehouse.”
↩︎ Attributing the cost of individual features“Cloud Services costs scale with the number of active dynamic tables, the target lag, and pipeline depth.”
↩︎ Attributing the cost of individual features