sql-optimization

Optimize slow SQL queries across MySQL, PostgreSQL, SQL Server, and Oracle.

Updated Apr 15, 2026
One-click install
npx skills add https://github.com/Udaradg/ai-coding-assistants --skill sql-optimization-udaradg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimization
Source: https://github.com/Udaradg/ai-coding-assistants/tree/main/.github/skills/sql-optimization
Command: npx skills add https://github.com/Udaradg/ai-coding-assistants --skill sql-optimization-udaradg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Inefficient SQL queries and missing indexes cause slow performance and high resource consumption across databases, hindering application responsiveness and increasing costs.

Core Features & Use Cases

  • Query analysis: Detect anti‑patterns and recommend rewrites for faster execution.
  • Index strategy: Suggest composite, partial, and covering indexes tailored to MySQL, PostgreSQL, SQL Server, and Oracle.
  • Advanced techniques: Apply window functions, batch operations, temporary tables, and cursor‑based pagination.
  • Performance monitoring: Provide sample commands to inspect slow‑query logs for each supported database.

Use case: Optimize a sales reporting query that scans millions of rows by adding the right indexes and rewriting subqueries.

Quick Start

Analyze and optimize the performance of my SELECT query on the orders table.

Frequently Asked Questions about sql-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize slow SQL queries across different databases?

To optimize slow SQL queries, you need execution plan analysis and index suggestions tailored to your specific database. This process detects anti-patterns and recommends rewrites, applying index strategies and batch operations to reduce resource consumption.

Does this SQL query tuning approach work with PostgreSQL and MySQL?

Yes, SQL query tuning applies to PostgreSQL, MySQL, SQL Server, and Oracle. It provides tailored index strategies like composite, partial, and covering indexes, ensuring performance optimization techniques fit your specific database engine.

What is the best way to design indexes for a table scanning millions of rows?

The best way to design indexes for large tables is applying composite, partial, and covering indexes based on execution plan analysis. This targeted index strategy prevents full table scans and significantly boosts query speed.

How do I use execution plan analysis to fix SQL anti-patterns?

Execution plan analysis identifies inefficient operations like full table scans or poorly performing subqueries. By detecting these anti-patterns, you can apply recommended query rewrites, utilize window functions, and implement temporary tables for faster execution.

How do I implement cursor-based pagination for large batch operations?

Cursor-based pagination for large batch operations is implemented using advanced SQL techniques that replace offset-based fetching. This method applies window functions and batch operations to process millions of rows efficiently without performance degradation.

How do I inspect slow-query logs for performance monitoring?

To inspect slow-query logs for performance monitoring, you use specific sample commands provided for each supported database. This helps identify high resource consumption queries, allowing you to apply targeted optimization and index design strategies.