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 1nzlAQ-0007XL-LE for pgsql-admin@arkaria.postgresql.org; Fri, 10 Jun 2022 20:23:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nzlAN-0005YA-US for pgsql-admin@arkaria.postgresql.org; Fri, 10 Jun 2022 20:23:35 +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 1nzlAN-0005Y1-Hz for pgsql-admin@lists.postgresql.org; Fri, 10 Jun 2022 20:23:35 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nzlAH-0005Qp-30 for pgsql-admin@lists.postgresql.org; Fri, 10 Jun 2022 20:23:34 +0000 Received: by mail-pf1-x42a.google.com with SMTP id z17so383354pff.7 for ; Fri, 10 Jun 2022 13:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:from:mime-version:date:subject:message-id :to; bh=tPTgO+rarzq5mnRVQmSX1c6DBFtcex1fXM+I1mQ0pCs=; b=iVLvNExdyppwCqrlFiOrokK0Nfpi1yOULIPzDODnFT2a4/GAGCmjVMCEqE9HWOPGlh HjM35PVE0seRehRu51bpFt5i6F7JH0djFrYVU9NUHc/hlz1gylXqqEcbGhJCsCwAofrZ vjcjjOuvYQB63/rVDAmKtovAdT+EmvME9gReY67uMJmideL9QvI3x/3a7QUIZw3AQfS7 b3tQNkhiKCmoY0MTSzFSsiLBifS24HlIJkvQOWPcXdJnjbCTM8tUCOlVzDoQtdnrxjy9 6QATV8GemZ3dvQ+efkqH4ImmwGMoCjEd/pyut+gTbRPSvxH527StHmq24GbpoZbheaBL 2ohw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:content-transfer-encoding:from:mime-version:date :subject:message-id:to; bh=tPTgO+rarzq5mnRVQmSX1c6DBFtcex1fXM+I1mQ0pCs=; b=yisrZCblMDU6opuhV10UrOlfqNv+O6W3B+YvkBS3/LkxKYW/niy9o4CfdU+qmzUMwm RrRK3L7AxyABd+Af/IXyTIzvd2GTJIECVTS8pS1Ad9UMnrcQ1NwTNBi7vUHQ+81FLTmx ZwKqG34ij47gPdvNzdvcvj1RN9/7jVfWwGWD7b+5v5pWufEDZwE2/Jy+7Pnf7OEGlsHK 79ZsCdZIM305Z7Vp0tvkTfdwsyVRJ3mRNbrB0ZBaioRm8M2vqArNbF4Y4dzPgNmp2OUP l/Qc42ax7Y16yY4j/bPFpKlWPTEmYfKRuUMcANsdkNw3absPyBOheLL6g5IKWhBGR8Me GzWQ== X-Gm-Message-State: AOAM533P2Jc/DI32sKqS+5YPaCou0p32UlEsZfC3jDY7nSkpIdbiXBzI iCG6806J3TNYLED7UN+kf5yWuKeQ8O8= X-Google-Smtp-Source: ABdhPJwbItx7hBO3nNr6bCBcu8Fi3qjd9luXas3gKhtXLGRJmcz8L1KtKCnrDrI3QKyf3ZhYrVjK7g== X-Received: by 2002:a63:84c7:0:b0:3fd:862:df17 with SMTP id k190-20020a6384c7000000b003fd0862df17mr36497830pgd.28.1654892607535; Fri, 10 Jun 2022 13:23:27 -0700 (PDT) Received: from smtpclient.apple (2603-8001-3e43-3464-a039-fcf2-daee-ab43.res6.spectrum.com. [2603:8001:3e43:3464:a039:fcf2:daee:ab43]) by smtp.gmail.com with ESMTPSA id ik3-20020a170902ab0300b0015e8d4eb246sm131387plb.144.2022.06.10.13.23.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Jun 2022 13:23:27 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-626EB01A-09D1-4558-93F5-D9C779026737 Content-Transfer-Encoding: 7bit From: Teja Jakkidi Mime-Version: 1.0 (1.0) Date: Fri, 10 Jun 2022 13:23:26 -0700 Subject: N_live_tup value is less than actual row count in a table Message-Id: To: pgsql-admin@lists.postgresql.org X-Mailer: iPhone Mail (19A404) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-626EB01A-09D1-4558-93F5-D9C779026737 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Hello PGSQL Admin group, I am noticing this wierd behavior and not sure if this is how Postgres actu= ally works. I have a test table with 100000 rows and I deleted 20000 rows. So the curren= t rows are 80000 and dead tuples should be 20000. After autovacuum completed= , the dead tuples were gone. When querying the pg_stat_all_tables, it returned n_live_tup value as 63945.= Why is it less than actual row count 80000? I read some articles and it is suggested to analyze manually to bring that n= _live_tup number to actual row count. And it did work. After manual analyze,= the n_live_tup is showing as 80000.=20 I am having hard time understanding why is this behavior and if there is som= ething internally that is happening which I am missing. Please help me under= stand. Thanks, Teja.= --Apple-Mail-626EB01A-09D1-4558-93F5-D9C779026737 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello PGSQL Admin group,

I am noticing this wierd  behavior and not sure if this is how Postgre= s actually works.

I have a test table with 100000 r= ows and I deleted 20000 rows. So the current rows are 80000 and dead tuples s= hould be 20000. After autovacuum completed, the dead tuples were gone.
=
When querying the pg_stat_all_tables, it returned n_live_tup value= as 63945. Why is it less than actual row count 80000?

<= div>I read some articles and it is suggested to analyze manually to bring th= at n_li= ve_tup number to actual row count. And it did work. After manual= analyze, the n_live_tup is showing as 80000. 
I am having hard time u= nderstanding why is this behavior and if there is something internally that i= s happening which I am missing. Please help me understand.
=
Thanks,
Teja.
= --Apple-Mail-626EB01A-09D1-4558-93F5-D9C779026737--