Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计异常

postgres-opsPostgres OPS 搜索

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

245

周安装

10

GitHub Stars

17

下载量

79
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:postgres-ops(Postgres OPS 搜索)
来源仓库:https://github.com/0xdarkmatter/claude-mods
仓库路径:skills/postgres-ops
安装命令:
npx skills add https://github.com/0xdarkmatter/claude-mods --skill postgres-ops
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/0xdarkmatter/claude-mods --skill postgres-ops

简介

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。

  • 适合分析 schema、编写 SQL、排查查询问题或生成索引优化建议。
  • 使用时需明确数据库类型和连接环境,区分只读分析与写入操作。
  • 涉及删除、更新、迁移或批量导入时,应优先 dry-run、备份或使用事务保护。
  • 建议在安装前确认数据库版本和运维环境兼容性,避免因配置差异导致执行失败。

SKILL.md

PostgreSQL Operations

Comprehensive PostgreSQL skill covering schema design through production operations.

Quick Connection

# Standard connection
psql "postgresql://user:pass@localhost:5432/dbname"

# With SSL
psql "postgresql://user:pass@host:5432/dbname?sslmode=require"

# Environment variables (libpq)
export PGHOST=localhost PGPORT=5432 PGDATABASE=mydb PGUSER=myuser PGPASSWORD=secret
psql

# Connection pooling (pgBouncer default)
psql "postgresql://user:pass@localhost:6432/dbname"
-- Check current connection
SELECT current_database(), current_user, inet_server_addr(), inet_server_port();

-- Active connections
SELECT count(*) FROM pg_stat_activity WHERE state = 'active';

Index Type Selection

What query pattern are you optimizing?
│
├─ Equality (WHERE col = val)
│  └─ B-tree (default, almost always right)
│
├─ Range (WHERE col > val, ORDER BY, BETWEEN)
│  └─ B-tree
│
├─ Array/JSONB containment (@>, ?, ?|, ?&)
│  └─ GIN
│
├─ Full-text search (@@)
│  └─ GIN with tsvector
│
├─ Geometric/range overlap (&&, <->)
│  └─ GiST
│
├─ Pattern matching (LIKE '%text%', similarity)
│  └─ GIN with pg_trgm (gin_trgm_ops)
│
├─ Large table, few distinct values, append-only
│  └─ BRIN (tiny index, good for timestamps)
│
└─ Exact equality only, no range/sort needed
   └─ Hash (rare - B-tree usually better)

Quick Index Reference

IndexBest ForSizeWrite Cost
B-treeEquality, range, sortMediumLow
GINArrays, JSONB, FTS, trigramsLargeHigh
GiSTGeometry, ranges, FTSMediumMedium
BRINCorrelated data (timestamps)TinyVery low
HashExact equality onlyMediumLow

Deep dive: Load ./references/indexing.md for composite, partial, expression, and covering index strategies.

EXPLAIN ANALYZE Workflow

-- Step 1: Run with ANALYZE and BUFFERS
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT ...;

-- Step 2: Read bottom-up. Find the slowest node.
-- Step 3: Check estimates vs actuals
--   actual rows=10000, rows=100  -> bad estimate, run ANALYZE
-- Step 4: Look for these red flags:
Red FlagMeaningFix
Seq Scan on large tableNo usable indexAdd index matching WHERE/JOIN
actual rows >> estimated rowsStale statisticsANALYZE tablename
Nested Loop with high rowsO(n*m) joinCheck join conditions, add index
Sort with external mergework_mem too smallIncrease work_mem for session
Buffers: shared read >> hitCold cache or table too largeCheck shared_buffers, add covering index
Hash Batch > 1Hash join spilling to diskIncrease work_mem

Deep dive: Load ./references/query-tuning.md for plan node reference and optimization patterns.

Workload Profiles

SettingOLTPOLAPNotes
shared_buffers25% RAM25% RAMSame baseline
work_mem4-16 MB256 MB-1 GBOLAP needs big sorts
effective_cache_size75% RAM75% RAMPlanner hint
random_page_cost1.1 (SSD)1.1 (SSD)Lower for SSD
max_parallel_workers_per_gather24-8OLAP benefits more
checkpoint_completion_target0.90.9Spread checkpoint I/O
wal_buffers64 MB64 MB-1 for auto
maintenance_work_mem512 MB1-2 GBFor VACUUM, CREATE INDEX

Deep dive: Load ./references/config-tuning.md for full postgresql.conf walkthrough and extension setup.

Common Operations

Backup & Restore

# Logical backup (single database)
pg_dump -Fc dbname > backup.dump

# Restore
pg_restore -d dbname backup.dump

# Parallel backup (faster for large DBs)
pg_dump -Fc -j4 dbname > backup.dump

# Base backup for PITR
pg_basebackup -D /backup/base -Ft -Xs -P

Vacuum & Maintenance

-- Manual vacuum (reclaim space, update stats)
VACUUM (VERBOSE, ANALYZE) tablename;

-- Full vacuum (rewrites table, exclusive lock)
VACUUM FULL tablename;  -- CAUTION: locks table

-- Reindex without downtime
REINDEX INDEX CONCURRENTLY idx_name;

-- Update statistics only
ANALYZE tablename;

Monitor Key Metrics

-- Slow queries (requires pg_stat_statements)
SELECT query, calls, mean_exec_time, total_exec_time
FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10;

-- Table bloat indicator
SELECT schemaname, relname, n_dead_tup, n_live_tup,
       round(n_dead_tup::numeric / NULLIF(n_live_tup, 0) * 100, 1) AS dead_pct
FROM pg_stat_user_tables WHERE n_dead_tup > 1000
ORDER BY n_dead_tup DESC;

-- Lock contention
SELECT pid, relation::regclass, mode, granted, query
FROM pg_locks JOIN pg_stat_activity USING (pid)
WHERE NOT granted;

-- Cache hit ratio (should be > 99%)
SELECT sum(heap_blks_hit) / NULLIF(sum(heap_blks_hit) + sum(heap_blks_read), 0) AS ratio
FROM pg_statio_user_tables;

Deep dive: Load ./references/operations.md for WAL archiving, PITR, autovacuum tuning, connection pooling.

Data Types Quick Reference

TypeUse WhenExample
JSONBSemi-structured data, flexible schema'{"tags": ["a","b"]}'::jsonb
ARRAYFixed-type listsARRAY['a','b','c']
tsrangeTime periods, scheduling'[2024-01-01, 2024-12-31)'::tsrange
tsvectorFull-text searchto_tsvector('english', body)
uuidDistributed IDsgen_random_uuid()
inet/cidrIP addresses, networks'192.168.1.0/24'::cidr

Deep dive: Load ./references/schema-design.md for normalization, constraints, RLS, generated columns, table inheritance.

Gotchas & Anti-Patterns

MistakeWhy It's BadFix
SELECT * in productionWastes bandwidth, blocks covering index scansList columns explicitly
Function on indexed column (WHERE UPPER(email) =...)Prevents index useExpression index: CREATE INDEX... ON (UPPER(email))
NOT IN (subquery) with NULLsReturns no rows if subquery has NULLUse NOT EXISTS
Missing ANALYZE after bulk loadPlanner uses stale row estimatesRun ANALYZE tablename
VACUUM FULL in productionExclusive lock on entire tableRegular VACUUM + pg_repack
LIMIT without ORDER BYNon-deterministic resultsAlways pair with ORDER BY
Offset pagination on large tablesScans and discards rowsKeyset pagination: WHERE id > last_id
Too many indexesSlows writes, wastes spaceAudit with pg_stat_user_indexes
Single shared connection poolContention across servicesPer-service pools via pgBouncer
default_transaction_isolation = serializableExcessive serialization failuresKeep read committed, use explicit SERIALIZABLE where needed

Row-Level Security (RLS) Quick Start

-- Enable RLS on table
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;

-- Policy: users see only their own rows
CREATE POLICY user_isolation ON documents
    USING (owner_id = current_setting('app.current_user_id')::int);

-- Policy: admins see everything
CREATE POLICY admin_access ON documents
    USING (current_setting('app.role') = 'admin');

-- Set context per request (from app layer)
SET app.current_user_id = '42';
SET app.role = 'user';

Full-Text Search Quick Start

-- Add search column
ALTER TABLE articles ADD COLUMN search_vector tsvector
    GENERATED ALWAYS AS (to_tsvector('english', title || ' ' || body)) STORED;

-- Index it
CREATE INDEX idx_articles_fts ON articles USING gin(search_vector);

-- Search with ranking
SELECT title, ts_rank(search_vector, query) AS rank
FROM articles, to_tsquery('english', 'database & optimization') AS query
WHERE search_vector @@ query
ORDER BY rank DESC;

LISTEN/NOTIFY

-- Publisher
NOTIFY order_events, '{"order_id": 123, "status": "shipped"}';

-- Subscriber (in psql or app)
LISTEN order_events;

-- Check for notifications (app code)
-- Python: conn.poll(); conn.notifies
-- Node: client.on('notification', callback)

Reference Files

Load these for deep-dive topics. Each is self-contained.

ReferenceWhen to Load
./references/schema-design.mdDesigning tables, choosing types, constraints, RLS policies, JSONB modeling
./references/indexing.mdChoosing index types, composite/partial/expression indexes, index maintenance
./references/query-tuning.mdReading EXPLAIN plans, pg_stat_statements, optimizing specific query patterns
./references/operations.mdBackup/restore, WAL/PITR, vacuum tuning, monitoring, connection pooling
./references/replication.mdStreaming/logical replication, failover, partitioning, FDW
./references/config-tuning.mdpostgresql.conf settings, OLTP/OLAP profiles, extension setup

See Also

  • sql-ops - Vendor-neutral SQL patterns (CTEs, window functions, JOINs)
  • sqlite-ops - SQLite-specific patterns and operations
  • python-database-ops - SQLAlchemy ORM and async database patterns

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.86%
按下载量换算30

Claude

31.49%
按下载量换算25

Cursor

17.13%
按下载量换算14

Gemini CLI

9.9%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills