Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1houyt-0000WB-Dv for pgsql-performance@arkaria.postgresql.org; Sat, 20 Jul 2019 19:25:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1houyr-0003VM-5y for pgsql-performance@arkaria.postgresql.org; Sat, 20 Jul 2019 19:25:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1houyq-0003VF-TU for pgsql-performance@lists.postgresql.org; Sat, 20 Jul 2019 19:25:16 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1houyj-0002Xo-Si for pgsql-performance@lists.postgresql.org; Sat, 20 Jul 2019 19:25:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x6KJP3mT011475; Sat, 20 Jul 2019 15:25:03 -0400 From: Tom Lane To: Ken Tanzer cc: pgsql-performance@lists.postgresql.org Subject: Re: Speeding up query pulling comments from pg_catalog In-reply-to: References: <19788.1563634004@sss.pgh.pa.us> Comments: In-reply-to Ken Tanzer message dated "Sat, 20 Jul 2019 12:08:00 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11473.1563650703.1@sss.pgh.pa.us> Date: Sat, 20 Jul 2019 15:25:03 -0400 Message-ID: <11474.1563650703@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ken Tanzer writes: > On Sat, Jul 20, 2019 at 7:46 AM Tom Lane wrote: >> and then to add insult to injury, has to search pg_description a second >> time for each hit. > Not sure if I'm understanding this correctly, but are you saying that > because col_description() is specified in two places in the query, that it > actually will get called twice? Yes. > I was under the impression that a function > (at least a non-volatile one) specified multiple times, but with the same > arguments, would only get called once. Is that just wishful thinking? Afraid so. There's been assorted talk about various optimizations to avoid unnecessary duplicate function calls, but I don't think that merging textually-separate calls has even been on the radar. The discussions I can recall have been more about not calling stable functions (with fixed arguments) more than once per query. regards, tom lane