Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uxZdW-00FnHb-Cw for pgsql-docs@arkaria.postgresql.org; Sat, 13 Sep 2025 23:26:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uxZdU-006kKK-A4 for pgsql-docs@arkaria.postgresql.org; Sat, 13 Sep 2025 23:26:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uxZdU-006kKC-1c for pgsql-docs@lists.postgresql.org; Sat, 13 Sep 2025 23:26:28 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uxZdQ-000ez2-2H for pgsql-docs@lists.postgresql.org; Sat, 13 Sep 2025 23:26:28 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-4382709a3f8so125081b6e.0 for ; Sat, 13 Sep 2025 16:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757805982; x=1758410782; darn=lists.postgresql.org; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=KN8Nv93Mp+PyHLaK3hVzbymJCfPry1BEgcwR+L3aKB8=; b=Qp4uZYutwGPB54RXx7hh6wAWD9sV82FwNNkMsmyEmcHL5fE7F35eWM3ZPdZ+4srMkQ a3FNU83ZW/DoI8y8bpSEhtTD4Nue+3Y9vFQG/kAMV4AbN5jmxFSDh9oFGZjMEKxzrIn6 H5F8XLCFAArP9CneRitOMIgqNcOuylcoAk9dw6ln6IWi9CM4OlqoWs43TaCmQ/jAK1jy 5/4bMWp89+yT1ieoJy02pD0OgiqPDTFgYXhKAst/aHlbXYbPXfzcrhF2+m/Hc7kp8LvE 96opR22awkZB49YBZsv3uasUqBKMsdhEVFj3/Xo5b1bGiR7UNdHuGMRg7jtxeKCZRr2D ygug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757805982; x=1758410782; h=to:subject:message-id:date:from:references:in-reply-to:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KN8Nv93Mp+PyHLaK3hVzbymJCfPry1BEgcwR+L3aKB8=; b=SO2dAb99oRMOrxMewYlj4UNu+yLUl4ZWGz5nd9/2Nm5UE6T0jULEAKwYDxRZpA9IUs xnmxccJ7XwGDcq74uir+BDconCZ1d/Pazh6ASar02t+ToG3BrC6/CVgkp65NlhjmYnwr JCLN7bgZdXojr8XejsWM7Gx4ul7fsshD/NV0qpvD5AU5VjL+hj4q35+TBA57XzH/+vCq q1fcSMN/KXS7DqvNgUi3u8V+jS0wzp26Go1UegfAWC0yGYP3tfckGNlf/nCDT2bxPbek KsmkC/Ub2Xo9ysykKg2NgP8CR3rJ/xsDdQ8D7AqjoV3mNIMO75QDumx5RVL41sxl1cXX PX+g== X-Forwarded-Encrypted: i=1; AJvYcCWp59c/uhrCRGgeD0JzhcDW1sjTenPdRJk8IOZhhwdzSgIguIGgl+GUfOZWoIE4JGmIqCmQKNAOPeTs@lists.postgresql.org X-Gm-Message-State: AOJu0YxwAAxvyoB6Wk6D2u4UAvWRnxExsM1e4ph1nETHzeNx5Cuox+69 aKq1+o+ofRLJO5DHZsuR9VQBm0mKYHOC/mGUpS2N7yI1wgMYAPTzk6O2BBsat32ueWrrDgvlGvH EDU3Jw6iShludtAvuYybgySWNXaqTZAT6sA== X-Gm-Gg: ASbGncvXBOoyWaooGjov8AMvO2+m0hgQoNqUD4C2DkjdY09QUnw+YpeXm9KLqwy0BKu phwmagnfMtD1Pugw6BrSowrmulnwOx1+2Wa8guZA6ZwCj3qm9RpXCp+TZS1Kabfd3jOoQoDRPEK zY1GXzlaXkndyzAxjcki0W9RsIlpXtn1Qb+s2/cFxEH9tRzqYFXY8QFyPIZaofnnklgOQ7j3lvs BcilZYgPCsbPldM X-Google-Smtp-Source: AGHT+IGb1MDyldC7lfS3D1pDSUmE1/Ak5nA9o3qCRHVSVaW3DpovLHvqMQjYQNEJraw5OYlUtBH+Ey7Dt+gIV45Jql8= X-Received: by 2002:a05:6808:1819:b0:438:40c3:8750 with SMTP id 5614622812f47-43b8da3a76fmr3747463b6e.37.1757805982415; Sat, 13 Sep 2025 16:26:22 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a05:6802:34ce:10b0:5df:b5f6:b71 with HTTP; Sat, 13 Sep 2025 16:26:21 -0700 (PDT) In-Reply-To: <175779557876.861.12514976006917547591@wrigleys.postgresql.org> References: <175779557876.861.12514976006917547591@wrigleys.postgresql.org> From: "David G. Johnston" Date: Sat, 13 Sep 2025 16:26:21 -0700 X-Gm-Features: Ac12FXwrbf24wkR1NrjQNybcwU-J1WQFIexNHPD3F8ghi_BHXePqee8BesNiIQs Message-ID: Subject: Re: The document contains false statements To: "kes-kes@yandex.ru" , "pgsql-docs@lists.postgresql.org" Content-Type: multipart/alternative; boundary="0000000000002a82bf063eb71994" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002a82bf063eb71994 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Saturday, September 13, 2025, PG Doc comments form < noreply@postgresql.org> wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/17/sql-createfunction.html > Description: > > > This is effectively another way of declaring a named OUT parameter > > Actually OUT works twice slower in compare to RETURNS TABLE > https://stackoverflow.com/q/79763947/4632019 > > DB<>fiddle for [`OUT`](https://dbfiddle.uk/fz9L_wm0) and [`RETURNS > TABLE`](https://dbfiddle.uk/uTkU1MT8) cases. > > *I hope after the fix, data centers will consume 2 times less electricity > > The statement is not false - it contains an =E2=80=9Cexcept=E2=80=9D clause= that you=E2=80=99ve ignored which makes it true for exactly this reason. The fact you are comparing a set-returning function to one that doesn=E2=80=99t return a set= has invalidated the test. The fundamental issue here is =E2=80=9Cselect (composite_func()).*=E2=80=9D= where the function is not set-returning if known to be broken - the =E2=80=9C*=E2=80= =9D expansion during planning results in the function being executed multiple times once for each output column. (I may be missing some nuances here as, since the inclusion of lateral joins, this almost never comes up anymore.) Non-trivial function calls should be placed in the FROM clause of a query; in part to ensure avoidance of this problematic behavior. This is not at all limited to RLS. In short, I don=E2=80=99t know how to improve the documentation to prevent = people from writing bad queries of this type. Concrete suggestions are welcome, but removing this sentence, or re-wording it, doesn=E2=80=99t seem like it = would make any difference. David J. --0000000000002a82bf063eb71994 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Saturday, September 13, 2025, PG Doc comments form <noreply@postgresql.org> wrote:
The following documentation comment has been logged o= n the website:

Page: https://www.postgresql.org/docs/17/sql-createfunct= ion.html
Description:

> This is effectively another way of declaring a named OUT parameter

Actually OUT works twice slower in compare to RETURNS TABLE
= https://stackoverflow.com/q/79763947/4632019

DB<>fiddle for [`OUT`](https://dbfiddle.uk/fz9L_wm0) and [`RETURNS
TABLE`](https://= dbfiddle.uk/uTkU1MT8) cases.

*I hope after the fix, data centers will consume 2 times less electricity

The statement is not false - it contains a= n =E2=80=9Cexcept=E2=80=9D clause that you=E2=80=99ve ignored which makes i= t true for exactly this reason.=C2=A0 The fact you are comparing a set-retu= rning function to one that doesn=E2=80=99t return a set has invalidated the= test.

The fundamental issue here is =E2=80=9Csele= ct (composite_func()).*=E2=80=9D where the function is not set-returning if= known to be broken - the =E2=80=9C*=E2=80=9D expansion during planning res= ults in the function being executed multiple times once for each output col= umn. (I may be missing some nuances here as, since the inclusion of lateral= joins, this almost never comes up anymore.)

N= on-trivial function calls should be placed in the FROM clause of a query; i= n part to ensure avoidance of this problematic behavior.

This is not at all limited to RLS.

In short= , I don=E2=80=99t know how to improve the documentation to prevent people f= rom writing bad queries of this type.=C2=A0 Concrete suggestions are welcom= e, but removing this sentence, or re-wording it, doesn=E2=80=99t seem like = it would make any difference.

David J.
<= br>
--0000000000002a82bf063eb71994--