diff --git a/.env.production.sample b/.env.production.sample
index d7c04e23548082b7e7778c7459695772a899931e..fbb28470789c7496a7854607f006e5efc70cbaff 100644
--- a/.env.production.sample
+++ b/.env.production.sample
@@ -63,3 +63,7 @@ SMTP_FROM_ADDRESS=notifications@example.com
 
 # Streaming API integration
 # STREAMING_API_BASE_URL=
+
+# Advanced settings
+# If you need to use pgBouncer, you need to disable prepared statements:
+# PREPARED_STATEMENTS=false
diff --git a/config/database.yml b/config/database.yml
index 5ec342f939f8bf31283b5cd7ed8c01f91adf0e8f..810b83278041d3689128aa2b58efddb10c93880e 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -22,3 +22,4 @@ production:
   password: <%= ENV['DB_PASS'] || '' %>
   host: <%= ENV['DB_HOST'] || 'localhost' %>
   port: <%= ENV['DB_PORT'] || 5432 %>
+  prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %>