pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken Tanzer <ken.tanzer@gmail.com>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Speeding up query pulling comments from pg_catalog
Date: Mon, 22 Jul 2019 15:57:18 -0400
Message-ID: <28922.1563825438@sss.pgh.pa.us> (raw)
In-Reply-To: <CAD3a31XiBoRDozzn+jFc9EXrGL=Og0iOUL1rgr+m--g7QMr4ag@mail.gmail.com>
References: <CAD3a31UEEojeQ9VYZHO0u2j0eyyh5jaYd8Pc=7yfJEHrfzELFg@mail.gmail.com>
	<19788.1563634004@sss.pgh.pa.us>
	<CAD3a31U5Kb48p32AbiaZqMa-Rg1R3f7JvZY1Vgkx4Y31XqigRg@mail.gmail.com>
	<11474.1563650703@sss.pgh.pa.us>
	<CAD3a31XiBoRDozzn+jFc9EXrGL=Og0iOUL1rgr+m--g7QMr4ag@mail.gmail.com>

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





view thread (6+ messages)

Message-ID: <28922.1563825438@sss.pgh.pa.us>
Permalink:  ../28922.1563825438@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28922.1563825438@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ken.tanzer@gmail.com, pgsql-performance@lists.postgresql.org
  Subject: Re: Speeding up query pulling comments from pg_catalog
  In-Reply-To: <28922.1563825438@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox