From altimateai-data-engineering-skills
Ranks Snowflake queries by cost, time, or data scanned to identify optimization candidates. Activates when users ask about slow/expensive queries, query history, or warehouse cost analysis.
How this skill is triggered — by the user, by Claude, or both
Slash command
/altimateai-data-engineering-skills:finding-expensive-queriesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Query history → Rank by metric → Identify patterns → Recommend optimizations**
Query history → Rank by metric → Identify patterns → Recommend optimizations
Before querying, clarify:
Use QUERY_ATTRIBUTION_HISTORY for credit/cost analysis:
SELECT
query_id,
warehouse_name,
user_name,
credits_attributed_compute,
start_time,
end_time,
query_tag
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_ATTRIBUTION_HISTORY
WHERE start_time >= DATEADD('days', -7, CURRENT_TIMESTAMP())
ORDER BY credits_attributed_compute DESC
LIMIT 20;
Use QUERY_HISTORY for detailed performance metrics (run separately, not joined):
SELECT
query_id,
query_text,
total_elapsed_time/1000 as seconds,
bytes_scanned/1e9 as gb_scanned,
bytes_spilled_to_local_storage/1e9 as gb_spilled_local,
bytes_spilled_to_remote_storage/1e9 as gb_spilled_remote,
partitions_scanned,
partitions_total
FROM SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY
WHERE query_id IN ('<query_id_1>', '<query_id_2>', ...)
AND start_time >= DATEADD('days', -7, CURRENT_TIMESTAMP());
Look for:
credits_attributed_compute queriesquery_hash repeated (caching opportunity)partitions_scanned = partitions_total (no pruning)gb_spilled (memory pressure)Provide:
-- Time range (required)
WHERE start_time >= DATEADD('days', -7, CURRENT_TIMESTAMP())
-- By warehouse
AND warehouse_name = 'ANALYTICS_WH'
-- By user
AND user_name = 'ETL_USER'
-- Only queries over cost threshold
AND credits_attributed_compute > 0.01
-- Only queries over time threshold
AND total_elapsed_time > 60000 -- over 1 minute
npx claudepluginhub joshuarweaver/cascade-featured --plugin altimateai-data-engineering-skillsOptimizes Snowflake queries using clustering keys, materialized views, caching, query profiling, and warehouse tuning. Identifies slow queries and bottlenecks via QUERY_HISTORY.
Fetches Snowflake query profile from a query ID, identifies bottlenecks, and returns an optimized SQL query with expected improvements. Activates when user provides a query_id or mentions slow query/optimization.
Audits SQL for cost and performance anti-patterns (SELECT *, full-table scans, Cartesian joins, etc.), scores warehouse health 0-100, and outputs a prioritized cost-reduction plan for BigQuery, Snowflake, Redshift, and Postgres.