graphile / graphile.github.io

PostGraphile (PostGraphQL) and Graphile-Build website - contributions very welcome!
https://www.graphile.org/
25 stars 128 forks source link

[Solved] Error: "Prepared statement ... already exists" when repeating query #280

Open saintsal opened 3 years ago

saintsal commented 3 years ago

I just tried the default docker image with Digital Ocean's hosted Postgres (which recommends using connection pools), and ran into the error "Prepared statement ... already exists" when repeating the same query.

@benjie quickly pointed out the following on Discord:

PostGraphile uses prepared statements as a minor performance optimisation, but this causes issues if you’re running external connection pools in addition to PostGraphile’s native connection pooling. You can disable prepared statements by setting the environment variable POSTGRAPHILE_PREPARED_STATEMENT_CACHE_SIZE=0

In my case, since PostGraphile already has connection pools built-in, I just connected directly to the database rather than the Postgres connection pool, and everything works fine.

I wasn't sure where this might go in the documentation, so just quickly posting this as an issue in case it helps anyone.

IMalaniak commented 2 years ago

@saintsal is that is the same as setting queryCacheMaxSize in the PostGraphileOptions?

benjie commented 2 years ago

I don’t think so