How to Configure Snowflake Slow Query Log

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a snowflake slow query log by reading built-in history views. Because the platform lacks a separate file log, teams filter metadata views by run time. Data teams often grant broad admin roles so engineers can check these system views. Broad permissions let users read sensitive query text and raw data across the whole account. How the native snowflake slow query log works Snowflake does not write slow statements to a traditional local text file. Instead, the platform records every r

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up a snowflake slow query log by reading built-in history views. Because the platform lacks a separate file log, teams filter metadata views by run time. Data teams often grant broad admin roles so engineers can check these system views. Broad permissions let users read sensitive query text and raw data across the whole account.

How the native snowflake slow query log works

Snowflake does not write slow statements to a traditional local text file. Instead, the platform records every run inside a central metadata repo. You build a snowflake slow query log by querying these shared account usage views. Each record shows the SQL text, total run time, warehouse size, and user role.

Admins filter these records by total elapsed time to spot bottlenecks. You can see if a statement waited in a queue or spilled data to disk. The metadata also tracks bytes scanned and rows produced during each user session. Teams schedule regular tasks to copy slow records into a dedicated alert table.

To read this history, a user needs specific privileges on the system schema. Instead of granting full account admin rights, admins should create a custom monitoring role. You grant imported privileges on the system database to that specific role only. This lets engineers check run times while keeping warehouse billing settings locked down.

Why role permissions play a big part in query tracking

When teams rush this setup, they often share high-level roles with many developers. Any user with full history permissions can read every SQL statement run by others. Those statements often contain plain text values like emails, phone numbers, or card numbers. A shared monitoring role turns a simple performance check into a data exposure risk.

Good role design separates performance tuning from raw table permissions. You can assign a reader role that sees query metrics without reading business tables. Teams also set statement timeout rules at the account, warehouse, or user session level. Timeout rules stop bad queries before they burn through compute credits.

Snowflake Access Control + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native history views solve and what they leave open

Native history views give your team a full record of past database work. They help engineers find heavy joins, missing filters, and undersized compute warehouses after the fact. Combined with custom roles, they let you track performance without sharing root admin keys. Resource monitors also help by pausing warehouses when monthly credit limits run out.

Still, native history views only show slow statements after they finish or fail. System roles decide who can log in and start a session in the database. They do not inspect or control what individual statements do while in flight. And when engineers run ad-hoc checks on live tables, static roles do not mask sensitive columns.

A user with table permissions can still run an unindexed scan on production data. That single query can return thousands of national IDs or emails to a local screen. Native logs record the mistake later, with a noticeable delay in the shared history views. Teams need real-time controls to inspect statements and rewrite sensitive fields before results return.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Does Snowflake have a dedicated slow query log file to turn on?

No, the platform records all query activity inside built-in system views by default. You filter these history views by elapsed execution time to find your slowest queries.

Why is there a delay when checking past slow queries?

The historical account views update on a background schedule rather than in real time. For live checks, engineers must query the active session history function instead.

How can we stop slow queries from wasting compute credits?

You can set statement timeout rules on the warehouse or user session to cancel long runs. This stops runaway queries before they consume your compute budget.

The query runs. The emails stay hidden.