Skip to content

henriqueatila/golang-gin-best-practices / skills/golang-gin-psql-dba

golang-gin-psql-dba

Flagged

PostgreSQL DBA for Go Gin APIs. Use when designing schemas, analyzing migrations, choosing indexes, optimizing queries, or selecting extensions (pgvector, PostGIS, TimescaleDB).

FileKindSize
SKILL.mdskill md9.9 KB
metadata.jsonconfig668 B
references/backup-and-recovery-managed-and-schedules.mdmarkdown4.3 KB
references/backup-and-recovery-strategies.mdmarkdown4.8 KB
references/backup-and-recovery-wal-and-validation.mdmarkdown2.7 KB
references/extensions-toolkit-crypto-and-uuid.mdmarkdown4.1 KB
references/extensions-toolkit-partman-and-trgm.mdmarkdown4.5 KB
references/extensions-toolkit-pgaudit-and-stats.mdmarkdown4.3 KB
references/extensions-toolkit-setup-and-cron.mdmarkdown3.8 KB
references/index-strategy-maintenance-and-explain.mdmarkdown4.4 KB
references/index-strategy-types-and-variants.mdmarkdown3.8 KB
references/migration-impact-backfill-and-lock-timeout.mdmarkdown3.5 KB
references/migration-impact-lock-timeout.mdmarkdown4.6 KB
references/migration-impact-locks-and-operations.mdmarkdown6.4 KB
references/paradedb-advanced-search-and-hybrid.mdmarkdown4.7 KB
references/paradedb-go-integration-and-tips.mdmarkdown4.9 KB
references/paradedb-setup-and-basic-search.mdmarkdown4.5 KB
references/pgvector-capacity-and-performance.mdmarkdown4.3 KB
references/pgvector-queries-and-go-integration.mdmarkdown4.4 KB
references/pgvector-setup-and-schema.mdmarkdown4.9 KB
references/postgis-go-integration-and-performance.mdmarkdown3.8 KB
references/postgis-setup-types-and-indexes.mdmarkdown4.3 KB
references/query-performance-pool-and-replicas.mdmarkdown4.6 KB
references/query-performance-stats-and-vacuum.mdmarkdown4.2 KB
references/replication-and-ha-clusters.mdmarkdown3.4 KB
references/replication-and-ha-go-readwrite.mdmarkdown4.0 KB
references/replication-and-ha-go-resilience.mdmarkdown4.8 KB
references/replication-and-ha-lag-monitoring.mdmarkdown3.3 KB
references/replication-and-ha-logical.mdmarkdown2.2 KB
references/replication-and-ha-managed-services.mdmarkdown2.0 KB
references/replication-and-ha-overview.mdmarkdown3.1 KB
references/replication-and-ha-streaming-setup.mdmarkdown3.6 KB
references/row-level-security-go-integration-and-pitfalls.mdmarkdown5.5 KB
references/row-level-security-setup-and-policies.mdmarkdown5.8 KB
references/schema-design-complete-example.mdmarkdown6.9 KB
references/schema-design-constraints-and-normalization.mdmarkdown4.2 KB
references/schema-design-naming-and-types.mdmarkdown3.9 KB
references/schema-design-soft-delete-and-tenancy.mdmarkdown5.1 KB
references/timescaledb-aggregates-compression-retention.mdmarkdown5.7 KB
references/timescaledb-go-integration.mdmarkdown3.5 KB
references/timescaledb-setup-and-hypertables.mdmarkdown4.8 KB

references/replication-and-ha-overview.md

View on GitHub
# Replication and HA — Overview

PostgreSQL replication and high availability strategies for Go/Gin APIs.

## Physical vs Logical Replication

| Feature | Physical (Streaming) | Logical |
|---|---|---|
| Granularity | Entire cluster (all databases) | Per-table, per-publication |
| Cross-version replication | No — identical major version required | Yes — PG 10 to PG 16 supported |
| Standby is read-only | Yes (hot standby) | No — subscriber is writable |
| DDL replication | Yes — everything replicated | No — DDL must be applied manually |
| Sequence replication | Yes | No |
| Overhead | Low — WAL already generated | Moderate — logical decoding CPU |
| Primary use case | HA failover, read scaling | Selective sync, migrations, ETL |

## Streaming Replication (WAL Shipping)

The primary continuously streams Write-Ahead Log (WAL) segments to one or more standbys over a replication connection. Each standby replays WAL records to stay in sync. The standby can serve read-only queries in **hot standby** mode while replay is ongoing.

WAL travels as a stream of binary change records — not SQL. Standbys are byte-for-byte identical to the primary at the replayed LSN (Log Sequence Number).

## Synchronous vs Asynchronous Trade-offs

| Mode | Latency Impact | Data Safety | Use When |
|---|---|---|---|
| **Asynchronous** (default) | None — primary does not wait | Small window of data loss on crash | Read scaling, analytics replicas |
| **Synchronous** (`synchronous_commit = on`) | +1 network RTT per write | Zero data loss — standby confirms before commit | Financial, audit, compliance systems |
| **Remote write** (`synchronous_commit = remote_write`) | +1 RTT, lower than full sync | Standby received WAL but may not have replayed | Balance: near-zero loss, lower latency than full sync |

Set synchronous mode per transaction when needed: `SET LOCAL synchronous_commit = on`. Avoid forcing it globally unless all writes require it.

## Use Cases

- **Read scaling** — route SELECT queries to one or more hot standbys; primary handles writes only.
- **HA failover** — promote a standby if the primary fails; Patroni automates this.
- **Data distribution** — logical replication pushes specific tables to reporting databases, data warehouses, or microservices.
- **Zero-downtime major upgrades** — logical replication from old to new version; switch application endpoint when caught up.

**Related files:**
- Setup details: [replication-and-ha-streaming-setup.md](replication-and-ha-streaming-setup.md)
- Logical replication: [replication-and-ha-logical.md](replication-and-ha-logical.md)
- Read/write splitting in Go: [replication-and-ha-go-readwrite.md](replication-and-ha-go-readwrite.md)
- Lag monitoring: [replication-and-ha-lag-monitoring.md](replication-and-ha-lag-monitoring.md)
- HA clusters (Patroni, pg_auto_failover): [replication-and-ha-clusters.md](replication-and-ha-clusters.md)
- Managed services: [replication-and-ha-managed-services.md](replication-and-ha-managed-services.md)
- Go resilience patterns: [replication-and-ha-go-resilience.md](replication-and-ha-go-resilience.md)
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall