On 24/6/2022 23:43, Leif Harald Karlsen wrote:
> Thank you for the quick answer, and for the pointer to the patch! This
> looks like just the thing I need!
> On a more general note: What would, in general, be the best way to
> implement such optimizations? Is there a good way to do this as an
> extension, or is a patch the preferred way?
According to my experience, it depends on your needings.
For example, self-join-removal feature, or my current project -
flattening of nested subqueries - is much more optimal to implement as a
patch, because you can do it so early as possible and can generalize
parts of the core code and thus, reduce size of your code a lot.
But if you want to use your code with many PG versions, even already
working in production or you make just a research, without immediate
practical result - your choice is an extension.
--
regards,
Andrey Lepikhov
Postgres Professional