pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
No problem, only curiosity
3+ messages / 2 participants
[nested] [flat]

* No problem, only curiosity
@ 2023-01-24 13:06  Loles <lolesft@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Loles @ 2023-01-24 13:06 UTC (permalink / raw)
  To: pgsql-admin

Hello community!

Does anyone know why I am getting a result less than 2 million rows in this
example?

postgres=# create table test_n_tup_live (id serial);
CREATE TABLE

postgres=# insert into test_n_tup_live select generate_series(1,1000000);
INSERT 0 1000000

postgres=# analyze test_n_tup_live ;
ANALYZE

postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where
relname = 'test_n_tup_live';

 n_live_tup | n_dead_tup
------------+------------
    1000000 |          0
(1 fila)

postgres=# update test_n_tup_live set id = id + 1;
UPDATE 1000000

postgres=# insert into test_n_tup_live select generate_series(1,1000000);
INSERT 0 1000000

postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where
relname = 'test_n_tup_live';
 n_live_tup | n_dead_tup
------------+------------
    2000000 |    1000000
(1 fila)

postgres=# vacuum test_n_tup_live;
VACUUM

postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where
relname = 'test_n_tup_live';

 n_live_tup | n_dead_tup
------------+------------
    1999925 |          0
(1 fila)

Thanks!

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: No problem, only curiosity
@ 2023-01-24 13:51  Erik Wienhold <ewie@ewie.name>
  parent: Loles <lolesft@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Erik Wienhold @ 2023-01-24 13:51 UTC (permalink / raw)
  To: Loles <lolesft@gmail.com>; pgsql-admin

> On 24/01/2023 14:06 CET Loles <lolesft@gmail.com> wrote:
>
> Does anyone know why I am getting a result less than 2 million rows in this
> example?
>
> postgres=# create table test_n_tup_live (id serial);
> CREATE TABLE
>
> postgres=# insert into test_n_tup_live select generate_series(1,1000000);
> INSERT 0 1000000
>
> postgres=# analyze test_n_tup_live ;
> ANALYZE
>
> postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where relname = 'test_n_tup_live';
>
>  n_live_tup | n_dead_tup
> ------------+------------
>  1000000 | 0
> (1 fila)
>
> postgres=# update test_n_tup_live set id = id + 1;
> UPDATE 1000000
>
> postgres=# insert into test_n_tup_live select generate_series(1,1000000);
> INSERT 0 1000000
>
> postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where relname = 'test_n_tup_live';
>  n_live_tup | n_dead_tup
> ------------+------------
>  2000000 | 1000000
> (1 fila)
>
> postgres=# vacuum test_n_tup_live;
> VACUUM
>
> postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where relname = 'test_n_tup_live';
>
>  n_live_tup | n_dead_tup
> ------------+------------
>  1999925 | 0
> (1 fila)

Both numbers are estimates: https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ALL-TABLES-VIEW

--
Erik





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: No problem, only curiosity
@ 2023-01-24 13:55  Loles <lolesft@gmail.com>
  parent: Erik Wienhold <ewie@ewie.name>
  0 siblings, 0 replies; 3+ messages in thread

From: Loles @ 2023-01-24 13:55 UTC (permalink / raw)
  To: Erik Wienhold <ewie@ewie.name>; +Cc: pgsql-admin

Oh yes.. sorry and thank you.

El mar, 24 ene 2023 a las 14:51, Erik Wienhold (<ewie@ewie.name>) escribió:

> > On 24/01/2023 14:06 CET Loles <lolesft@gmail.com> wrote:
> >
> > Does anyone know why I am getting a result less than 2 million rows in
> this
> > example?
> >
> > postgres=# create table test_n_tup_live (id serial);
> > CREATE TABLE
> >
> > postgres=# insert into test_n_tup_live select generate_series(1,1000000);
> > INSERT 0 1000000
> >
> > postgres=# analyze test_n_tup_live ;
> > ANALYZE
> >
> > postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where
> relname = 'test_n_tup_live';
> >
> >  n_live_tup | n_dead_tup
> > ------------+------------
> >  1000000 | 0
> > (1 fila)
> >
> > postgres=# update test_n_tup_live set id = id + 1;
> > UPDATE 1000000
> >
> > postgres=# insert into test_n_tup_live select generate_series(1,1000000);
> > INSERT 0 1000000
> >
> > postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where
> relname = 'test_n_tup_live';
> >  n_live_tup | n_dead_tup
> > ------------+------------
> >  2000000 | 1000000
> > (1 fila)
> >
> > postgres=# vacuum test_n_tup_live;
> > VACUUM
> >
> > postgres=# select n_live_tup, n_dead_tup from pg_stat_user_tables where
> relname = 'test_n_tup_live';
> >
> >  n_live_tup | n_dead_tup
> > ------------+------------
> >  1999925 | 0
> > (1 fila)
>
> Both numbers are estimates:
> https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ALL-TABLES-VIEW
>
> --
> Erik
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2023-01-24 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24 13:06 No problem, only curiosity Loles <lolesft@gmail.com>
2023-01-24 13:51 ` Erik Wienhold <ewie@ewie.name>
2023-01-24 13:55   ` Loles <lolesft@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox