pg_plan_guarantee icon indicating copy to clipboard operation
pg_plan_guarantee copied to clipboard

Storage of guaranteed plans

Open akorotkov opened this issue 2 years ago • 1 comments

Hi!

Thank you for your work. Guaranteed plans are definitely highly demanded by users.

I think it's not convenient for users to manually specify the guaranteed plan. It's hard to manage at the application/user level. And it is very error-prone. An incorrect plan could easily cause a segfault or wrong query result.

I think this extension needs storage for saved guaranteed plans. So, the user can store a current plan for a given query and then use it as a guaranteed plan.

It's important to automatically invalidate saved plans on DDL. Hopefully, pg_depend mechanism could be used for this.

It will be also nice to be able to write saved plans outside of transactional scope. Also, it would be useful to have dedicated plan storage on replicas, because replicas could need a distinct set of guaranteed plans. Both requirements could be easily fulfilled by OrioleDB.

Looking forward to your feedback.

akorotkov avatar Apr 05 '22 14:04 akorotkov

Alternatively to invalidation saves plan on DDL, I can propose to store not serialized plans, but just hints (for instance, that could be pg_hint_plan hints). This would save US from invalid plans. However, extraction of hints from the plan is separate complex task.

akorotkov avatar Apr 05 '22 14:04 akorotkov