-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(database): add pgbouncer support and optimize postgres config #1700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(database): add pgbouncer support and optimize postgres config #1700
Conversation
- Add pgbouncer service to handle connection pooling - Update database connection URIs to support direct and pooled connections - Optimize postgres configuration with better memory settings - Update prisma schema to support directUrl connection
Reviewer's GuideThis PR integrates PgBouncer into the Docker setup for transparent connection pooling, tunes Postgres memory and connection settings for better performance, and updates both environment examples and the Prisma schema to support separate direct and pooled connection URLs. Class diagram for updated Prisma database connection configurationclassDiagram
class PrismaClient {
+String url
+String directUrl
+connect()
+disconnect()
}
PrismaClient : url = pooled connection (via PgBouncer)
PrismaClient : directUrl = direct Postgres connection
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @guilherme-aguilar - I've reviewed your changes - here's some feedback:
- Extract database credentials (user, password, and database name) into environment variables or a .env file instead of hard-coding them in docker-compose for better flexibility and security.
- Add healthcheck definitions for both the postgres and pgbouncer services to ensure dependent services wait for the database to be fully ready before starting.
- After updating the Prisma schema with the new directUrl, remember to regenerate the Prisma client and verify any related migrations are applied.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract database credentials (user, password, and database name) into environment variables or a .env file instead of hard-coding them in docker-compose for better flexibility and security.
- Add healthcheck definitions for both the postgres and pgbouncer services to ensure dependent services wait for the database to be fully ready before starting.
- After updating the Prisma schema with the new directUrl, remember to regenerate the Prisma client and verify any related migrations are applied.
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- Add new psql_bouncer database provider option - Update database scripts to handle psql_bouncer provider - Comment out pgbouncer service in docker-compose - Simplify postgresql schema by removing directUrl - Add new psql_bouncer-schema.prisma file - Update .env.example with psql_bouncer configuration - Modify runWithProvider.js to handle psql_bouncer migrations
Summary by Sourcery
Add PgBouncer for connection pooling, support both pooled and direct PostgreSQL connections in Prisma, and optimize PostgreSQL memory settings
New Features:
Enhancements: