finding-expensive-queries

Rank Snowflake queries by execution cost, time, and data scanned.

2|Updated Apr 8, 2026
One-click install
npx skills add https://github.com/miptah21/skills --skill finding-expensive-queries
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: finding-expensive-queries
Source: https://github.com/miptah21/skills/tree/main/.agents/skills/finding-expensive-queries
Command: npx skills add https://github.com/miptah21/skills --skill finding-expensive-queries

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It identifies which Snowflake queries are driving the most cost, latency, and resource waste so you can prioritize optimization work instead of guessing.

Core Features & Use Cases

  • Cost-based query ranking using SNOWFLAKE.ACCOUNT_USAGE.QUERY_ATTRIBUTION_HISTORY to surface the most expensive queries in a time window.
  • Performance and scan/spill enrichment using SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY to quantify elapsed time, bytes scanned, and spillage.
  • Actionable optimization guidance by detecting patterns like poor partition pruning, repeated query hashes (potential caching), and high spillage severity.

Quick Start

Ask an AI assistant to find the top expensive Snowflake queries from the last 7 days for a given warehouse and return a ranked list with severity classification and optimization recommendations.

Frequently Asked Questions about finding-expensive-queries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find the most expensive Snowflake queries driving up warehouse credits?

You can identify costly Snowflake queries by ranking them using ACCOUNT_USAGE QUERY_ATTRIBUTION_HISTORY for cost attribution. This highlights the most expensive performance offenders within a specific time window so you can prioritize fixes.

Why does my Snowflake query have high spillage and how do I fix it?

High spillage in Snowflake queries indicates memory pressure during execution. Enriching query cost data with ACCOUNT_USAGE QUERY_HISTORY metrics detects spillage severity and returns actionable optimization recommendations to fix the performance offenders.

What is the best way to analyze Snowflake query history for poor partition pruning?

Analyzing Snowflake query history for poor partition pruning involves ranking expensive queries and enriching them with ACCOUNT_USAGE QUERY_HISTORY scan metrics. This detects excessive bytes scanned patterns and returns actionable optimization guidance.

Can I prioritize Snowflake query optimization by cost and elapsed time together?

Yes, you can prioritize Snowflake query optimization by ranking queries based on execution cost, elapsed time, and bytes scanned together. This surfaces the top performance offenders across multiple dimensions for targeted optimization work.

Do I need ACCOUNT_USAGE access to identify costly Snowflake query patterns?

Yes, identifying costly Snowflake query patterns requires ACCOUNT_USAGE access. The ranking process specifically relies on QUERY_ATTRIBUTION_HISTORY for cost attribution and QUERY_HISTORY for scan and spillage metrics to detect optimization candidates.

How do I detect repeated query hashes in Snowflake to improve caching?

Detect repeated query hashes in Snowflake by reviewing ranked expensive queries for identical hash patterns. This identifies potential caching opportunities and repeated work, allowing you to apply recommended fixes and reduce warehouse credit waste.