sql-optimization Skill
Optimiere die Datenbankperformance durch Indexing-Strategien, Query-Analyse, Schema-Design und Implementierungsmuster.
- GitHub Stars
- 23
- Dateien
- 1
- Letzter Commit
- 11. Nov. 2026
- Lizenz
- CC-BY-SA-4.0
- Erlaubte Tools
- —
Was macht der sql-optimization Skill?
Optimiere die Datenbankperformance durch Indexing-Strategien, Query-Analyse, Schema-Design und Implementierungsmuster.
Zusammenfassung erzeugt aus der SKILL.md des Skills.
Über den sql-optimization skill
Die Hauptfunktion dieses Skills ist die Verbesserung der Datenbankperformance durch Query-Tuning und Schema-Design. Entwickler nutzen ihn, wenn sie langsame Queries analysieren, effiziente Indexing-Strategien entwerfen oder bessere Datenmuster implementieren müssen. Ein Agent sollte diesen Skill laden, um ineffizientes SQL in performanten Code zu verwandeln, indem er Prinzipien wie Composite Indexing anwendet, N+1-Probleme vermeidet und cursor-basierte Pagination anstelle von langsamen Offset-Limits nutzt.
Der Skill bietet spezifische Anleitung zur Interpretation von EXPLAIN ANALYZE-Outputs und unterscheidet zwischen Sequential Scans und Index-only Scans. Er deckt zudem Techniken zur Schema-Optimierung ab, wie etwa Normalisierung für schreibintensive Workloads oder Denormalisierung für schnellere Lesezugriffe. Um die Sicherheit zu gewährleisten, legt der Skill Wert auf die Verwendung von Parameterized Statements zur Vermeidung von SQL-Injection und empfiehlt, Performance-Benchmarks in bereinigten Staging-Umgebungen statt in Produktionsdatenbanken durchzuführen. Zudem wird empfohlen, Statement Timeouts zu nutzen, um eine Ressourcenerschöpfung durch komplexe Queries zu verhindern.
Was ein agent damit machen kann
- 1Analyse von langsamen Query-Execution-PlansUntersuche einen EXPLAIN ANALYZE-Output, um festzustellen, ob eine Query einen langsamen Full Table Scan durchführt.
Geschrieben basierend auf dem SKILL.md des skills. Jeder use case wurde gegen ein zitat daraus geprüft.
So installierst du den sql-optimization Skill
Jeder Befehl kopiert den Skill-Ordner in das Skills-Verzeichnis des Clients. Starte den Client neu oder beginne eine neue Session, um ihn zu laden.Den sql-optimization Skill in Plugin installieren
/plugin marketplace add andreibesleaga/GABBE /plugin install gabbe-data@gabbe
Den sql-optimization Skill in Claude Code installieren
~/.claude/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.claude/skills/sql-optimizationDen sql-optimization Skill in Claude Code (project) installieren
.claude/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization .claude/skills/sql-optimizationDen sql-optimization Skill in Codex installieren
~/.agents/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.agents/skills/sql-optimizationDen sql-optimization Skill in Gemini CLI installieren
~/.gemini/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.gemini/skills/sql-optimizationDen sql-optimization Skill in Claude.ai installieren
npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization sql-optimization && zip -r sql-optimization.zip sql-optimization # claude.ai → Customize → Skills → + → Create skill → Upload a skill → sql-optimization.zip
Automatisierte Checks
Geluften am 16. Nov. 2026Vollständiger Bericht →Noch nicht verifiziert. Ein Skill braucht 80 Punkte, keinen schweren Befund und genug Daten für unsere Prüfung. Wie die Checks funktionieren · Was du für mehr Punkte verbessern kannst
- Source Repository verknüpft und erreichbarandreibesleaga/gabbe/plugins/gabbe-data/skills/sql-optimization is public and reachablegithub.com/andreibesleaga/gabbe/tree/HEAD/plugins/gabbe-data ↗Bestanden
- Open Source Lizenz (OSI)CC-BY-SA-4.0 is not OSI-approvedspdx.org/licenses/CC-BY-SA-4.0.html ↗Befund
- Commit oder Release im letzten JahrLast commit 2026-11-11github.com/andreibesleaga/gabbe/commits ↗Bestanden
- Keine Download-und-Ausführen-Muster oder Zugangsdatendiebstahl in SkriptenNo scripts in the skill folderBestanden
- Keine versteckten Anweisungen in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/andreibesleaga/gabbe/blob/HEAD/plugins/gabbe-data ↗Bestanden
- Vorab erlaubte Tools sind eingeschränktNo pre-approved tools; the agent asks before using onegithub.com/andreibesleaga/gabbe/blob/HEAD/plugins/gabbe-data ↗Bestanden
- SKILL.md folgt dem Agent-Skills-FormatValid name and description; says when to use it; 81 linesgithub.com/andreibesleaga/gabbe/blob/HEAD/plugins/gabbe-data ↗Bestanden
SKILL.md
Auf GitHub ansehensql-optimization Skill
Goal
This skill focuses on ensuring database interactions are performant and scalable.
Steps
1. The Golden Rule: Indexing
- Primary Keys: Always indexed by default (B-Tree).
- Foreign Keys: MUST be indexed manually in most DBs (Postgres/MySQL) to avoid full table scans on joins.
- Where Clauses: Columns used in
WHERE,ORDER BY,GROUP BYneed indexes. - Composite Indexes: Order matters!
(last_name, first_name)supports lookup bylast_nameORlast_name + first_name, but NOT byfirst_namealone.
2. Analyzing Queries (EXPLAIN ANALYZE)
Always run EXPLAIN ANALYZE on suspect queries.
| Output Term | Meaning | Action |
|---|---|---|
| Seq Scan / Full Table Scan | Reading every row. | Bad (unless table is tiny). Add an index. |
| Index Scan | Reading index + looking up heap. | Good. |
| Index Only Scan | Reading only index. | Best. (Covering Index). |
| Nested Loop | Looping for joins. | Fine for small datasets. Bad for large. |
| Hash Join | Building hash table for join. | Good for large datasets. |
3. Implementation Patterns
1. Select Only What You Need
- Bad:
SELECT * FROM users - Good:
SELECT id, name FROM users - Reason: Reduces IO, network payload, and memory usage.
2. Solve the N+1 Problem
- Problem: Fetching 100 posts, then running 100 queries to get authors.
- Fix: Use
JOINor eager loading (ORM specific:include,with). - Detection: Use logs or APM query counts.
3. Pagination
- Offset/Limit:
OFFSET 1000000is slow (DB scans 1M rows then discards). - Cursor/Keyset:
WHERE id > last_seen_id LIMIT 10. O(1) performance.
4. Transactions
- Keep them short.
- Don't make external API calls inside a DB transaction (holds locks).
4. Schema Optimization
- Normalization (3NF): Reduces redundancy, ensures integrity. Good for write-heavy.
- Denormalization: Adds redundancy for read speed (e.g., storing
author_nameonpoststable). - Data Types: Use the smallest needed type.
VARCHAR(255)vsTEXT(Postgres treats similar, MySQL differs).INTvsBIGINT.JSONB(Postgres) for unstructured data, but don't overuse it.
5. Maintenance
- Run
VACUUM ANALYZE(Postgres) regularly to update planner statistics. - Monitor index usage. Remove unused indexes (they slow down writes).
Security & Guardrails
1. Skill Security (SQL Optimization)
- Query Parameterization: Optimized queries must always use parameterized statements or prepared statements to prevent SQL Injection (SQLi). Never concatenate strings for query building.
- Safe EXPLAIN Execution: Be cautious when running
EXPLAIN ANALYZE, as it actually executes the query. On production, ensure it is only run onSELECTstatements, as running it onINSERT/UPDATE/DELETEwill modify data.
2. System Integration Security
- Resource Exhaustion Prevention: Limit the execution time of optimized queries (e.g.,
statement_timeoutin Postgres) to prevent Denial of Service (DoS) attacks via complex, CPU-intensive queries. - Data Exposure Restrictions: When optimizing
SELECTqueries or adding denormalized columns, ensure that access control rules (Row-Level Security) are maintained and sensitive columns are not inadvertently exposed.
3. LLM & Agent Guardrails
- SQLi Generation Defense: LLMs tasked with optimizing SQL must be strictly instructed and verified to output parameterized queries, rejecting user inputs that attempt to inject raw SQL commands.
- Execution Sandboxing: Agents must not execute optimized queries directly against production databases. Performance benchmarking must be done in a sanitized, ephemeral staging environment.
- Data Masking in Context: When feeding slow queries and
EXPLAINplans into an LLM for analysis, all literal values (e.g., specific user emails, IDs) must be masked or redacted to prevent PII leakage into the model's context.
Dateien in diesem Skill
1sql-optimization Skill-Fragen
Wie installiere ich den sql-optimization Skill in Claude Code?
Führe npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.claude/skills/sql-optimization aus. Claude Code lädt Skills aus ~/.claude/skills (alle Projekte) oder .claude/skills (ein Projekt) und nutzt einen Skill, wenn seine Beschreibung zur Aufgabe passt.
Welche Clients können den sql-optimization Skill nutzen?
Jeder Client, der das Agent Skills-Format liest: Claude Code, Codex, Gemini CLI und claude.ai (als ZIP hochladen). Skripte im Skill laufen nur dort, wo der Client Codeausführung erlaubt.
Wie kann ich langsame Queries mit EXPLAIN ANALYZE identifizieren?
Du kannst im Output nach 'Seq Scan' oder 'Full Table Scan' suchen. Das deutet darauf hin, dass die Datenbank jede Zeile liest und eventuell einen Index benötigt.