CertSafari
    Snowflake SnowPro Advanced: MLOps Engineer (MLA-B01)· Lessons

    Domain 5 · Lesson 17/17

    ML cost attribution with object tags and query tags

    Manage ML cost attribution and resource optimization.

    19 min read
    5.34% of exam
    12 sources
    Published 20 Oct 2026
    Docs as of 4 Oct 2026

    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.

    Which view answers which attribution question
    ViewGranularityUse it to
    WAREHOUSE_METERING_HISTORYCredits per warehouseCharge a whole warehouse to the team that owns it
    TAG_REFERENCESTag values on objects such as warehouses and usersMap a warehouse_id or user name to a cost_center value
    QUERY_ATTRIBUTION_HISTORYCredits per query, with USER_NAME and QUERY_TAGSplit 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.

    Sources123

    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.

    A cost_center tag restricted to known valuessql
    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.

    Last month's warehouse credits grouped by cost_center tag valuesql
    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_SECONDS cancels 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?

    Sources145678910

    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.

    Tagging warehouses and users with the same cost_center tagsql
    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.

    Credits from untagged users on shared warehousessql
    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?

    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?

    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?

    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.

    Labelling all subsequent queries in a session with a cost centersql
    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.

    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?

    Sources111

    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?

    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.

    Primary replication group for the tag database, created in the organization accountsql
    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';

    Sources1

    Sources

    (12)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 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. 2.
      “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. 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. 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. 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. 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. 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. 8.
      “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. 10.
      “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
    10. 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
    11. 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

    Continue to part 2 of 2

    Tuning warehouse and compute pool cost for ML workloads

    Spotted a mistake, or was something unclear? Tell us.