Re: function calls optimization - Mailing list pgsql-hackers

From Tom Lane
Subject Re: function calls optimization
Date
Msg-id 19586.1572534410@sss.pgh.pa.us
Whole thread Raw
In response to Re: function calls optimization  (Andres Freund <andres@anarazel.de>)
Responses Re: function calls optimization
Re: function calls optimization
List pgsql-hackers
Andres Freund <andres@anarazel.de> writes:
> On October 31, 2019 7:45:26 AM PDT, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> We've typically supposed that the cost of searching for duplicate
>> subexpressions would outweigh the benefits of sometimes finding them.

> Based on profiles I've seen I'm not sure that's the right choice. Both for when the calls are expensive (say postgis
stuff),and for when a lot of rows are processed. 

Yeah, if your mental model of a function call is some remarkably expensive
PostGIS geometry manipulation, it's easy to justify doing a lot of work
to try to detect duplicates.  But most functions in most queries are
more like int4pl or btint8cmp, and it's going to be extremely remarkable
if you can make back the planner costs of checking for duplicate usages
of those.

Possibly this could be finessed by only trying to find duplicates of
functions that have high cost estimates.  Not sure how high is high
enough.

> I think one part of doing this in a realistic manner is an efficient
> search for redundant expressions. The other, also non trivial, is how to
> even represent re eferences to the results of expressions in other parts of the expression tree / other expressions.

Yup, both of those would be critical to do right.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andreas Karlsson
Date:
Subject: Re: function calls optimization
Next
From: Andres Freund
Date:
Subject: Re: function calls optimization