prisma / docs

📚 Prisma Documentation
https://www.prisma.io/docs
Apache License 2.0
985 stars 778 forks source link

Document url connection parameter `statement_cache_size` #2748

Open Jolg42 opened 2 years ago

Jolg42 commented 2 years ago

Only found in rust source code as of today see: https://sourcegraph.com/search?q=context:global+repo:github.com/prisma/+statement_cache_size&patternType=literal

Example

postgresql:///localhost:5432/foo?statement_cache_size=420

Found from source code

PostgreSQL
//! - `statement_cache_size`, number of prepared statements kept cached.
//!   Defaults to 500. If `pgbouncer` mode is enabled, caching is always off.

MySQL
//! - `statement_cache_size`, number of prepared statements kept cached.
//!   Defaults to 1000. Set to 0 to disable caching.

So it seems it's only for MySQL and PostgreSQL with different defaults and can be disabled by setting it to 0

It should go there I think for a basic documentation https://www.prisma.io/docs/concepts/database-connectors/postgresql https://www.prisma.io/docs/concepts/database-connectors/mysql

@pimeys can you confirm the above? and if possible give more details about why it's important / why would someone want to increase / decrease / disable it?

Jolg42 commented 2 years ago

Context: popped up in an internal Slack discussion where a user was having problems and the Prisma Client error message were

Can’t create more than max_prepared_stmt_count statements (current value: 16382) and Timed out fetching a new connection from the connection pool.

https://prisma-company.slack.com/archives/CEYCG2MCN/p1642671709022300

janpio commented 2 years ago

This is not really a feature we want our users to actually use and play around with, as it concerns an area that our users should optimally never have to worry about. Especially if they start trying this randomly for Timed out fetching a new connection from the connection pool. then this will just lead to more confusion and wasted time.

What we might want to do is to create an issue for the other error message, properly describe when that might occur and how statement_cache_size could help fix that potentially.

tmm1 commented 1 month ago

FYI the docs in the source seem to be wrong as both numbers are defaulted to 100:

https://github.com/search?q=org%3Aprisma%20%22let%20mut%20statement_cache_size%20%3D%20100%3B%22&type=code