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 1pKJiU-0005qf-OD for pgsql-admin@arkaria.postgresql.org; Tue, 24 Jan 2023 13:52:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pKJiT-0004Sf-KX for pgsql-admin@arkaria.postgresql.org; Tue, 24 Jan 2023 13:52:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKJiT-0004SW-AV for pgsql-admin@lists.postgresql.org; Tue, 24 Jan 2023 13:52:01 +0000 Received: from mout-u-204.mailbox.org ([80.241.59.204]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKJiQ-0005ug-ST for pgsql-admin@postgresql.org; Tue, 24 Jan 2023 13:52:00 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4P1T0q4DPjz9sQS; Tue, 24 Jan 2023 14:51:55 +0100 (CET) Date: Tue, 24 Jan 2023 14:51:55 +0100 (CET) From: Erik Wienhold To: Loles , pgsql-admin@postgresql.org Message-ID: <2014960602.121600.1674568315040@office.mailbox.org> In-Reply-To: References: Subject: Re: No problem, only curiosity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 24/01/2023 14:06 CET Loles wrote: > > Does anyone know why I am getting a result less than 2 million rows in th= is > example? > > postgres=3D# create table test_n_tup_live (id serial); > CREATE TABLE > > postgres=3D# insert into test_n_tup_live select generate_series(1,1000000= ); > INSERT 0 1000000 > > postgres=3D# analyze test_n_tup_live ; > ANALYZE > > postgres=3D# select n_live_tup, n_dead_tup from pg_stat_user_tables where= relname =3D 'test_n_tup_live'; > > =C2=A0n_live_tup | n_dead_tup > ------------+------------ > 1000000 | 0 > (1 fila) > > postgres=3D# update test_n_tup_live set id =3D id + 1; > UPDATE 1000000 > > postgres=3D# insert into test_n_tup_live select generate_series(1,1000000= ); > INSERT 0 1000000 > > postgres=3D# select n_live_tup, n_dead_tup from pg_stat_user_tables where= relname =3D 'test_n_tup_live'; > =C2=A0n_live_tup | n_dead_tup > ------------+------------ > 2000000 | 1000000 > (1 fila) > > postgres=3D# vacuum test_n_tup_live; > VACUUM > > postgres=3D# select n_live_tup, n_dead_tup from pg_stat_user_tables where= relname =3D 'test_n_tup_live'; > > =C2=A0n_live_tup | n_dead_tup > ------------+------------ > 1999925 | 0 > (1 fila) Both numbers are estimates: https://www.postgresql.org/docs/current/monitor= ing-stats.html#MONITORING-PG-STAT-ALL-TABLES-VIEW -- Erik