> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elementum.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Snowflake Query Profile Table

> What the Query Profile Table is, why Elementum recommends provisioning it, and how to set it up in your Snowflake account.

The Query Profile Table is a small, dedicated table in your Snowflake account that records performance metrics for queries Elementum runs on your behalf. It's part of the [Snowflake CloudLink setup](/administration/connect-snowflake-to-elementum) and is provisioned once, after the CloudLink itself is created.

## What the Query Profile Table is

When you create a Snowflake CloudLink, Elementum generates a DDL script that creates a dynamic table in the `ELEMENTUM_PLATFORM` schema. That table is backed by `SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY` and a scheduled task that keeps it current. Once provisioned:

* The table records execution time, warehouse usage, bytes scanned, and similar metrics **only for queries the `ELEMENTUM` role runs**.
* It does not capture queries from your internal users, other applications, or third-party tools.
* It lives entirely inside your Snowflake account—no data leaves Snowflake.
* A scheduled task clears records older than 14 days, so the table stays small.

| Property  | Value                                                           |
| --------- | --------------------------------------------------------------- |
| Location  | `ELEMENTUM.ELEMENTUM_PLATFORM` schema in your Snowflake account |
| Source    | Filtered view of `SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY`        |
| Scope     | Queries executed by the `ELEMENTUM` role only                   |
| Retention | 14 days, enforced by a scheduled task                           |
| Owner     | The `ELEMENTUM` role                                            |

<Info>
  Elementum reads the Query Profile Table to surface query-performance metrics. Without it, every metric lookup has to scan `SNOWFLAKE.ACCOUNT_USAGE` directly, which is slow and consumes credits.
</Info>

## Why Elementum recommends provisioning it

The Query Profile Table gives Elementum's support and engineering teams the visibility needed to diagnose performance issues in your environment, without granting access to anything beyond the queries Elementum itself ran.

### Faster diagnosis of performance issues

When the table is provisioned, Elementum can diagnose and resolve issues directly rather than relying on support escalations and one-off `ACCOUNT_USAGE` queries. This applies to:

* Timeouts and slow-running operations
* Intermittent query failures
* Warehouse scaling and credit-usage concerns

### Proactive performance monitoring

With visibility into how operations perform over time, Elementum can:

* Identify which operations are creating bottlenecks
* Alert on emerging performance issues before they affect your workflows
* Recommend configuration changes (such as warehouse sizing or scaling policy) when they would improve your experience

### Targeted optimization for your environment

Using performance trends specific to your account, Elementum can recommend or apply targeted improvements such as:

* Index recommendations
* [Search optimization](https://docs.snowflake.com/en/user-guide/search-optimization-service)
* Clustering keys on tables Elementum queries frequently

## Privacy and access scope

The table is designed so Elementum only ever sees activity it generated:

* The DDL filters `QUERY_HISTORY` by the `ELEMENTUM` role, so other users' queries are excluded.
* The table is owned by the `ELEMENTUM` role and lives in the platform schema you already use for CloudLink. No additional access is granted outside that role.
* Data older than 14 days is removed automatically by the scheduled task.

<Note>
  You control access through your existing Snowflake roles and grants. If you ever revoke the `ELEMENTUM` role's privileges, the table and its task stop receiving data.
</Note>

## Prerequisites

Before provisioning the Query Profile Table, confirm:

* The Snowflake CloudLink has been created and is showing as **Connected** in **Organization Settings → CloudLinks**. See [Connect Snowflake to Elementum](/administration/connect-snowflake-to-elementum) for the full setup.
* You have a Snowflake user with the `ACCOUNTADMIN` role available to run the DDL.
* The `ELEMENTUM` role, warehouse, database, and `ELEMENTUM_PLATFORM` schema created during CloudLink setup are in place.

## Provision the table

Elementum generates the DDL for your specific CloudLink—it includes the right database, schema, warehouse, and role names for your environment.

<Steps>
  <Step title="Open the CloudLink details">
    In Elementum, go to **Organization Settings → CloudLinks** and click the name of your Snowflake CloudLink to open its details.
  </Step>

  <Step title="Copy the DDL">
    Scroll to the **Query Profile Table** section and click **Copy DDL**. The script is tailored to this CloudLink and includes the grants the `ELEMENTUM` role needs to read `SNOWFLAKE.ACCOUNT_USAGE` and run the scheduled task.
  </Step>

  <Step title="Run the DDL in Snowflake">
    Open a Snowflake worksheet as `ACCOUNTADMIN` and run the script.

    <Warning>
      The DDL must be run by `ACCOUNTADMIN`. It grants `IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE` and creates a scheduled task in `ELEMENTUM_PLATFORM`—both of which require account-level privileges.
    </Warning>
  </Step>

  <Step title="Confirm the status updates">
    Return to the CloudLink dialog. The **Query Profile Table** status should change to **Provisioned**. If it still shows **Not provisioned**, see [Troubleshooting](#troubleshooting) below.
  </Step>
</Steps>

## Verify the table is working

You can sanity-check the table and its scheduled task directly in Snowflake.

<Steps>
  <Step title="Confirm the table exists">
    ```sql theme={null}
    USE ROLE ELEMENTUM;
    USE DATABASE ELEMENTUM;
    USE SCHEMA ELEMENTUM_PLATFORM;

    SHOW DYNAMIC TABLES LIKE 'QUERY_PROFILE%';
    ```

    You should see the dynamic table created by the DDL.
  </Step>

  <Step title="Confirm the scheduled task is running">
    ```sql theme={null}
    SHOW TASKS LIKE 'QUERY_PROFILE%' IN SCHEMA ELEMENTUM.ELEMENTUM_PLATFORM;
    ```

    The task `state` should be `started`. If it shows `suspended`, resume it:

    ```sql theme={null}
    USE ROLE ACCOUNTADMIN;
    ALTER TASK ELEMENTUM.ELEMENTUM_PLATFORM.<TASK_NAME> RESUME;
    ```
  </Step>

  <Step title="Confirm rows are being recorded">
    Once the CloudLink has run a few queries (give it a few minutes after provisioning), the table should contain rows:

    ```sql theme={null}
    SELECT COUNT(*) FROM ELEMENTUM.ELEMENTUM_PLATFORM.<QUERY_PROFILE_TABLE>;
    ```

    The exact table and task names are in the DDL Elementum generated for your CloudLink.
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Status stays on &#x22;Not provisioned&#x22; after running the DDL">
    * Re-run the DDL as `ACCOUNTADMIN`. The `IMPORTED PRIVILEGES` grant and task creation both require account-level privileges and will silently fail under other roles.
    * Confirm the CloudLink in the UI matches the one whose DDL you copied. Each CloudLink has its own DDL.
    * Click **Refresh** on the CloudLink details page; the status check runs against Snowflake on demand.
  </Accordion>

  <Accordion title="&#x22;Insufficient privileges&#x22; when running the DDL">
    * Verify you are running the script as `ACCOUNTADMIN`, not `SYSADMIN` or a custom admin role.
    * Confirm the `ELEMENTUM` role exists. If you set up the CloudLink before the role was created, the grants in the DDL will fail.
  </Accordion>

  <Accordion title="The dynamic table exists but stays empty">
    * Check that the scheduled task is in the `started` state with `SHOW TASKS`.
    * Confirm the `ELEMENTUM` warehouse is not suspended; the task needs warehouse compute to run.
    * Allow up to the task's scheduled interval (typically a few minutes) for the first rows to land.
    * Verify the CloudLink has actually executed queries since provisioning. The table only captures activity from the `ELEMENTUM` role.
  </Accordion>

  <Accordion title="Removing the Query Profile Table">
    If you need to remove the table—for example, before tearing down a CloudLink—drop the task first, then the table:

    ```sql theme={null}
    USE ROLE ACCOUNTADMIN;
    ALTER TASK ELEMENTUM.ELEMENTUM_PLATFORM.<TASK_NAME> SUSPEND;
    DROP TASK ELEMENTUM.ELEMENTUM_PLATFORM.<TASK_NAME>;
    DROP DYNAMIC TABLE ELEMENTUM.ELEMENTUM_PLATFORM.<QUERY_PROFILE_TABLE>;
    ```

    The CloudLink will continue to work without the table, but query-profile lookups will fall back to scanning `ACCOUNT_USAGE` directly.
  </Accordion>
</AccordionGroup>

## Related

* [Connect Snowflake to Elementum](/administration/connect-snowflake-to-elementum) — full CloudLink setup, including the step where you provision this table.
* [Snowflake warehouses](/administration/snowflake-warehouses) — sizing and scaling guidance Elementum can refine using Query Profile data.
* [Snowflake table types](/administration/snowflake-table-types) — Standard vs. Hybrid tables and how table type affects query performance.
