|
|
|
|
|
by anarazel
3822 days ago
|
|
I think this is a pretty important area to work on. Not in the direction of query hints, but rather have "approved" query plans, and an interface to see new query plans, and how much their costs differ. That'd not only make production scenarios more reliable, but it'd also make it much easier to test tweaks to the cost model in practice. The problem is that that's a rather significant project, and it's hard to get funding for that kind of work. The postgres companies aren't that big, and it's not an all that sexy feature marketing wise. |
|
I also don't think that query hints are a good way to do it. And I don't mind if the way to do it is somewhat cumbersome. This is very much a case where 20% of the work can give 99% of the benefit.
For example what about the following approach?
1. Add an option to EXPLAIN that will cause PostgreSQL's optimizer to spit out multiple plans it considered, with costs, and with a description of the plan that PostgreSQL can easily parse and fit to a query.
2. Add a PLAN command that can be applied to a prepared statement and will set its plan. It is an error to submit a plan that does not match the query.
And now in the rare case where I don't like a query's plan I can:
Pick my desired plan from the list (hopefully)Then in my code I:
And now if I notice that a query performs worse than I think it should, I can make it do what I want it to.