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 1shXEa-003YqT-61 for pgsql-general@arkaria.postgresql.org; Fri, 23 Aug 2024 16:33:56 +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 1shXEY-00EwGA-7f for pgsql-general@arkaria.postgresql.org; Fri, 23 Aug 2024 16:33:54 +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 1shXEX-00EwFz-Qt for pgsql-general@lists.postgresql.org; Fri, 23 Aug 2024 16:33:54 +0000 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1shXEU-0018kO-GF for pgsql-general@lists.postgresql.org; Fri, 23 Aug 2024 16:33:53 +0000 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-70cb3eb4461so1009080a34.1 for ; Fri, 23 Aug 2024 09:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724430829; x=1725035629; darn=lists.postgresql.org; h=cc:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=TBypnIiQgsiNLCPxvZNVxy2Hwr9sX5CXcVrYvufjk+c=; b=hySUT0Ha7UuxLD+Xe0l2wcdLbXMlbrJxHABtrPoo6SohDcVLBTVvLLb+iq7G5OK2ci cJpjSQCt2fI+HCV0kdBV1UyEaGyLBnt3lUEAlSLNpwNZhJBmn4ktRyL5uj5QSSemJAQN UhOGM0pPpZqle2CXhhDOnpl3rwX7lXqTarvjZtKH1JFDSQ2Rj+vFvDdTb0iCXbAHoxPO PvKasWoYSh/wdaDvrBTRmFL7PdsS8LUjW2bA5HTvU49rV+5MSr/6Js+2rpwQrI7Ewgwb 8Ba6OA9H0zHvmrA5lVv+aL0iyL5+jHxTiyw0hyHNs+j85QB+7yNctpBrSc1UW7pW/yTW LTuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724430829; x=1725035629; h=cc:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TBypnIiQgsiNLCPxvZNVxy2Hwr9sX5CXcVrYvufjk+c=; b=YpJdOB+O8yH3lj4OsytZgZ7o0MApe73mfo73LfL0Torl6kxooe7B3yLc9E7fuUk/rV Al5T66npXK4r8LK3lnZLS3T1qdWWZAcksZj2mmEOwh3O9UMEXFBHZ0baAu3DVtLDkF8m qGUszOYJI8zR8ejRZCvzvvirOfnL6ziSejoKkdJdfNVoRjeBioVOgnmxpfGOE1Otm5zl VjCPZFY8d8D34OYbU7EuG5Cp3em4DAszf0OK0JOfED35QUJW9SUI/rKhCHgwfUm0FCx9 ypT+WDZ9YtKn+dnhiv6dPJfTMUJJezO3x+8Eo7jCqEZgvzZDs3B4ag7OtGQr41N4vn06 L9sQ== X-Gm-Message-State: AOJu0Yz0ZaNo+SJb6LG0PaJOOFJ63mZrQgdSRWm4f1Gec8R50EuIv3Es K5r0SFpRoRxxPwBURgtzqS5sJu82XtfZ27730V4nh5bAg3KmQwP6T5NLFVT4EN4bpu8nNjBUyzD 8w0wsGHsasebOc2jkHwn6maXLpmj3YuatRWY= X-Google-Smtp-Source: AGHT+IEPDQPlaoW8ShVvr/Hhu/cJaE/N5/6BSIsExq+7PTjKcHgYxppgPNcEdJVMSf36zgx7MAuFnwyyC9p3ssnksN4= X-Received: by 2002:a05:6830:43a2:b0:709:399f:5c31 with SMTP id 46e09a7af769-70e01b4d2d2mr2278641a34.4.1724430829481; Fri, 23 Aug 2024 09:33:49 -0700 (PDT) MIME-Version: 1.0 References: <19c4824f-24b8-4561-81c3-a2f4a7949803@aklaver.com> In-Reply-To: <19c4824f-24b8-4561-81c3-a2f4a7949803@aklaver.com> From: Matthew Tice Date: Fri, 23 Aug 2024 10:33:38 -0600 Message-ID: Subject: Re: dead tuple difference between pgstattuple and pg_stat_user_tables Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000007f78d06205c5754" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000007f78d06205c5754 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Aug 23, 2024 at 10:26=E2=80=AFAM Adrian Klaver wrote: > On 8/23/24 09:14, Matthew Tice wrote: > > Hi All, > > > > I'm trying to understand why there's a difference between what > > pgstattuple reports and pg_stat_user_tables reports (for the number of > > dead tuples). > > > > As I understand, pgstattuple and pgstattuple_approx return the exact > > number of dead tuples (as noted in the documentation) and based on an > > https://www.postgresql.org/docs/current/pgstattuple.html > > pgstattuple_approx(regclass) returns record > > pgstattuple_approx is a faster alternative to pgstattuple that > returns approximate results. > > Not sure how you get exact count out of that? > Maybe the wording is a little confusing to me. Under the section for pgstattuple_approx: "pgstattuple_approx tries to avoid the full-table scan and returns exact dead tuple statistics along with an approximation of the number and size of live tuples and free space." > > > This is a Google Alloy DB instance running: > > https://cloud.google.com/alloydb/docs/overview > > "AlloyDB for PostgreSQL is a fully managed, PostgreSQL-compatible > database service that's designed for your most demanding workloads, > including hybrid transactional and analytical processing. AlloyDB pairs > a Google-built database engine with a cloud-based, multi-node > architecture to deliver enterprise-grade performance, reliability, and > availability." > > Where the important parts are 'PostgreSQL-compatible' and 'Google-built > database engine'. You probably need to reach out to Google to see what > that means for this situation. > > Got it, thanks Adrian. > > > > select version(); > > -[ RECORD 1 ]------------------------- > > version | PostgreSQL 14.10 on x86_64-pc-linux-gnu, compiled by Debian > > clang version 12.0.1, 64-bit > > SELECT 1 > > -- > Adrian Klaver > adrian.klaver@aklaver.com > > --00000000000007f78d06205c5754 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Aug 23, 2024 at 10:26=E2=80= =AFAM Adrian Klaver <adrian= .klaver@aklaver.com> wrote:
On 8/23/24 09:= 14, Matthew Tice wrote:
> Hi All,
>
> I'm trying to understand why there's a difference between what=
> pgstattuple reports and pg_stat_user_tables reports (for the number of=
> dead tuples).
>
> As I understand, pgstattuple and pgstattuple_approx return the exact <= br> > number of dead tuples (as noted in the documentation) and based on an =

https://www.postgresql.org/docs/current/pgst= attuple.html

pgstattuple_approx(regclass) returns record

=C2=A0 =C2=A0 =C2=A0pgstattuple_approx is a faster alternative to pgstattup= le that
returns approximate results.

Not sure how you get exact count out of that?

Maybe the wording is a little confusing to me. Under the section for= =C2=A0pgstattuple_approx:
"pgstattuple_approx tries to avoid= the full-table scan and returns exact dead tuple statistics along with an = approximation of the number and size of live tuples and free space."
=C2=A0

> This is a Google Alloy DB instance running:

https://cloud.google.com/alloydb/docs/overview

"AlloyDB for PostgreSQL is a fully managed, PostgreSQL-compatible
database service that's designed for your most demanding workloads, including hybrid transactional and analytical processing. AlloyDB pairs a Google-built database engine with a cloud-based, multi-node
architecture to deliver enterprise-grade performance, reliability, and
availability."

Where the important parts are 'PostgreSQL-compatible' and 'Goog= le-built
database engine'. You probably need to reach out to Google to see what =
that means for this situation.

Got it, thanks Adrian.
=C2=A0

>=C2=A0 > select version();
> -[ RECORD 1 ]-------------------------
> version | PostgreSQL 14.10 on x86_64-pc-linux-gnu, compiled by Debian =
> clang version 12.0.1, 64-bit
> SELECT 1

--
Adrian Klaver
adrian.klave= r@aklaver.com

--00000000000007f78d06205c5754--