dbt-performance
БесплатноБез исполняемых скриптовНе проверенOptimizing dbt and Snowflake performance through materialization choices, clustering keys, warehouse sizing, and query optimization. Use this skill when…
Об этом скилле
dbt Performance Optimization
Purpose
Transform AI agents into experts on dbt and Snowflake performance optimization, providing guidance on choosing optimal materializations, leveraging Snowflake-specific features, and implementing query optimization patterns for production-grade performance.
When to Use This Skill
Activate this skill when users ask about:
- Optimizing slow dbt model builds
- Choosing appropriate materializations for performance
- Implementing Snowflake clustering keys
- Sizing warehouses appropriately
- Converting models to incremental for performance
- Optimizing query patterns and SQL
- Troubleshooting performance bottlenecks
- Using Snowflake performance features (Gen2, query acceleration, search optimization)
Official Snowflake Documentation: Query Performance
Materialization Performance
Choose the Right Materialization
| Materialization | Build Time | Query Time | Best For |
|---|---|---|---|
| ephemeral | Fast | Varies | Staging, reusable logic |
| view | Instant | Slow | Always-fresh simple transforms |
| table | Slow | Fast | Dimensions, complex logic |
| incremental | Fast | Fast | Large facts (millions+ rows) |
Guidelines:
- Use
ephemeralfor staging (fast, no storage) - Use
tablefor dimensions - Use
incrementalfor large facts
When to Change Materializations
Change Ephemeral/View to Table When
1. Memory Constraints
Queries failing or running slowly due to memory limitations:
-- Change from ephemeral to table
{{ config(materialized='table') }}
2. CTE Reuse
Same intermediate model referenced multiple times downstream:
-- If int_customers__metrics is used by 3+ downstream models
{{ config(materialized='table') }} -- Materialize to avoid re-computation
3. Functions on Join Columns
Transformations in JOIN conditions prevent optimization:
-- ❌ BAD: Functions on join columns (forces full table scans)
select *
from {{ ref('stg_customers') }} c
join {{ ref('stg_orders') }} o
on upper(trim(c.customer_email)) = upper(trim(o.customer_email))
-- ✅ GOOD: Materialize cleaned columns as a table first
{{ config(materialized='table') }}
select
customer_id,
upper(trim(customer_email)) as customer_email_clean -- Pre-compute once
from {{ ref('stg_customers') }}
Performance Impact: Ephemeral → Table trades storage for compute efficiency
Change Table to Incremental When
1. Large Data Volumes
Table has millions+ rows and full refreshes take too long:
{{ config(
materialized='incremental',
unique_key='order_id',
cluster_by=['order_date']
) }}
select * from {{ ref('stg_orders') }}
{% if is_incremental() %}
where order_date > (select max(order_date) from {{ this }})
{% endif %}
2. Append-Only Data
Event logs, clickstreams, transaction history
3. Time-Based Updates
Daily/hourly data loads with time-based filtering
Performance Impact: Table → Incremental reduces build time at cost of added complexity
Snowflake-Specific Optimizations
Clustering Keys
Improve query performance on large tables:
{{ config(
materialized='table',
cluster_by=['order_date', 'customer_id']
) }}
Best Practices:
- Use 1-4 columns maximum
- Order columns by cardinality (low to high)
- Include common WHERE clause columns
- Include JOIN key columns
- Monitor cluster usage:
SYSTEM$CLUSTERING_INFORMATION()
Example with Multiple Keys:
{{ config(
materialized='incremental',
unique_key='event_id',
cluster_by=['event_date', 'event_type', 'user_id']
) }}
Official Snowflake Docs: Clustering Keys
Warehouse Sizing
{{ config(
snowflake_warehouse='LARGE_WH' -- For complex transformations
) }}
Optimal Sizing Goal: ~500 Micropartitions (MPs) per Node
Snowflake stores data in micropartitions (~16MB compressed). The warehouse sizing goal is to maintain approximately 500 MPs scanned per node for optimal performance. Too few MPs per node underutilizes the warehouse; too many causes compute skew and spilling.
Sizing Formula:
Warehouse Size Needed = Total MPs Scanned / 500
Quick Reference Table (MPs scanned → Recommended warehouse):
| MPs Scanned | Warehouse Size | Nodes | MPs per Node |
|---|---|---|---|
| 500 | XS | 1 | 500 |
| 1,000 | S | 2 | 500 |
| 2,000 | M | 4 | 500 |
| 4,000 | L | 8 | 500 |
| 8,000 | XL | 16 | 500 |
| 16,000 | 2XL |
Установить dbt-performance в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл dbt-performance?
Optimizing dbt and Snowflake performance through materialization choices, clustering keys, warehouse sizing, and query optimization. Use this skill when addressing slow model builds, optimizing query performance, sizing warehouses, implementing clustering strategies, or troubleshooting performance issues.
Как установить скилл dbt-performance?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл dbt-performance запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic