-
Notifications
You must be signed in to change notification settings - Fork 274
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
Big performance increase for PostgreSQL 12+ #497
Comments
Hi @feld, thank you for the heads up. I would be worried about setting this option for everyone upfront, but we can at least document it. Can you please send a PR either to Postgrex or to Postgrex adapter under EctoSQL (or both) with the steps for this configuration so people can try it out? Thank you! |
We have more information that would be great to have documented: PostgreSQL 11 and older:
PostgreSQL 12 and newer:
|
I'm investigating an Ecto performance problem right now, so I'd be happy to add to documentation. (Aside, in my case, Though, changing the planner for the entire session seems a fairly drastic adjustment. From the Postgres commit log:
And FWIW, Brandstetter on DBA.SO:
I suggest encouraging people to experiment before turning this on and are bitten later having forgotten about it. For example, per-session in
In contrast to that blog post (which recommends turning it on unless you know what you're doing), I would expect to turn this on only if you know the performance issue you are addressing, why the planner is inadequate in that case, and you've tried and/or can't help it with changes to statistics. (A nice example about adjusting planner statistics. ) |
The problem we see in Pleroma is with Postgres and prepared statements, which are all Ecto generates. Performance is good for the first 5 queries and then becomes terrible.
|
I tested this now (on pg13 with pgBouncer) and got |
My related story: https://elixirforum.com/t/ecto-query-often-timing-out-when-using-a-pin-next-to-module-attribute/40640 I think an option to disable prepared statements on per-query basis would be useful. |
This is being actively discussed on the Postgres mailing list as someone in the Go community hit the same issue and opened a bug report about the performance of the query planner with parameterized statements. There is one useful suggestion that Postgrex may be able to follow up on:
|
We added some more info in the docs about how you can use unnamed prepared statements using this driver: f092eb7 |
If we can apply
parameters: [plan_cache_mode: "force_custom_plan"]
only when PostgreSQL 12+ servers are being connected to we will get a big performance increase for all Ecto/Postgrex users.https://blog.soykaf.com/post/postgresql-elixir-troubles/
The text was updated successfully, but these errors were encountered: