AGENT SKILL

postgres-perf

PostgreSQL performance optimization and best practices. Use when writing SQL queries, designing schemas, implementing indexes, or debugging database performance. Covers query optimization, connection management, schema design, and RLS.

License 许可
MIT
最近更新
2026-06-07
Stars
★ 0
Forks
1

01 前言 Front Matter

name
postgres-perf
metadata
{ "author": "misskim", "origin": "Concept from Supabase postgres-best-practices, distilled for our use", "version": "1.0" }
description
PostgreSQL performance optimization and best practices. Use when writing SQL queries, designing schemas, implementing indexes, or debugging database performance. Covers query optimization, connection management, schema design, and RLS.

03 SKILL.md 正文

PostgreSQL Performance

DB 쿼리/스키마 작성 시 성능 최적화 가이드.

우선순위별 핵심 규칙

🔴 CRITICAL: 쿼리 성능

-- ❌ 인덱스 없는 WHERE
SELECT * FROM orders WHERE customer_email = 'user@example.com';

-- ✅ 인덱스 생성
CREATE INDEX idx_orders_email ON orders(customer_email);
  • EXPLAIN ANALYZE 습관화 — 실행 계획 항상 확인
  • Seq Scan이 큰 테이블에 나타나면 인덱스 필요
  • SELECT * 금지 → 필요한 컬럼만 선택
  • N+1 쿼리 → JOIN 또는 배치 조회로 교체

🔴 CRITICAL: 커넥션 관리

  • 커넥션 풀 사용 (직접 연결 금지)
  • Supabase → pgBouncer (transaction mode)
  • 서버리스 환경 → 커넥션 풀 필수
  • 유휴 커넥션 정리

🟡 HIGH: 스키마 설계

-- ❌ 무분별한 인덱스
CREATE INDEX idx_everything ON orders(a, b, c, d, e);

-- ✅ 부분 인덱스 (자주 쓰는 조건)
CREATE INDEX idx_active_orders ON orders(created_at)
WHERE status = 'active';
  • 정규화 vs 비정규화 — 읽기 패턴에 맞게 결정
  • UUID vs serial → UUID가 분산 환경에 유리하나 인덱스 크기 큼
  • JSONB → 구조화 불가능한 데이터만, 쿼리 대상이면 컬럼으로

🟢 MEDIUM: 동시성/잠금

  • 대량 UPDATE/DELETE → 배치 처리
  • SELECT ... FOR UPDATE → 필요한 행만 잠금
  • 트랜잭션 최소화 (짧게 유지)
  • 데드락 방지 — 일관된 잠금 순서

🔵 LOW: RLS (Row Level Security)

-- 보안 정책 예시
CREATE POLICY user_data ON user_profiles
  FOR SELECT USING (auth.uid() = user_id);
  • RLS 정책은 인덱스와 함께 설계 (성능 임팩트!)
  • auth.uid() 호출 최소화
  • 복잡한 정책 → EXPLAIN으로 성능 확인

실무 팁

  • 개발 중: EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
  • 프로덕션: 슬로우 쿼리 로그 활성화
  • 마이그레이션: 대용량 테이블 ALTER는 비동기로
  • 백업: NAS에 pg_dump 자동화 가능

04 同仓库更多 Skills

javimosch
javimosch/open-claw-skills

crowd-prompting

A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.

★ 0
javimosch
javimosch/open-claw-skills

ceaser

Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir/UltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).

★ 0
javimosch
javimosch/open-claw-skills

ceaser-send

Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp <subcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir/UltraHonk zero-knowledge proofs.

★ 0
javimosch
javimosch/open-claw-skills

dilemm-ai

Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).

★ 0
javimosch
javimosch/open-claw-skills

moldium

Post and manage content on the Moldium blog platform. Triggered by "post to Moldium", "write a blog post", "publish an article", etc.

★ 0
javimosch
javimosch/open-claw-skills

arxiv-paper-reviews

Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http://weakaccept.top:8000/.

★ 0