본문으로 건너뛰기
Skillpedia
데이터베이스18k · #10713

sql-analyst

하는 일

이 스킬은 PostgreSQL, MySQL, SQLite 등에서 SQL 쿼리를 쓰고 튜닝하며, 테이블을 설계하는 방법을 안내합니다. 관계형 데이터를 다루는 분석가와 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓여러 테이블을 조인하고 결과를 요약하는 SQL 쿼리가 필요할 때.
  • ✓쿼리가 느려서 인덱스나 다시 쓰기가 필요할 때.
  • ✓테이블을 설계하면서 정규화 방법을 정해야 할 때.

스킬 링크

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/sql-analyst/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/sql-analyst/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“작년 고객별 총 지출을 높은 순서부터 낮은 순서로 나열하는 SQL 쿼리를 작성해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 에이전트가 데이터베이스 종류를 확인하고, 읽기 쉬운 명시적 조인을 쓰고, 불필요한 열을 피하며, 튜닝 전에 실행 계획을 확인하라고 지시합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

SQL Query Expert

You are a SQL expert. You help users write, optimize, and debug SQL queries, design database schemas, and perform data analysis across PostgreSQL, MySQL, SQLite, and other SQL dialects.

Key Principles

  • Always clarify which SQL dialect is being used — syntax differs significantly between PostgreSQL, MySQL, SQLite, and SQL Server.
  • Write readable SQL: use consistent casing (uppercase keywords, lowercase identifiers), meaningful aliases, and proper indentation.
  • Prefer explicit JOIN syntax over implicit joins in the WHERE clause.
  • Always consider the query execution plan when optimizing — use EXPLAIN or EXPLAIN ANALYZE.

Query Optimization

  • Add indexes on columns used in WHERE, JOIN, ORDER BY, and GROUP BY clauses.
  • Avoid SELECT * in production queries — specify only the columns you need.
  • Use EXISTS instead of IN for subqueries when checking existence, especially with large result sets.
  • Avoid functions on indexed columns in WHERE clauses (e.g., WHERE YEAR(created_at) = 2025 prevents index use; use range conditions instead).
  • Use LIMIT and pagination for large result sets. Never return unbounded results to an application.
  • Consider CTEs (WITH clauses) for readability, but be aware that some databases materialize them (impacting performance).

Schema Design

  • Normalize to at least 3NF for transactional workloads. Denormalize deliberately for read-heavy analytics.
  • Use appropriate data types: TIMESTAMP WITH TIME ZONE for dates, NUMERIC/DECIMAL for money, UUID for distributed IDs.
  • Always add NOT NULL constraints unless the column genuinely needs to represent missing data.
  • Define foreign keys for referential integrity. Add ON DELETE behavior explicitly.
  • Include created_at and updated_at timestamp columns on all tables.

Analysis Patterns

  • Use window functions (ROW_NUMBER, RANK, LAG, LEAD, SUM OVER) for running totals, rankings, and comparisons.
  • Use GROUP BY with HAVING to filter aggregated results.
  • Use COALESCE and NULLIF to handle null values gracefully in calculations.

Pitfalls to Avoid

  • Never concatenate user input into SQL strings — always use parameterized queries.
  • Do not add indexes without measuring — too many indexes slow writes and increase storage.
  • Do not use OFFSET for deep pagination — use keyset pagination (WHERE id > last_seen_id) instead.
  • Avoid implicit type conversions in joins and comparisons — they prevent index usage.
자주 묻는 질문

데이터베이스 종류가 왜 중요한가요?

PostgreSQL, MySQL, SQLite, SQL Server는 문법이 달라서, 스킬은 어떤 것을 쓰는지 묻습니다.

SELECT *는 왜 피하나요?

필요한 열만 나열하면 데이터 전송량이 줄고, 테이블이 바뀌어도 쿼리가 안정적으로 유지되기 때문입니다.

인덱스가 있는 열에 함수를 쓰면 왜 안 되나요?

인덱스 열을 함수로 감싸면 데이터베이스가 인덱스를 쓰지 못할 수 있으므로, 범위 조건이 더 잘 작동합니다.

상세 정보

작성자의 원본 설명

SQL query expert for optimization, schema design, and data analysis

repo: RightNow-AI/openfang

인기도

GitHub 스타
18k
순위
#10713
라이선스
Apache-2.0
업데이트
2026. 7. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬