
{"id":8831,"date":"2025-07-09T09:45:23","date_gmt":"2025-07-09T09:45:23","guid":{"rendered":"https:\/\/test.opensource-db.in\/wp1\/?p=8831"},"modified":"2025-07-09T09:46:53","modified_gmt":"2025-07-09T09:46:53","slug":"how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes","status":"publish","type":"post","link":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/","title":{"rendered":"How We solved prepared statement issues with PgBouncer\u2019s pooling modes"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">When leveraging PostgreSQL for your application, <code>PgBouncer<\/code> is the go-to connection pooler for high concurrent workloads. You might already be aware of the different pooling modes available on PgBouncer and their uses. If you are unfamiliar with PgBouncer, <a href=\"https:\/\/test.opensource-db.in\/wp1\/connection-pooling-with-pgbouncer-a-primer\/\">this post<\/a> would help you get up to speed. In most setups, PgBouncer is used in transaction pooling mode. And if one intends to use prepared statements for better performance with transaction pooling, they would soon realize that PgBouncer isn&#8217;t that great for this use case, and will cause errors\/issues. In this blog, we&#8217;ll look at what challenge we had encountered in such a setup, how we solved it, as well as some of the other potential alternatives that you could consider, and also discuss how to verify effectiveness of the changes that we do.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In our case, we were migrating a few databases from OpenShift Containers to On-Premise. We are leveraging PgBouncer as the connection pooler, and configured <code>pool_mode=transaction<\/code> as it is a banking application. The client was using liquibase to generate prepared statements in one of the databases. After successful migration of that particular database to the new environment and mapping the application to the target database, we have observed a few errors related to a prepared statement as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ERROR:  prepared statement \"test\" already exists<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">How we solved it?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The issue was that <code>pool_mode<\/code> was set to <code>transaction<\/code>, but a prepared statement works at session level. In this case, we either need to disable prepared statement, or set the <code>pool_mode<\/code> to <code>session<\/code> for that particular database. Let us run a simple prepared statement in both of these modes .<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How to set multiple pool_modes in pgbouncer<\/strong>?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can set different <code>pool_mode<\/code> for different database based on the requirement. The following pgbouncer.ini configuration file illustrates the setup:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Go to the PgBouncer configuration file.\nvi \/etc\/pgbouncer\/pgbouncer.ini\n&#91;databases]\n* = host=localhost port=5433 auth_user=postgres\ntest_db = host=localhost port=5433 auth_user=postgres pool_mode=session\n&#91;pgbouncer]\nlisten_addr = *\nlisten_port = 6432\nadmin_users = postgres\nauth_type = scram-sha-256\nauth_file = \/etc\/pgbouncer\/userlist.txt\npool_mode = transaction\nmax_client_conn = 100\ndefault_pool_size = 20<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We can set a different <code>pool_mode<\/code> for different databases as shown above. Here, we have set the default <code>pool_mode<\/code> as <code>transaction<\/code> for all the databases, but for the <code>test_db<\/code> , it was set to <code>session<\/code>. If you have already set <code>pool_mode<\/code> to <code>transaction<\/code> and need to change the <code>pool_mode<\/code> to <code>session<\/code> , add a new row as we did for <code>test_db<\/code> above and reload the pgbouncer. This will not affect the current connections.<br><br>After making the changes, you could verify the <code>pool_mode<\/code> being used as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Here is the output of pools we had\npgbouncer=# show pools;\n-&#91; RECORD 1 ]---------+------------\ndatabase              | pgbouncer\nuser                  | pgbouncer\ncl_active             | 1\ncl_waiting            | 0\ncl_active_cancel_req  | 0\ncl_waiting_cancel_req | 0\nsv_active             | 0\nsv_active_cancel      | 0\nsv_being_canceled     | 0\nsv_idle               | 0\nsv_used               | 0\nsv_tested             | 0\nsv_login              | 0\nmaxwait               | 0\nmaxwait_us            | 0\npool_mode             | statement\nload_balance_hosts    |\n-&#91; RECORD 2 ]---------+------------\ndatabase              | test_db\nuser                  | postgres\ncl_active             | 0\ncl_waiting            | 0\ncl_active_cancel_req  | 0\ncl_waiting_cancel_req | 0\nsv_active             | 0\nsv_active_cancel      | 0\nsv_being_canceled     | 0\nsv_idle               | 0\nsv_used               | 1\nsv_tested             | 0\nsv_login              | 0\nmaxwait               | 0\nmaxwait_us            | 0\npool_mode             | session\nload_balance_hosts    |\n-&#91; RECORD 3 ]---------+------------\ndatabase              | test\nuser                  | postgres\ncl_active             | 0\ncl_waiting            | 0\ncl_active_cancel_req  | 0\ncl_waiting_cancel_req | 0\nsv_active             | 0\nsv_active_cancel      | 0\nsv_being_canceled     | 0\nsv_idle               | 0\nsv_used               | 1\nsv_tested             | 0\nsv_login              | 0\nmaxwait               | 0\nmaxwait_us            | 0\npool_mode             | transaction\nload_balance_hosts    |<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If we observe the output of <code>show pools<\/code> , it says the database <code>test_db<\/code> is having <code>pool_mode<\/code> as <code>session<\/code> and database <code>test<\/code> is having <code>pool_mode<\/code> as <code>transaction<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Running prepared statement in transaction pool_mode<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s run a simple prepared statement in database <code>test<\/code> with <code>pool_mode<\/code> set to <code>transaction<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Running the prepare statement and execute first time \n&#91;postgres@ip-172-31-94-225 ~]$ psql -h localhost -p 6432 -U postgres -d test -c \"PREPARE stmtc AS SELECT 1;EXECUTE stmtc;\"\nPassword for user postgres:\nPREPARE\n ?column?\n----------\n        1\n(1 row)\n#Running the prepare statement and execute second time \n&#91;postgres@ip-172-31-94-225 ~]$ psql -h localhost -p 6432 -U postgres -d test -c \"PREPARE stmtc AS SELECT 1;EXECUTE stmtc;\"\nPassword for user postgres:\nERROR:  prepared statement \"stmtc\" already exists<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, we ran same set of commands two times and see the error message in the second time because when the <code>pool_mode<\/code> is set to <code>transaction<\/code>, PgBouncer ends the backend client connection once the transaction is committed, and would not allow the same&nbsp;prepared statement (which works at session level) to be executed again<code>.<\/code> <br><br>Let&#8217;s now see what happens in the <code>session<\/code> pool_mode.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Running prepared statement in transaction pool_mode<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s run the same simple prepared statement in database <code>test_db<\/code> with <code>pool_mode<\/code> set to <code>session<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Running the prepare statement and execute first time\n&#91;postgres@ip-172-31-94-225 ~]$ psql -h localhost -p 6432 -U postgres -d test_db -c \"PREPARE stmtc AS SELECT 1;EXECUTE stmtc;\"\nPassword for user postgres:\nPREPARE\n ?column?\n----------\n        1\n(1 row)\n#Running the prepare statement and execute second time\n&#91;postgres@ip-172-31-94-225 ~]$ psql -h localhost -p 6432 -U postgres -d test_db -c \"PREPARE stmtc AS SELECT 1;EXECUTE stmtc;\"\nPassword for user postgres:\nPREPARE\n ?column?\n----------\n        1\n(1 row)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, we see the same set of commands executed without errors both times because <code>pool_mode<\/code> is set to <code>session<\/code>. This setting goes well with prepared statements since they also work at the session level. <br><br>It is my recommendation, therefore, that if you&#8217;re using PgBouncer, it is better to use <code>session<\/code> pool_mode only for those databases where prepared statements are used. <br><br>But what if you can&#8217;t change the pool_mode to <code>session<\/code>?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this case, you would either need to consider switching your prepared statements to normal queries and continue using <code>pool_mode<\/code>=<code>transaction<\/code>, or try disabling the caching of the client-side prepared statements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disable client-side prepared statement<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you must use&nbsp;<code>transaction<\/code> pooling mode&nbsp;to maximize connection reuse and minimize backend connections, the application needs to send normal queries instead of preparing them. You could also consider&nbsp;disabling the client-side prepared statements (which again depends on the driver that you use).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set\u00a0<code>max_prepared_statements=0<\/code>\u00a0in your\u00a0<code>pgbouncer.ini<\/code>.<\/li>\n\n\n\n<li>If JDBC , we can use prepareThreshold=0&amp;preparedStatementCacheQueries=0 in your connection string.<\/li>\n\n\n\n<li>If psycopg, set the&nbsp;<code>prepare_threshold<\/code>&nbsp;to&nbsp;<code>None<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Post tracking<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It is important to monitor and track these kind of changes, and also test your failover process in a staging environment to ensure prepared statements and pooling modes behave as expected.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Configure both PgBouncer and PostgreSQL logs to capture these errors.<\/li>\n\n\n\n<li>Monitor the logs actively and identify the frequency of the errors.<\/li>\n\n\n\n<li>Leverage PgBouncer admin database for stats to analyze the traffic better.<\/li>\n\n\n\n<li>Also test a failover scenario and simulate production-like poolers in staging to catch these issues early.\n<ul class=\"wp-block-list\">\n<li>Mirror the whole production setup including identical PgBouncer pooling modes and configurations. This helps catch issues with prepared statements, connection recycling, and pool state transitions before they impact users.<\/li>\n\n\n\n<li>Use PgBouncer admin commands like <code>pause<\/code>,<code>resume<\/code> , <code>reconnect<\/code> and <code>kill<\/code> to manage and observe the connection pool behavior during failover.<\/li>\n\n\n\n<li>Automate failover drills&nbsp;and include monitoring and validation as part of your test plan.<\/li>\n\n\n\n<li>Integrate alerts or trigger based notifications for these errors for quick identification and resolution.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this blog, we discussed how to resolve the issues caused by using prepared statements with PgBouncer configured in <code>transaction<\/code> pooling mode. Since prepared statements are session-bound but <code>transaction<\/code> mode reuses connections per transaction, statements may fail with errors like \u201cprepared statement already exists.\u201d The solution involves setting <code>pool_mode = session<\/code> specifically for affected databases while keeping the default as <code>transaction<\/code>, enabling session persistence only where needed. As an alternative, disabling client-side prepared statements in the application driver (e.g., JDBC or psycopg) was suggested when changing pool mode wasn\u2019t possible. When making changes to the PgBouncer settings, it is very important to monitor logs, simulate production-like setups in staging, and test failovers thoroughly to catch issues early, ultimately ensuring reliability and performance in PostgreSQL environments using PgBouncer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some of our blogs on PgBouncer<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/test.opensource-db.in\/wp1\/connection-pooling-with-pgbouncer-a-primer\/\">Connection Pooling with pgBouncer: A Primer<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/test.opensource-db.in\/wp1\/step-by-step-guide-to-postgresql-ha-with-patroni-part-3\/\">Step-by-Step Guide to PostgreSQL HA with Patroni: Part 3<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Being a PostgreSQL expert specializing in designing scalable and efficient systems focuses on delivering robust technical solutions aligned with business goals. Feel free to reach us for any query.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When leveraging PostgreSQL for your application, PgBouncer is the go-to connection pooler for high concurrent workloads. You might already be [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":8848,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1,65,23,42,89,167],"tags":[],"class_list":["post-8831","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-others","category-pgbouncer","category-postgresql-14","category-postgresql-15","category-postgresql-16","category-postgresql-17"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How We solved prepared statement issues with PgBouncer\u2019s pooling modes - OpenSource DB<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How We solved prepared statement issues with PgBouncer\u2019s pooling modes - OpenSource DB\" \/>\n<meta property=\"og:description\" content=\"When leveraging PostgreSQL for your application, PgBouncer is the go-to connection pooler for high concurrent workloads. You might already be [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/\" \/>\n<meta property=\"og:site_name\" content=\"OpenSource DB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-09T09:45:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-09T09:46:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"945\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Venkat Akhil\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@opensource_db\" \/>\n<meta name=\"twitter:site\" content=\"@opensource_db\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Venkat Akhil\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/\"},\"author\":{\"name\":\"Venkat Akhil\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/a37b142ecbf953189a4f9209b0b8d328\"},\"headline\":\"How We solved prepared statement issues with PgBouncer\u2019s pooling modes\",\"datePublished\":\"2025-07-09T09:45:23+00:00\",\"dateModified\":\"2025-07-09T09:46:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/\"},\"wordCount\":997,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#organization\"},\"image\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png\",\"articleSection\":[\"Others\",\"PgBouncer\",\"PostgreSQL 14\",\"PostgreSQL 15\",\"PostgreSQL 16\",\"PostgreSQL 17\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/\",\"name\":\"How We solved prepared statement issues with PgBouncer\u2019s pooling modes - OpenSource DB\",\"isPartOf\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png\",\"datePublished\":\"2025-07-09T09:45:23+00:00\",\"dateModified\":\"2025-07-09T09:46:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png\",\"contentUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png\",\"width\":1800,\"height\":945},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/test.opensource-db.in\/wp1\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How We solved prepared statement issues with PgBouncer\u2019s pooling modes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#website\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/\",\"name\":\"OpenSource DB\",\"description\":\"Your Trusted OpenSource Databases partner\",\"publisher\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/test.opensource-db.in\/wp1\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#organization\",\"name\":\"OPENSOURCE DB PRIVATE LIMITED\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png\",\"contentUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png\",\"width\":368,\"height\":120,\"caption\":\"OPENSOURCE DB PRIVATE LIMITED\"},\"image\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/\",\"https:\/\/x.com\/opensource_db\",\"https:\/\/www.youtube.com\/channel\/UCmTI5h\",\"https:\/\/www.linkedin.com\/company\/opensource-db\",\"https:\/\/www.instagram.com\/opensource_db\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/a37b142ecbf953189a4f9209b0b8d328\",\"name\":\"Venkat Akhil\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/522c0947d21b2c2c89f10698fd9131f9db4110f65c8d02b53d9b4559c7650865?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/522c0947d21b2c2c89f10698fd9131f9db4110f65c8d02b53d9b4559c7650865?s=96&d=mm&r=g\",\"caption\":\"Venkat Akhil\"},\"url\":\"https:\/\/test.opensource-db.in\/wp1\/author\/sudheer-sopensource-db-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How We solved prepared statement issues with PgBouncer\u2019s pooling modes - OpenSource DB","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"How We solved prepared statement issues with PgBouncer\u2019s pooling modes - OpenSource DB","og_description":"When leveraging PostgreSQL for your application, PgBouncer is the go-to connection pooler for high concurrent workloads. You might already be [&hellip;]","og_url":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/","og_site_name":"OpenSource DB","article_publisher":"https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/","article_published_time":"2025-07-09T09:45:23+00:00","article_modified_time":"2025-07-09T09:46:53+00:00","og_image":[{"width":1800,"height":945,"url":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png","type":"image\/png"}],"author":"Venkat Akhil","twitter_card":"summary_large_image","twitter_creator":"@opensource_db","twitter_site":"@opensource_db","twitter_misc":{"Written by":"Venkat Akhil","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#article","isPartOf":{"@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/"},"author":{"name":"Venkat Akhil","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/a37b142ecbf953189a4f9209b0b8d328"},"headline":"How We solved prepared statement issues with PgBouncer\u2019s pooling modes","datePublished":"2025-07-09T09:45:23+00:00","dateModified":"2025-07-09T09:46:53+00:00","mainEntityOfPage":{"@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/"},"wordCount":997,"commentCount":0,"publisher":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#organization"},"image":{"@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage"},"thumbnailUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png","articleSection":["Others","PgBouncer","PostgreSQL 14","PostgreSQL 15","PostgreSQL 16","PostgreSQL 17"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/","url":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/","name":"How We solved prepared statement issues with PgBouncer\u2019s pooling modes - OpenSource DB","isPartOf":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#website"},"primaryImageOfPage":{"@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage"},"image":{"@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage"},"thumbnailUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png","datePublished":"2025-07-09T09:45:23+00:00","dateModified":"2025-07-09T09:46:53+00:00","breadcrumb":{"@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#primaryimage","url":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png","contentUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png","width":1800,"height":945},{"@type":"BreadcrumbList","@id":"https:\/\/test.opensource-db.in\/wp1\/how-we-solved-prepared-statement-issues-with-pgbouncers-pooling-modes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/test.opensource-db.in\/wp1\/"},{"@type":"ListItem","position":2,"name":"How We solved prepared statement issues with PgBouncer\u2019s pooling modes"}]},{"@type":"WebSite","@id":"https:\/\/test.opensource-db.in\/wp1\/#website","url":"https:\/\/test.opensource-db.in\/wp1\/","name":"OpenSource DB","description":"Your Trusted OpenSource Databases partner","publisher":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/test.opensource-db.in\/wp1\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/test.opensource-db.in\/wp1\/#organization","name":"OPENSOURCE DB PRIVATE LIMITED","url":"https:\/\/test.opensource-db.in\/wp1\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/","url":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png","contentUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png","width":368,"height":120,"caption":"OPENSOURCE DB PRIVATE LIMITED"},"image":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/","https:\/\/x.com\/opensource_db","https:\/\/www.youtube.com\/channel\/UCmTI5h","https:\/\/www.linkedin.com\/company\/opensource-db","https:\/\/www.instagram.com\/opensource_db\/"]},{"@type":"Person","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/a37b142ecbf953189a4f9209b0b8d328","name":"Venkat Akhil","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/522c0947d21b2c2c89f10698fd9131f9db4110f65c8d02b53d9b4559c7650865?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/522c0947d21b2c2c89f10698fd9131f9db4110f65c8d02b53d9b4559c7650865?s=96&d=mm&r=g","caption":"Venkat Akhil"},"url":"https:\/\/test.opensource-db.in\/wp1\/author\/sudheer-sopensource-db-com\/"}]}},"rttpg_featured_image_url":{"full":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",1800,945,false],"landscape":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",1800,945,false],"portraits":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",1800,945,false],"thumbnail":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image-150x150.png",150,150,true],"medium":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image-300x158.png",300,158,true],"large":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image-1024x538.png",1024,538,true],"1536x1536":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image-1536x806.png",1536,806,true],"2048x2048":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",1800,945,false],"ultp_layout_landscape_large":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",1200,630,false],"ultp_layout_landscape":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",870,457,false],"ultp_layout_portrait":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",600,315,false],"ultp_layout_square":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2025\/07\/image.png",600,315,false]},"rttpg_author":{"display_name":"Venkat Akhil","author_link":"https:\/\/test.opensource-db.in\/wp1\/author\/sudheer-sopensource-db-com\/"},"rttpg_comment":0,"rttpg_category":"<a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/business\/others\/\" rel=\"category tag\">Others<\/a> <a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/extensions\/pgbouncer\/\" rel=\"category tag\">PgBouncer<\/a> <a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/postgresql-14\/\" rel=\"category tag\">PostgreSQL 14<\/a> <a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/postgresql-15\/\" rel=\"category tag\">PostgreSQL 15<\/a> <a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/postgresql-16\/\" rel=\"category tag\">PostgreSQL 16<\/a> <a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/postgresql-17\/\" rel=\"category tag\">PostgreSQL 17<\/a>","rttpg_excerpt":"When leveraging PostgreSQL for your application, PgBouncer is the go-to connection pooler for high concurrent workloads. You might already be [&hellip;]","_links":{"self":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts\/8831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/comments?post=8831"}],"version-history":[{"count":11,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts\/8831\/revisions"}],"predecessor-version":[{"id":8849,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts\/8831\/revisions\/8849"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/media\/8848"}],"wp:attachment":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/media?parent=8831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/categories?post=8831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/tags?post=8831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}