Home / Market / postgresql

postgresql

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

skill★ 507590 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: postgresql description: "Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features" risk: critical source: community date_added: "2026-02-27"

---

PostgreSQL Table Design

Use this skill when

Do not use this skill when

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

Core Rules

PostgreSQL “Gotchas”

Data Types

Do not use the following data types

Table Types

Row-Level Security

Enable with ALTER TABLE tbl ENABLE ROW LEVEL SECURITY. Create policies: CREATE POLICY user_access ON orders FOR SELECT TO app_users USING (user_id = current_user_id()). Built-in user-based access control at the row level.

Constraints

Indexing

Partitioning

Special Considerations

Update-Heavy Tables

Insert-Heavy Workloads