Skip to main content

postgresql-operations

Manage PostgreSQL: schema migrations, performance tuning, backups, monitoring per README-SCHEMA-MAINTENANCE.md

来源信息

仓库
Hack23/cia
最近来源活动
2026年2月1日 00:05
检测到的 SKILL.md 语言
英语
星标
239
分支
57

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
postgresql-operations
description
Manage PostgreSQL: schema migrations, performance tuning, backups, monitoring per README-SCHEMA-MAINTENANCE.md
# PostgreSQL Operations Skill ## Purpose Manage PostgreSQL database operations including migrations, performance tuning, and backups. ## When to Use - ✅ Schema migrations with Liquibase - ✅ Performance optimization - ✅ Backup and recovery - ✅ Monitoring and alerting ## Liquibase Migrations ```xml <changeSet id="1" author="developer"> <createTable tableName="politician"> <column name="id" type="VARCHAR(12)"> <constraints primaryKey="true"/> </column> <column name="first_name" type="VARCHAR(50)"> <constraints nullable="false"/> </column> <column name="last_name" type="VARCHAR(50)"> <constraints nullable="false"/> </column> </createTable> </changeSet> ``` ## Performance Tuning ```sql -- Add indexes for frequently queried columns CREATE INDEX idx_politician_party ON politician(party); CREATE INDEX idx_voting_record_date ON voting_record(vote_date); -- Analyze query performance EXPLAIN ANALYZE SELECT * FROM politician WHERE party = 'S' AND district = 'Stockholm'; -- Update statistics ANALYZE politician; ``` ## Backup Strategy ```bash # Daily backups pg_dump -h localhost -U cia_user -d cia_production > backup_$(date +%Y%m%d).sql # Point-in-time recovery setup wal_level = replica archive_mode = on archive_command = 'cp %p /backup/archive/%f' ``` ## Monitoring ```sql -- Check connection count SELECT count(*) FROM pg_stat_activity; -- Check slow queries SELECT query, calls, total_time, mean_time FROM pg_stat_statements ORDER BY mean_time DESC LIMIT 10; ``` ## References - PostgreSQL: https://www.postgresql.org/docs/ - service.data.impl/README-SCHEMA-MAINTENANCE.md
在 GitHub 查看