Re: Speeding up query pulling comments from pg_catalog - Mailing list pgsql-performance

From Tom Lane
Subject Re: Speeding up query pulling comments from pg_catalog
Date
Msg-id 28922.1563825438@sss.pgh.pa.us
Whole thread Raw
In response to Re: Speeding up query pulling comments from pg_catalog  (Ken Tanzer <ken.tanzer@gmail.com>)
List pgsql-performance
Ken Tanzer <ken.tanzer@gmail.com> writes:
> On Sat, Jul 20, 2019 at 12:25 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> There's been assorted talk about various optimizations to
>> avoid unnecessary duplicate function calls,

> So I had read the sentence below to mean my functions would only get called
> once.  But is that sentence only supposed to apply to index scans?  Or does
> it mean the planner is allowed to optimize, but it just doesn't know how
> yet?

> A STABLE function cannot modify the database and is guaranteed to return
> the same results given the same arguments for all rows within a single
> statement. *This category allows the optimizer to optimize multiple calls
> of the function to a single call.*

It says "allows", not "requires".  But in particular, we've interpreted
that to mean trying to call a stable function (with constant or at least
stable arguments) once per query rather than once per row, as the naive
interpretation of SQL semantics would have us do.  Matching up textually
distinct calls has not been on the radar --- it seems fairly expensive
to do, with no return in typical queries, and relatively small return
even if we find a match.

            regards, tom lane



pgsql-performance by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: benchmarking effective_io_concurrency
Next
From: Kristian Ejvind
Date:
Subject: zabbix on postgresql - very slow delete of events