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

postgresql

하는 일

이 에이전트는 PostgreSQL 데이터베이스의 구조(스키마)를 설계하도록 돕습니다. 가장 적합한 데이터 타입, 규칙(제약 조건), 인덱스 및 기타 최적화를 제안해 데이터베이스가 잘 작동하고 유지보수하기 쉽게 합니다.

사용하는 경우

  • ✓새 프로젝트를 시작하고 데이터를 어떻게 정리할지 정해야 할 때.
  • ✓기존 데이터베이스를 더 나은 성능을 위해 최적화해야 할 때.
  • ✓각 열에 맞는 정보 타입(예: 텍스트, 숫자, 날짜)을 고를 때.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/postgresql/SKILL.md

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

사용 방법

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

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

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

AI에게 요청하는 예시

“온라인 스토어를 위한 데이터베이스 스키마를 설계해야 합니다. 고객, 제품, 주문 정보를 정리하고 싶습니다.”

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

작동 방식

에이전트는 저장할 정보의 종류와 접근 방식 같은 요구 사항을 분석합니다. 이를 바탕으로 최적화된 구조를 제안하고, 가장 알맞은 데이터 타입을 고르며, 검색 속도를 높이는 인덱스를 제안합니다.

기술 내용 (원본 SKILL.md)

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

PostgreSQL Table Design

Use this skill when

  • Designing a schema for PostgreSQL
  • Selecting data types and constraints
  • Planning indexes, partitions, or RLS policies
  • Reviewing tables for scale and maintainability

Do not use this skill when

  • You are targeting a non-PostgreSQL database
  • You only need query tuning without schema changes
  • You require a DB-agnostic modeling guide

Instructions

  1. Capture entities, access patterns, and scale targets (rows, QPS, retention).
  2. Choose data types and constraints that enforce invariants.
  3. Add indexes for real query paths and validate with EXPLAIN.
  4. Plan partitioning or RLS where required by scale or access control.
  5. Review migration impact and apply changes safely.

Safety

  • Avoid destructive DDL on production without backups and a rollback plan.
  • Use migrations and staging validation before applying schema changes.

Core Rules

  • Define a PRIMARY KEY for reference tables (users, orders, etc.). Not always needed for time-series/event/log data. When used, prefer BIGINT GENERATED ALWAYS AS IDENTITY; use UUID only when global uniqueness/opacity is needed.
  • Normalize first (to 3NF) to eliminate data redundancy and update anomalies; denormalize only for measured, high-ROI reads where join performance is proven problematic. Premature denormalization creates maintenance burden.
  • Add NOT NULL everywhere it’s semantically required; use DEFAULTs for common values.
  • Create indexes for access paths you actually query: PK/unique (auto), FK columns (manual!), frequent filters/sorts, and join keys.
  • Prefer TIMESTAMPTZ for event time; NUMERIC for money; TEXT for strings; BIGINT for integer values, DOUBLE PRECISION for floats (or NUMERIC for exact decimal arithmetic).

PostgreSQL “Gotchas”

  • Identifiers: unquoted → lowercased. Avoid quoted/mixed-case names. Convention: use snake_case for table/column names.
  • Unique + NULLs: UNIQUE allows multiple NULLs. Use UNIQUE (...) NULLS NOT DISTINCT (PG15+) to restrict to one NULL.
  • FK indexes: PostgreSQL does not auto-index FK columns. Add them.
  • No silent coercions: length/precision overflows error out (no truncation). Example: inserting 999 into NUMERIC(2,0) fails with error, unlike some databases that silently truncate or round.
  • Sequences/identity have gaps (normal; don't "fix"). Rollbacks, crashes, and concurrent transactions create gaps in ID sequences (1, 2, 5, 6...). This is expected behavior—don't try to make IDs consecutive.
  • Heap storage: no clustered PK by default (unlike SQL Server/MySQL InnoDB); CLUSTER is one-off reorganization, not maintained on subsequent inserts. Row order on disk is insertion order unless explicitly clustered.
  • MVCC: updates/deletes leave dead tuples; vacuum handles them—design to avoid hot wide-row churn.

Data Types

  • IDs: BIGINT GENERATED ALWAYS AS IDENTITY preferred (GENERATED BY DEFAULT also fine); UUID when merging/federating/used in a distributed system or for opaque IDs. Generate with uuidv7() (preferred if using PG18+) or gen_random_uuid() (if using an older PG version).
  • Integers: prefer BIGINT unless storage space is critical; INTEGER for smaller ranges; avoid SMALLINT unless constrained.
  • Floats: prefer DOUBLE PRECISION over REAL unless storage space is critical. Use NUMERIC for exact decimal arithmetic.
  • Strings: prefer TEXT; if length limits needed, use CHECK (LENGTH(col) <= n) instead of VARCHAR(n); avoid CHAR(n). Use BYTEA for binary data. Large strings/binary (>2KB default threshold) automatically stored in TOAST with compression. TOAST storage: PLAIN (no TOAST), EXTENDED (compress + out-of-line), EXTERNAL (out-of-line, no compress), MAIN (compress, keep in-line if possible). Default EXTENDED usually optimal. Control with ALTER TABLE tbl ALTER COLUMN col SET STORAGE strategy and ALTER TABLE tbl SET (toast_tuple_target = 4096) for threshold. Case-insensitive: for locale/accent handling use non-deterministic collations; for plain ASCII use expression indexes on LOWER(col) (preferred unless column needs case-insensitive PK/FK/UNIQUE) or CITEXT.
  • Money: NUMERIC(p,s) (never float).

…

자주 묻는 질문

‘데이터 타입’이란 무엇인가요?

열에 무엇을 저장할 수 있는지 정의하는 범주입니다. 예를 들어 이름에는 ‘텍스트’, 나이에는 ‘정수’, 생일에는 ‘날짜’를 씁니다.

‘인덱스’란 무엇인가요?

책 뒤의 색인과 같습니다. 모든 내용을 읽지 않고도 데이터베이스가 특정 정보를 훨씬 빨리 찾게 합니다.

‘스키마’란 무엇인가요?

데이터베이스의 청사진이나 전체 구조입니다. 어떤 테이블이 있는지, 각 테이블에 어떤 열이 있는지, 서로 어떻게 연결되는지 정의합니다.

상세 정보

작성자의 원본 설명

Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5474
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬