Supabase provides several options for connection to your Postgres database:
- HTTP connections using the API.
- Direct connections using Postgres' standard connection system.
- Connection pooling using PgBouncer.
Supabase provides an auto-updating API. This is the easiest way to get started if you are managing data (fetching, inserting, updating). However you cannot manage the database schema via the API (for security reasons). To do that you can either use the dashboard we provide or connect directly to your database.
A "direct connection" is when a connection is made to the database using Postgres' native connection implementation.
A "connection pool" is a system (external to Postgres) which manage connections, rather than Postgres' native system.
Why would you use a connection pool? Primarily because the way that Postgres handles connections isn't very scalable for a large number of temporary connections. You can use these simple questions to determine which connection method to use:
- Are you connecting to a database and maintaining a connection? If yes, use a direct connection.
- Are you connecting to your database and then disconnecting immediately (e.g. a serverless environment)? If yes, use a connection pool.