Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

azure-sql-optimization

БесплатноБез исполняемых скриптовНе проверен

Azure SQL Database optimization and platform-specific features. PROACTIVELY activate for: (1) Azure SQL Database optimization, (2) DTU vs vCore selection and…

JosiahSiegelот JosiahSiegel★ 67 звёзд на GitHub

Об этом скилле

Azure SQL Database Optimization

Platform-specific optimization for Azure SQL Database.

Quick Reference

Service Tier Comparison

Tier Best For Max Size Key Features
Basic Dev/test, light workloads 2 GB Low cost
Standard General workloads 1 TB S0-S12 DTUs
Premium High I/O, low latency 4 TB P1-P15 DTUs
General Purpose (vCore) Most workloads 16 TB Serverless option
Business Critical High availability 4 TB In-memory, read replicas
Hyperscale Large databases 100 TB Auto-scaling storage

DTU vs vCore

Aspect DTU vCore
Pricing Bundled resources Separate compute/storage
Control Limited Fine-grained
Reserved capacity No Yes (up to 72% savings)
Serverless No Yes (General Purpose)
Best for Simple workloads Predictable, migrated workloads

Performance Monitoring

Resource Consumption

-- Last 15 minutes (avg 15-second intervals)
SELECT
    end_time,
    avg_cpu_percent,
    avg_data_io_percent,
    avg_log_write_percent,
    avg_memory_usage_percent,
    max_worker_percent,
    max_session_percent
FROM sys.dm_db_resource_stats
ORDER BY end_time DESC;

-- Historical (last 14 days, hourly)
SELECT
    start_time,
    end_time,
    avg_cpu_percent,
    avg_data_io_percent,
    avg_log_write_percent
FROM sys.resource_stats
WHERE database_name = DB_NAME()
ORDER BY start_time DESC;

Query Performance Insight

-- Top CPU consumers last hour
SELECT TOP 20
    qt.query_sql_text,
    rs.avg_cpu_time / 1000 AS avg_cpu_ms,
    rs.count_executions,
    rs.avg_cpu_time * rs.count_executions / 1000 AS total_cpu_ms
FROM sys.query_store_query q
JOIN sys.query_store_query_text qt ON q.query_text_id = qt.query_text_id
JOIN sys.query_store_plan p ON q.query_id = p.query_id
JOIN sys.query_store_runtime_stats rs ON p.plan_id = rs.plan_id
JOIN sys.query_store_runtime_stats_interval rsi ON rs.runtime_stats_interval_id = rsi.runtime_stats_interval_id
WHERE rsi.start_time >= DATEADD(hour, -1, GETUTCDATE())
ORDER BY rs.avg_cpu_time * rs.count_executions DESC;

Automatic Tuning

Enable Automatic Tuning

-- Enable all auto-tuning options
ALTER DATABASE current
SET AUTOMATIC_TUNING (
    FORCE_LAST_GOOD_PLAN = ON,
    CREATE_INDEX = ON,
    DROP_INDEX = ON
);

-- Check current settings
SELECT * FROM sys.database_automatic_tuning_options;

View Tuning Recommendations

-- Current recommendations
SELECT
    name,
    reason,
    score,
    state_desc,
    is_revertable_action,
    is_executable_action,
    details
FROM sys.dm_db_tuning_recommendations;

Apply Recommendations

-- Force a specific query plan
EXEC sp_query_store_force_plan @query_id = 12345, @plan_id = 67890;

-- Unforce plan
EXEC sp_query_store_unforce_plan @query_id = 12345, @plan_id = 67890;

Hyperscale Features

Storage Auto-Scaling

  • Automatically grows up to 128 TB
  • No need to pre-provision storage
  • Pay only for storage used

Read Scale-Out

-- Connection string option
ApplicationIntent=ReadOnly

-- In application code
"Server=myserver.database.windows.net;Database=mydb;ApplicationIntent=ReadOnly;..."

Named Replicas

-- Create named replica
ALTER DATABASE MyDatabase
ADD SECONDARY ON SERVER MySecondaryServer
WITH (SERVICE_OBJECTIVE = 'HS_Gen5_2', SECONDARY_TYPE = Named, NAME = N'MyReadReplica');

Serverless Configuration

Configure Auto-Pause

-- Via Azure Portal, CLI, or PowerShell
-- Set auto-pause delay (minutes), min/max vCores

-- Check current usage
SELECT
    cpu_percent,
    auto_pause_delay_in_minutes_configured
FROM sys.dm_db_resource_stats_serverless;

Serverless Best Practices

  1. Use for intermittent workloads - Saves cost during idle periods
  2. Set appropriate min vCores - Prevents cold starts for time-sensitive apps
  3. Monitor auto-pause - Auto-resume adds latency
  4. Consider always-on for consistent workloads - Provisioned may be cheaper

Connection Optimization

Connection Pooling

// .NET connection string
"Server=tcp:myserver.database.windows.net,1433;Database=mydb;
 Min Pool Size=10;Max Pool Size=100;Connection Timeout=30;"

Retry Logic

// Azure SQL requires retry logic for transient faults
var options = new SqlRetryLogicOption()
{
    NumberOfTries = 5,
    DeltaTime = TimeSpan.FromSeconds(1),
    MaxTimeInterval = TimeSpan.FromSeconds(30)
};

Connection Best Practices

  1. Use connection pooling - Reduce connection overhead
  2. Implement retry logic - Handle transient faults (error 40613, 40197)
  3. Use redirect connection mode - Better performance after initial connection
  4. Close connections promptly - Don't hold connections unnecessarily

Azure-Specific Limitations

Not Supported

  • SQL Agent (use Azure Functions, Logic Apps)
  • BULK INSERT from files (u
Полный SKILL.md на GitHub

Установить azure-sql-optimization в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл azure-sql-optimization?

Azure SQL Database optimization and platform-specific features. PROACTIVELY activate for: (1) Azure SQL Database optimization, (2) DTU vs vCore selection and right-sizing, (3) automatic tuning (force last good plan, create/drop index), (4) Hyperscale tier and read replicas, (5) Serverless tier and auto-pause, (6) Azure SQL performance monitoring (Query Performance Insight, Intelligent Insights), (7) elastic pools, (8) Always Encrypted with secure enclaves, (9) Managed Instance vs Azure SQL DB tradeoffs, (10) failover groups and geo-replication. Provides: tier-selection matrix, automatic-tuning enablement steps, Hyperscale architecture overview, monitoring queries, and elastic pool sizing guidance.

Как установить скилл azure-sql-optimization?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл azure-sql-optimization запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить azure-sql-optimization с