Query Optimization

🌐Community
by josiahsiegel · vlatest · Repository

Helps with querying, optimization as part of agent workflows workflows.

Install on your platform

We auto-selected Claude Code based on this skill’s supported platforms.

1

Run in terminal (recommended)

terminal
claude mcp add query-optimization npx -- -y @trustedskills/query-optimization
2

Or manually add to ~/.claude/settings.json

~/.claude/settings.json
{
  "mcpServers": {
    "query-optimization": {
      "command": "npx",
      "args": [
        "-y",
        "@trustedskills/query-optimization"
      ]
    }
  }
}

Requires Claude Code (claude CLI). Run claude --version to verify your install.

About This Skill

What it does

This skill provides a comprehensive guide to T-SQL query optimization techniques, enabling AI agents to analyze and improve database queries. It focuses on identifying non-SARGable patterns, understanding join type performance characteristics, and utilizing query hints for enhanced efficiency. The goal is to help agents generate more performant SQL queries within agent workflows.

When to use it

  • When an AI agent needs to optimize existing T-SQL queries for improved performance.
  • When designing new database queries and needing guidance on SARGable patterns.
  • To understand the tradeoffs between different join types (Nested Loop, Merge Join, Hash Join).
  • When troubleshooting slow query execution times and identifying potential bottlenecks.

Key capabilities

  • SARGability Identification: Distinguishes between SARGable (index-seeking) and non-SARGable query patterns with examples.
  • Join Type Performance Analysis: Provides a comparison of Nested Loop, Merge Join, and Hash Join types, outlining their best use cases and characteristics.
  • Query Hint Reference: Offers a quick reference guide to T-SQL query hints for controlling compilation, optimization, parallelism, and data access.
  • Implicit Conversion Awareness: Highlights the importance of avoiding implicit data type conversions in queries.

Example prompts

  • "Can you rewrite this SQL query to be more SARGable?" [followed by a non-SARGable query]
  • "What are the performance characteristics of a Nested Loop join compared to a Hash Join?"
  • "How can I use query hints to limit parallelism in my T-SQL query?"

Tips & gotchas

  • This skill focuses specifically on T-SQL query optimization.
  • Understanding database indexes is crucial for effectively applying the techniques described within this guide.
  • Be mindful of potential dirty reads when using WITH (NOLOCK).

Tags

🛡️

TrustedSkills Verification

Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.

Security Audits

Gen Agent Trust HubPass
SocketPass
SnykPass

Details

Version
vlatest
License
Author
josiahsiegel
Installs
51

🌐 Community

Passed automated security scans.