PgCache and PgBouncer
PgBouncer and PgCache both sit between your app and Postgres, but they solve different problems. PgBouncer shares a few database connections among many clients. PgCache serves repeated reads from cache, so Postgres runs fewer queries.
See which of your own queries PgCache would serve: check your workload or open a sample report.
PgBouncer and RDS Proxy facts checked against their docs on .
PgCache
A caching proxy. It serves repeated reads from cache and sends everything else to your database. The cached data lives in a separate, vanilla Postgres instance, kept current through logical replication.
- Takes repeated reads off your database
- Picks what to cache from live traffic
PgBouncer
A lightweight connection pooler for Postgres. It keeps a small pool of database connections and lends them to clients.
What each one does
| Topic | PgCache | PgBouncer |
|---|---|---|
| Solves | Repeated reads | Too many connections |
| What happens to a read | Served from cache when it can be | Runs on Postgres over a pooled connection |
| What it holds | Data for cached queries | Connections |
What they have in common
- Both speak the Postgres protocol, so the app only changes its connection string
How they fit together
- PgCache in front, serving cached reads
- PgBouncer behind it, pooling the connections that reach Postgres
- Amazon RDS Proxy can take PgBouncer’s place on AWS
Common questions
Is PgCache a connection pooler?
No. If you need pooling, run PgCache with PgBouncer, PgDog or RDS Proxy.
Does PgBouncer cache queries?
No. Every query runs on Postgres over a pooled connection.
How do PgCache and PgBouncer run together?
PgCache sits in front and PgBouncer pools the connections behind it. The compatibility docs cover the setup, including RDS Proxy.
Sources
If something here is out of date, please write to [email protected].
See where your own queries land
Step 1
Check your workload
Paste a pg_stat_statements export or a Postgres log. In about a minute you see which of your queries PgCache would serve from cache.
No export handy? See a sample report
Runs in your browser. Nothing is uploaded.
Step 2
Get a free workload review
30 minutes with the founders, by video or email. Bring your Fit report or your Postgres problem.
- What PgCache would serve and save on your workload
- If it fits, a pilot with hands-on help
Prefer email? [email protected]
Already curious? Request a pilot
Free. Pick any open time on our calendar.
Run it yourself: Source on GitHub · Try it in one command
Not ready yet? Get updates by email.