sql-optimizer

Analyze MyBatis SQL to identify performance bottlenecks and provide optimization recommendations.

1|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/xmx0632/claude-code-demo --skill sql-optimizer-xmx0632
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-optimizer
Source: https://github.com/xmx0632/claude-code-demo/tree/main/Skills-Collection/sql-optimizer
Command: npx skills add https://github.com/xmx0632/claude-code-demo --skill sql-optimizer-xmx0632

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

在 MyBatis 项目中,SQL 编写不当常导致查询慢、缺少索引、N+1 问题等。此技能会分析 Mapper XML 和注解中的 SQL,识别瓶颈并给出具体的优化建议以提升性能。

Core Features & Use Cases

  • 分析 Mapper XML 与注解中的 SQL,发现索引缺失、低效模式和常见性能反模式。
  • 生成可执行的优化方案,包括添加或调整索引、查询重写、批处理方案等。
  • 使用场景:在 MyBatis 项目中,运行 sql-optimizer 以获得一个优先级排序的修改清单,降低查询延迟和资源消耗。

Quick Start

请提供要分析的 Mapper 文件以生成优化报告。

Frequently Asked Questions about sql-optimizer

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

FAQPage Schema
How do I optimize slow MyBatis SQL queries and fix N+1 problems?

Analyzing MyBatis Mapper XML and annotation-based queries identifies missing indexes and N+1 problem patterns. It delivers a prioritized modification list with query rewriting and batch processing recommendations to reduce query latency and resource consumption.

What is the best way to detect full-table scans in MyBatis Mapper files?

Detecting full-table scans in MyBatis Mapper files involves parsing SQL statements from XML and annotations to identify anti-patterns. It provides specific optimization guidance to ensure efficient indexing and minimize full-table scans across Java projects.

Can I run MyBatis SQL analysis safely within a CI pipeline or code review?

Yes, you can run MyBatis SQL analysis safely within a CI pipeline or code review. The parsing and pattern detection execute safely in code review contexts, delivering actionable optimization guidance without modifying production data.

Does MyBatis query tuning work with both XML Mappers and annotation-based queries?

MyBatis query tuning works with both XML Mappers and annotation-based queries across Java projects. It analyzes SQL from both formats to identify performance bottlenecks and provides optimization recommendations like adding indexes or rewriting queries.

How to generate a prioritized modification list for MyBatis SQL performance bottlenecks?

To generate a prioritized modification list for MyBatis SQL performance bottlenecks, analyze Mapper files to detect inefficient patterns. The output delivers executable optimization schemes including index adjustments and batch processing to lower query latency.

Why does my MyBatis query lack efficient indexing and how can I fix it?

Your MyBatis query lacks efficient indexing due to anti-patterns in the SQL logic. You can fix it by parsing Mapper XML to detect the bottleneck and applying generated recommendations for adding or adjusting indexes.