query-hint-tuning

Installation
SKILL.md

Query Hint Tuning (QHRT)

Use this skill when the user wants to optimize a specific query using query hints. This tests multiple hints and compares plans to find the best one.

When to Use

  • User provides a specific slow SELECT query to optimize with hints
  • After identifying CPU, IO, or memory bottlenecks from plan analysis
  • User says "tune this query with hints", "try hints", "optimize with OPTION clause", or "find best hint"
  • Query has suboptimal join strategy, parallelism issues, or cardinality estimation problems

When NOT to Use

  • Query modifies data (INSERT/UPDATE/DELETE) — only safe for SELECT queries
  • User hasn't provided a specific query

Required tools

  • A SQL query tool connected to the target server and database. Prefer, in order: the SQL Tools MCP server that ships with the microsoft-sql-admin plugin (mssql_list_database_connections, mssql_connect_database, then mssql_execute_query); any other SQL tool the agent host provides for running T-SQL and reading result sets; sqlcmd from a terminal. If using the SET-based scripts below instead of a dedicated plan tool, the host must interpret GO batch separators in one session (or explicitly preserve that session between calls), because SET SHOWPLAN_XML and SET STATISTICS XML only apply to the session that sets them. Phase 1 is read-only (plans are compiled, not executed); Phase 2 executes the query and runs only with the user's permission. If the SQL Tools MCP server is not connected or lists no connections, follow the sql-tools-mcp-setup skill, which asks before installing or configuring anything. If no SQL tool can be made available, give the user the T-SQL to run and ask for the results.
Installs
29
GitHub Stars
66
First Seen
11 days ago