-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add caution about using explicit PREPARE/EXECUTE call #25532
base: master
Are you sure you want to change the base?
Add caution about using explicit PREPARE/EXECUTE call #25532
Conversation
✅ Deploy Preview for infallible-bardeen-164bc9 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
When using server-side pooling, avoid explicit `PREPARE`/`EXECUTE` calls and use protocol-level prepared statements instead. Explicit prepare/execute calls can make connections sticky, preventing you from utilizing the benefits of the connection manager or server-side pooling. | ||
|
||
For example, with the NPGSQL driver, add the following to your connection string: | ||
`Max Auto Prepare=100;Auto Prepare Min Usages=5;`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this a proper code block. no period.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add the consult your driver documentation bit
|
||
When using server-side pooling, avoid explicit `PREPARE`/`EXECUTE` calls and use protocol-level prepared statements instead. Explicit prepare/execute calls can make connections sticky, preventing you from utilizing the benefits of the connection manager or server-side pooling. | ||
|
||
For example, with the NPGSQL driver, add the following to your connection string: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? What does this do? I don't understand the link between not using explicit PREPARE and doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have found a doc where some engineer has explained it some time back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"For protocol level prepared statements the location of phase type (prepare/bind/execute), ppstmt name and query is fixed and known to the odyssey. So odyssey is easily able to identify and modify the ppstmt name or prepare a query on the connection. But this is not true in case we want to use a PREPARE query (by either protocol)."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand the link with setting Max Auto Prepare and Auto Prepare Min Usages in the connections string. What do these options do/how do they help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markpyb Does every driver have some equivalent setting to turn on prepared statements? So would something like this work -
"Depending on your driver, you may have to set some parameters to leverage prepared statements. For example, Npgsql supports automatic preparation using the Max Auto Prepare and Auto Prepare Min Usages connection parameters, which you add to your connection string as follows:
Max Auto Prepare=100;Auto Prepare Min Usages=5;
Consult your driver documentation."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ddhodge yes every driver will have a different way to do it (if they support it) yes consult your driver documentation is good
the information is correct |
it looks like i cant see the preview version until @ddhodge suggestions are commited |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@netlify /stable/develop/best-practices-ysql/#re-use-query-plans-with-prepared-statements