On 10/31/19 3:45 PM, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
>> On October 31, 2019 7:06:13 AM PDT, Andrzej Barszcz <abusinf@gmail.com> wrote:
>>> Any pros and cons ?
>
>> Depends on the actual way of implementing this proposal. Think we need more details than what you idea here.
>
> We've typically supposed that the cost of searching for duplicate
> subexpressions would outweigh the benefits of sometimes finding them.
That is an important concern, but given how SQL does not make it
convenient to re-use partial results of calculations I think such
queries are quite common in real world workloads.
So if we can make it cheap enough I think that it is a worthwhile
optimization.
Andreas