Skip to content
Back to skills

Public Postgres Expert Base

ASecurity

PostgreSQL 知识基座。覆盖 Schema Design、Indexing(B-Tree/GIN/GiST/BRIN)、JSONB、Partitioning、Extensions。供 devlab-postgres-usage 通过 extends 继承。

  • 21 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 4, 2026
ai-agentssqlexpressrailsgitdatabaseperformance

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 4, 2026

npx -y skills add seed-forge/harness-ai-kit --skill public-postgres-expert-base --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Public Postgres Expert Base?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Public Postgres Expert Base
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/seed-forge-public-postgres-expert-base/badge)](https://www.skillsdirectory.com/skills/seed-forge-public-postgres-expert-base)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: public-postgres-expert-base
description: PostgreSQL 知识基座。覆盖 Schema Design、Indexing(B-Tree/GIN/GiST/BRIN)、JSONB、Partitioning、Extensions。供 devlab-postgres-usage 通过 extends 继承。
---

# PostgreSQL Knowledge Base

> **Source**: Adapted from [planetscale/database-skills](https://github.com/planetscale/database-skills) (PostgreSQL skill).

## Schema Design
- Prefer `BIGSERIAL` or `BIGINT GENERATED ALWAYS AS IDENTITY` for PKs.
- Use `TIMESTAMPTZ` (with timezone) over `TIMESTAMP`.
- `TEXT` and `VARCHAR` have similar performance in PostgreSQL — prefer `TEXT` unless length constraint is meaningful.
- Use `NUMERIC` for money, never `FLOAT`/`REAL`.
- `JSONB` (binary) over `JSON` (text) for structured data.

## Indexing
| Type | Use for |
|------|---------|
| B-Tree (default) | Equality, range, sorting |
| GIN | JSONB, fulltext, arrays, containment |
| GiST | Geometry, range types, nearest-neighbor |
| BRIN | Sequential data (timestamps, IDs) on large tables |
| Hash | Equality only (rarely needed) |

- Partial indexes: `CREATE INDEX ... WHERE condition` — index only relevant rows.
- Expression indexes: `CREATE INDEX ... ON t (lower(name))`.
- Covering indexes: `INCLUDE (col1, col2)` for index-only scans.
- `CONCURRENTLY` for creating indexes without blocking writes.

## JSONB
- Store structured, semi-structured, or variable-schema data.
- Index with GIN: `CREATE INDEX ... USING GIN (data jsonb_path_ops)`.
- Query: `data->>'key'` (text), `data->'key'` (jsonb), `data @> '{"key": "val"}'` (containment).
- Generated columns for frequently queried JSONB paths.

## Partitioning
- Declarative partitioning (range, list, hash) for large tables.
- Partition key must be part of every unique/PK constraint.
- `ATTACH PARTITION` / `DETACH PARTITION` for maintenance.
- Partition pruning: queries automatically skip irrelevant partitions.

## Extensions
- `pg_trgm`: trigram similarity for fuzzy search.
- `pgvector`: vector similarity search (AI/embeddings).
- `pg_stat_statements`: query performance analysis.
- `uuid-ossp`: UUID generation.
- `postgis`: geospatial data.

## Connection Management
- Use connection pooling (PgBouncer) — PostgreSQL connections are expensive (~5-10 MB each).
- Pool sizing: start with `2 * CPU cores + 1`.
- Use `prepared_statements` for parameterized queries.
- Set `statement_timeout` to prevent runaway queries.

## Guardrails
- Always use `TIMESTAMPTZ`, not `TIMESTAMP`.
- Prefer `TEXT` over `VARCHAR(N)` unless length limit is meaningful.
- Use `CONCURRENTLY` when creating indexes on production tables.
- Set `statement_timeout` at connection or session level.
- Use PgBouncer for connection pooling in production.

Files in this skill

  • CHANGELOG.md680 B
  • SKILL.md2.6 KB
  • USAGE.md867 B
  • skill.json1.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.