[GH-ISSUE #148] [FEATURE]: Add Configurable Database Connection Pool Limits #120

Open
opened 2026-02-26 21:34:31 +03:00 by kerem · 1 comment
Owner

Originally created by @minikill on GitHub (Oct 29, 2025).
Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/148

Problem

The application currently hardcodes database connection pool settings (SetMaxOpenConns(10)), which can cause issues in certain environments:

  1. Managed databases with connection limits (e.g., DigitalOcean) may have strict connection quotas
  2. lib/pq driver prepared statement conflicts: With connection pooling, users experience "pq: unnamed prepared statement does not exist" errors, especially on managed PostgreSQL instances (https://github.com/lib/pq/issues/889)
  3. No way to tune performance based on deployment environment

Ideal Solution (Long-term)

Switch to a more modern PostgreSQL driver that properly handles prepared statements with connection pooling, such as:

  • pgx - Actively maintained with better connection pooling support
  • pgxpool - Built specifically for connection pooling scenarios

Proposed Short-term Workaround

Add environment variables to make connection pool settings configurable:

  • PBW_DB_MAX_CONNS (default: 10)
  • PBW_DB_MAX_IDLE_CONNS (default: 5)

This allows users to:

  • Limit connections to match their database plan
  • Set to 1 connection to work around lib/pq prepared statement issues
  • Tune for their specific workload
Originally created by @minikill on GitHub (Oct 29, 2025). Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/148 ## Problem The application currently hardcodes database connection pool settings (`SetMaxOpenConns(10)`), which can cause issues in certain environments: 1. **Managed databases with connection limits** (e.g., DigitalOcean) may have strict connection quotas 2. **`lib/pq` driver prepared statement conflicts**: With connection pooling, users experience `"pq: unnamed prepared statement does not exist"` errors, especially on managed PostgreSQL instances (https://github.com/lib/pq/issues/889) 3. **No way to tune performance** based on deployment environment ## Ideal Solution (Long-term) Switch to a more modern PostgreSQL driver that properly handles prepared statements with connection pooling, such as: - `pgx` - Actively maintained with better connection pooling support - `pgxpool` - Built specifically for connection pooling scenarios ## Proposed Short-term Workaround Add environment variables to make connection pool settings configurable: - `PBW_DB_MAX_CONNS` (default: 10) - `PBW_DB_MAX_IDLE_CONNS` (default: 5) This allows users to: - Limit connections to match their database plan - Set to 1 connection to work around `lib/pq` prepared statement issues - Tune for their specific workload
Author
Owner

@minikill commented on GitHub (Jan 27, 2026):

Hey folks, a quick ping after ~3 months.

Are there plans to make DB pool settings configurable instead of hardcoded?
This MR does that with unchanged defaults.

<!-- gh-comment-id:3805488563 --> @minikill commented on GitHub (Jan 27, 2026): Hey folks, a quick ping after ~3 months. Are there plans to make DB pool settings configurable instead of hardcoded? This MR does that with unchanged defaults.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pgbackweb#120
No description provided.