Skip to content

Capability to disable prepared statement caching #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
x0a1b opened this issue Jan 6, 2020 · 4 comments
Closed

Capability to disable prepared statement caching #223

x0a1b opened this issue Jan 6, 2020 · 4 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@x0a1b
Copy link

x0a1b commented Jan 6, 2020

So when using Postgres with connection poolers like pgbouncer one might end up in a situation where you have to disable prepared statement caching. This is what Postgres JDBC driver allows if you set prepareThreshold=0 in connection string. As far as I can see from source code that is not possible today. Can we enable similar mechanism with preparedStatementCache=0; alternatively this will allow developers controlling cache size. JDBC has similar option preparedStatementCacheQueries I hope we can do something similar.

@Squiry
Copy link
Collaborator

Squiry commented Jan 8, 2020

One note: pgjdbc handles errors "prepared statement does not exist" and retries the whole process even when caching enabled. I'm not sure that poolers are the reason of this behaviour though.

mp911de added a commit that referenced this issue Jan 20, 2020
Rename LimitedStatementCache to BoundedStatementCache. Synchronize cache access. Update documentation. Extract PgBouncerIntegrationTests into its own top-level class.

[#223][#225]
@mp911de mp911de added this to the 0.9.0.M1 milestone Jan 20, 2020
@steven-sheehy
Copy link
Contributor

Documentation is wrong in README and mentions -1 to disable instead of 0:

Determine the number of queries that are cached in each connection. The default is -1, meaning there's no limit. The value of -1 disables the cache. Any other value specifies the cache size.

Documentation in code looks correct:

Configure the preparedStatementCacheQueries. The default is {@code -1}, meaning there's no limit. The value of {@code 0} disables the cache. Any other value specifies the cache size.

mp911de added a commit that referenced this issue Jan 27, 2020
Update documentation to reflect how to disable the cache.

[#223]
@mp911de
Copy link
Collaborator

mp911de commented Jan 27, 2020

Good catch, that's fixed now.

@davecramer
Copy link
Member

Hmmmm.... prepareThreshold=0 doesn't explicitly disable the cache preparedStatementCacheQueries=0 does that.

mp911de pushed a commit that referenced this issue May 15, 2020
Added preparedStatementCacheQueries parameter, which controls cache behaviour.
When cache limit is reached last used statement is closed before parsing new one.
When cache limit is 0 caching of statement is disabled and unnamed statements are used in extended message flow.
Negative values stand for IndefiniteStatementCache (default one).

[#223][#225][#277]
mp911de pushed a commit that referenced this issue May 15, 2020
mp911de added a commit that referenced this issue May 15, 2020
Rename LimitedStatementCache to BoundedStatementCache. Synchronize cache access. Update documentation. Extract PgBouncerIntegrationTests into its own top-level class.

[#223][#225][closes #277]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants