sql-optimization skill
인덱싱 전략, 쿼리 분석, 스키마 설계 및 구현 패턴을 통해 데이터베이스 성능을 최적화합니다.
- GitHub 스타
- 23
- 파일
- 1
- 마지막 커밋
- 2026년 11월 11일
- 라이선스
- CC-BY-SA-4.0
- 허용된 도구
- —
sql-optimization skill은 무엇을 하나요?
인덱싱 전략, 쿼리 분석, 스키마 설계 및 구현 패턴을 통해 데이터베이스 성능을 최적화합니다.
skill의 SKILL.md에서 생성된 요약입니다.
sql-optimization skill 정보
쿼리 튜닝과 스키마 설계를 통해 데이터베이스 성능을 개선하는 것이 이 SKILL의 주요 기능입니다. 개발자는 느린 쿼리를 분석하거나, 효율적인 인덱싱 전략을 설계하거나, 더 나은 데이터 패턴을 구현해야 할 때 이 기능을 사용합니다. 에이전트는 복합 인덱스 적용, N+1 문제 방지, 느린 offset limit 대신 커서 기반 페이지네이션 활용 등의 원칙을 적용하여 비효율적인 SQL을 성능이 뛰어난 코드로 변환하기 위해 이 SKILL을 로드해야 합니다.
이 SKILL은 EXPLAIN ANALYZE 출력을 해석하고 순차 스캔(sequential scan)과 인덱스 전용 스캔(index-only scan)을 구분하는 구체적인 가이드를 제공합니다. 또한 쓰기 작업이 많은 워크로드를 위한 정규화나 읽기 속도를 위한 비정규화와 같은 스키마 최적화 기술도 다룹니다. 보안 유지를 위해 이 SKILL은 SQL injection을 방지하기 위한 매개변수화된 문장(parameterized statements) 사용을 강조하며, 운영 데이터베이스 대신 정제된 스테이징 환경에서 성능 벤치마크를 실행할 것을 권장합니다. 또한 복잡한 쿼리로 인한 리소스 고갈을 방지하기 위해 문장 타임아웃(statement timeouts)을 사용할 것을 제안합니다.
agent가 수행할 수 있는 작업
- 1느린 쿼리 실행 계획 분석EXPLAIN ANALYZE 출력을 검토하여 쿼리가 느린 전체 테이블 스캔을 수행하고 있는지 식별합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
sql-optimization skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.플러그인에 sql-optimization skill 설치
/plugin marketplace add andreibesleaga/GABBE /plugin install gabbe-data@gabbe
Claude Code에 sql-optimization skill 설치
~/.claude/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.claude/skills/sql-optimizationClaude Code (project)에 sql-optimization skill 설치
.claude/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization .claude/skills/sql-optimizationCodex에 sql-optimization skill 설치
~/.agents/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.agents/skills/sql-optimizationGemini CLI에 sql-optimization skill 설치
~/.gemini/skills/sql-optimization/SKILL.md
$ npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.gemini/skills/sql-optimizationClaude.ai에 sql-optimization skill 설치
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
자동 검사
2026년 11월 16일에 실행됨전체 보고서 →아직 검증되지 않았습니다. 스킬은 점수 80, 심각한 발견 없음, 검사에 충분한 데이터가 필요합니다. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능andreibesleaga/gabbe/plugins/gabbe-data/skills/sql-optimization is public and reachablegithub.com/andreibesleaga/gabbe/tree/HEAD/plugins/gabbe-data ↗통과
- 오픈 소스 라이선스 (OSI)CC-BY-SA-4.0 is not OSI-approvedspdx.org/licenses/CC-BY-SA-4.0.html ↗결함 발견
- 최근 1년 내 커밋 또는 릴리스Last commit 2026-11-11github.com/andreibesleaga/gabbe/commits ↗통과
- 스크립트에 다운로드 후 실행이나 자격 증명 탈취가 없음No scripts in the skill folder통과
- SKILL.md에 숨겨진 지침 없음No override phrases, safeguard switches, credential requests or hidden charactersgithub.com/andreibesleaga/gabbe/blob/HEAD/plugins/gabbe-data ↗통과
- 사전 허용 도구가 제한됨No pre-approved tools; the agent asks before using onegithub.com/andreibesleaga/gabbe/blob/HEAD/plugins/gabbe-data ↗통과
- SKILL.md가 Agent Skills 형식을 따름Valid name and description; says when to use it; 81 linesgithub.com/andreibesleaga/gabbe/blob/HEAD/plugins/gabbe-data ↗통과
SKILL.md
GitHub에서 보기sql-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.
이 스킬의 파일
1sql-optimization skill 질문
Claude Code에 sql-optimization skill을 어떻게 설치하나요?
npx degit andreibesleaga/GABBE/plugins/gabbe-data/skills/sql-optimization ~/.claude/skills/sql-optimization를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
sql-optimization skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
EXPLAIN ANALYZE를 사용하여 느린 쿼리를 어떻게 식별할 수 있나요?
출력 결과에서 'Seq Scan' 또는 'Full Table Scan'을 확인하십시오. 이는 데이터베이스가 모든 행을 읽고 있음을 나타내며 인덱스가 필요할 수 있습니다.