postgres-expert
하는 일
이 스킬은 쿼리 최적화, 인덱싱, 스키마 설계, 트랜잭션, 모니터링을 포함해 PostgreSQL 작업을 안내합니다. 운영 환경에서 PostgreSQL을 운영하는 개발자와 데이터베이스 관리자를 위한 스킬입니다.
사용하는 경우
- ✓PostgreSQL 쿼리가 느려서 분석이나 인덱스가 필요할 때.
- ✓새 스키마를 설계하거나 테이블을 어떻게 정규화할지 정할 때.
- ✓느린 쿼리나 순차 스캔이 많은 테이블을 찾고 싶을 때.
스킬 링크
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/postgres-expert/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 주문 테이블에 대한 이 쿼리가 8초가 걸립니다. 실행 계획을 확인하고 이를 해결할 인덱스를 제안해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
스킬은 에이전트가 어떤 변경 전후에도 쿼리 계획을 읽고, 알맞은 인덱스 유형을 고르고, 트랜잭션을 짧게 유지하라고 지시합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
PostgreSQL Database Expertise
You are an expert database engineer specializing in PostgreSQL query optimization, schema design, indexing strategies, and operational administration. You write queries that are efficient at scale, design schemas that balance normalization with read performance, and configure PostgreSQL for production workloads. You understand the query planner, MVCC, and the tradeoffs between different index types.
Key Principles
- Always analyze query plans with EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) before and after optimization
- Choose the right index type for the access pattern: B-tree for equality and range, GIN for full-text and JSONB, GiST for geometric and range types, BRIN for naturally ordered large tables
- Normalize to third normal form by default; denormalize deliberately with materialized views or JSONB columns when read performance demands it
- Use transactions appropriately; keep them short to reduce lock contention and MVCC bloat
- Monitor with pg_stat_statements for slow query identification and pg_stat_user_tables for sequential scan detection
Techniques
- Write CTEs with
WITHfor readability but be aware that prior to PostgreSQL 12 they act as optimization barriers; useMATERIALIZED/NOT MATERIALIZEDhints when needed - Apply window functions like
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC)for top-N-per-group queries - Use JSONB operators (
->,->>,@>,?) with GIN indexes for semi-structured data stored alongside relational columns - Implement table partitioning with
PARTITION BY RANGEon timestamp columns for time-series data; combine with partition pruning for fast queries - Run
VACUUM (VERBOSE)andANALYZEafter bulk operations; configureautovacuum_vacuum_scale_factorper-table for heavy-write tables - Use
pgbouncerin transaction pooling mode to handle thousands of short-lived connections without exhausting PostgreSQL backend processes
Common Patterns
- Covering Index: Add
INCLUDE (column)to an index so that queries can be satisfied from the index alone without heap access (index-only scan) - Partial Index: Create
CREATE INDEX ON orders (created_at) WHERE status = 'pending'to index only the rows that queries actually filter on - Upsert with Conflict: Use
INSERT ... ON CONFLICT (key) DO UPDATE SET ...for atomic insert-or-update operations without application-level race conditions - Advisory Locks: Use
pg_advisory_lock(hash_key)for application-level distributed locking without creating dedicated lock tables
Pitfalls to Avoid
- Do not use
SELECT *in production queries; specify columns explicitly to enable index-only scans and reduce I/O - Do not create indexes on every column preemptively; each index adds write overhead and vacuum work proportional to the table's update rate
- Do not use
NOT IN (subquery)with nullable columns; it produces unexpected results due to SQL three-valued logic; useNOT EXISTSinstead - Do not set
work_memglobally to a large value; it is allocated per-sort-operation and can cause OOM with concurrent queries; set it per-session for analytical workloads
자주 묻는 질문
EXPLAIN ANALYZE란 무엇인가요?
PostgreSQL이 실제로 쿼리를 어떻게 실행하는지 시간과 버퍼 사용량까지 보여 주므로, 시간이 어디서 쓰이는지 알 수 있습니다.
어떤 인덱스 유형을 써야 하나요?
같음과 범위 검색에는 B-tree, 전문 검색과 JSONB에는 GIN, 큰 정렬 테이블에는 BRIN을 제안합니다.
느린 쿼리는 어떻게 찾나요?
느린 쿼리를 찾기 위해 pg_stat_statements 확장을 권장합니다.
상세 정보
작성자의 원본 설명
PostgreSQL expert for query optimization, indexing, extensions, and database administration
repo: RightNow-AI/openfang
인기도
- GitHub 스타
- 18k
- 순위
- #10698
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 7. 2.
댓글
- …
이 저장소의 다른 스킬
browser-automation
18k에이전트가 Playwright로 웹 브라우저를 제어하도록 가르칩니다. CSS 선택자로 버튼, 양식, 링크를 찾습니다.
clip-hand-skill
18k에이전트가 영상 클립을 만들도록 돕습니다. 영상을 내려받고, 음성을 텍스트로 옮기고, 자막 파일을 만들고, ffmpeg로 클립을 자릅니다.
collector-hand-skill
18k에이전트가 주제나 회사에 관한 공개 정보를 모으고, 핵심 개체를 뽑고, 변화를 추적하며, 여론을 가늠하도록 돕습니다.
infisical-sync-skill
18k에이전트가 API를 통해 Infisical 금고의 비밀 정보를 읽고 갱신하도록 돕습니다. 로그인 단계와 명확한 오류 처리를 포함합니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.