Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mD81c-0004ec-Uc for pgsql-docs@arkaria.postgresql.org; Mon, 09 Aug 2021 16:21:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mD81b-0000mt-Tx for pgsql-docs@arkaria.postgresql.org; Mon, 09 Aug 2021 16:21:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mD81b-0000mg-MM for pgsql-docs@lists.postgresql.org; Mon, 09 Aug 2021 16:21:15 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mD81X-0001J0-Vv for pgsql-docs@lists.postgresql.org; Mon, 09 Aug 2021 16:21:14 +0000 Received: by mail-pl1-x630.google.com with SMTP id t3so16926706plg.9 for ; Mon, 09 Aug 2021 09:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=5LlUZs95zBCR0qowCwRxv09J2RPx7ABjlOUldCMOJP0=; b=cur7EAEOmN36+31esQEVr43twHHpQhouDHMuehbcn1ypwfSU9MgT5pl7uZp/p0oDLi oJM+X2nYV185bl16jy9SXUr9/cpxRGpgdyW6n/Qj+KX+Q9+4htdZtsdROboXlK19McoJ EuLgA7axVJLYOIBao+OhIMnxpRXKSh1weBzCLtXGWX3rpO21ed6NIjkubnedxVC3/+td ELcNVL2n3j2cp8cMBKHDx5J5rGbbgh11ScgIC8y/vjy6iTtvsbK+WsrF2tbkyEgQ1HbA nrhYWV1A1kip7tHg3xL/y1uSmgLb98FT4YilUEahb8eyezJg09jCTRwcHIOJg3AtYVIG m4eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=5LlUZs95zBCR0qowCwRxv09J2RPx7ABjlOUldCMOJP0=; b=Drmh9mqLvdM2u18iDJD2h99fqVChzC9DPoBxOBIMlTB938Ta8ChjTdrx8Z0Zfv9DZ1 qeelje+jEFfgtDekvnTdgmD78YTDWiQQrB/U1kBhGsbG2xeDYG48HqfbrEAbfUG0UKyX jQMxmoX/8tvR6Ct9mR3KFImjowZLXOuvfGZlfxYCPQ6r8JuHFf/1oTJRPqOFjhwcRSKh J7mMQ3BYQgmiBB3Gzf8zCqsw9EXwyakhGQnPP/5IBXQlPJX9eC7GTHnz5iGIcJyerR70 COMZ/b0RNarJAckzD18ZSQwEIryuSHyGadJ/9us1rqkgO/X4RyuCuvmMvxE2ql5Gh3dX GPIg== X-Gm-Message-State: AOAM533Ct7ct6PqDXI6vucGWG1N/NS6YlmZhPDdFeMOnbqtQMoe9dWLs sdzTkIghhxT/pFdm4oMHBHrwsWtJwqnb5IDn2mQ= X-Google-Smtp-Source: ABdhPJwaWu7fFbYLAPYkRmmRstDIKtIF32ppQct2sp2mXx7oCI3jvzyPemjQwja3jdCnDLgBj1gdyuw/vRkwqqeFO0Q= X-Received: by 2002:a65:42c3:: with SMTP id l3mr651807pgp.377.1628526070935; Mon, 09 Aug 2021 09:21:10 -0700 (PDT) MIME-Version: 1.0 References: <162851358008.709.11763395628268716122@wrigleys.postgresql.org> In-Reply-To: From: "David G. Johnston" Date: Mon, 9 Aug 2021 09:20:53 -0700 Message-ID: Subject: Re: incorrect information in documentation To: ivanmulhin@gmail.com, Pg Docs , Tom Lane Content-Type: multipart/alternative; boundary="000000000000f733f805c922c523" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f733f805c922c523 Content-Type: text/plain; charset="UTF-8" On Mon, Aug 9, 2021 at 9:06 AM David G. Johnston wrote: > On Mon, Aug 9, 2021 at 8:02 AM PG Doc comments form < > noreply@postgresql.org> wrote: > >> Hello, on page >> https://www.postgresql.org/docs/current/row-estimation-examples.html - >> there >> is a example: >> selectivity = (1 - null_frac1) * (1 - null_frac2) * min(1/num_distinct1, >> 1/num_distinct2) >> = (1 - 0) * (1 - 0) / max(10000, 10000) >> = 0.0001 >> in the first string " * min" and in the second " / max" >> as I understand it isn't correct. >> > > Division is just multiplication by the reciprocal so while the > presentation here is inconsistent it is correct. Likewise, the larger a > number the smaller its reciprocal, so the change from min to max also > works. > > FWIW this used to be presented with the calculation and formula in sync, but the original had a simple typo in the calculation. When the typo got fixed back in December of 2007 [1] the author of the patch simplified the calculation at the same time. I suggest we update the formula line to match the calculation presented. David J. 1. https://github.com/postgres/postgres/commit/f5678e8e07563e34ae4dc832546977d13edcd665 --000000000000f733f805c922c523 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Aug 9, 2021 at 9:06 AM David G. Johnston <david.g.johnston@gmail.com>= wrote:
On Mon, Aug 9, 2021 at 8:02 AM PG Doc comments fo= rm <noreply@= postgresql.org> wrote:
Hello, on page
https://www.postgresql.org/docs/= current/row-estimation-examples.html - there
is a example:
selectivity =3D (1 - null_frac1) * (1 - null_frac2) * min(1/num_distinct1,<= br> 1/num_distinct2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D (1 - 0) * (1 - 0) / max(10000= , 10000)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 0.0001
in the first string=C2=A0 " * min" and in the second " / max= "
as I understand it isn't correct.

Division is just multiplica= tion by the reciprocal so while the presentation here is inconsistent it is= correct.=C2=A0 Likewise, the larger a number the smaller its reciprocal, s= o the change from min to max also works.=C2=A0=C2=A0


FWIW this used to be presented with the calculation and form= ula in sync, but the original had a simple typo in the calculation.=C2=A0 W= hen the typo got fixed back in December of 2007 [1] the author of the patch= simplified the calculation at the same time.=C2=A0 I suggest we update the= formula line to match the calculation presented.

Davi= d J.

--000000000000f733f805c922c523--