Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

VanDyckBrown's avatar

Postgres connection pooling & authentication

Hi,

I recently migrated from mysql to a managed Postgresql database. Lots of bug fixing later i was finally ready to role the change out to production.

While rolling out to production i ran in to a max connection error so i decided to use connection pools in digital ocean which is using pgbouncer.

After turning on connection pooling i started running in to errors having to do with prepared statements

message": "SQLSTATE[26000]: Invalid sql statement name: 7 ERROR: prepared statement "pdo_stmt_00000004" does not exist (SQL: select * from "users" where "id" = 2 limit 1)"

message": "SQLSTATE[26000]: Invalid sql statement name: 7 ERROR: prepared statement "pdo_stmt_00000005" does not exist (SQL: select "roles".*, "model_has_roles"."model_id" as "pivot_model_id", "model_has_roles"."role_id" as "pivot_role_id", "model_has_roles"."model_type" as "pivot_model_type" from "roles" inner join "model_has_roles" on "roles"."id" = "model_has_roles"."role_id" where "model_has_roles"."model_id" = 2 and "model_has_roles"."model_type" = App\Models\User)",

message": "SQLSTATE[08P01]: <>: 7 ERROR: bind message supplies 2 parameters, but prepared statement "pdo_stmt_00000005" requires 1 (SQL: select "roles".*, "model_has_roles"."model_id" as "pivot_model_id", "model_has_roles"."role_id" as "pivot_role_id", "model_has_roles"."model_type" as "pivot_model_type" from "roles" inner join "model_has_roles" on "roles"."id" = "model_has_roles"."role_id" where "model_has_roles"."model_id" = 2 and "model_has_roles"."model_type" = App\Models\User)"

Do i have to tell laravel i am using a connection pool? If so where do i do this?

0 likes
1 reply

Please or to participate in this conversation.