Re: BUG #8681: column 'n_tup_del' of pg_stat_user_tables doesn't change in case of truncate - Mailing list pgsql-bugs

From Anit Chakkarwar
Subject Re: BUG #8681: column 'n_tup_del' of pg_stat_user_tables doesn't change in case of truncate
Date
Msg-id CABkhq9EdDA_Zxqyv3eYbc=uQpSHyavs1268F0PbbSdcobqA-Ag@mail.gmail.com
Whole thread Raw
In response to Re: BUG #8681: column 'n_tup_del' of pg_stat_user_tables doesn't change in case of truncate  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #8681: column 'n_tup_del' of pg_stat_user_tables doesn't change in case of truncate  (Stephen Frost <sfrost@snowman.net>)
List pgsql-bugs
Hi Tom,

Thanks, I have one query please refer below scenario.

1. Create table.
2. Insert 100 rows.
3. Delete 2 rows.
4. Truncate table.
5. Do vacuum
6. Insert 20 rows again. (Table count is 20 now)

Now n_tup_del = 2, n_tup_ins=120, n_live_tup=20 in pg_stat_user_tables, but
how can I figure out what has happened to 98 rows?


Regards,
Anit Chakkarwar


On Fri, Dec 13, 2013 at 11:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

> anitchakkarwar@gmail.com writes:
> > If I do truncate then n_tup_del value is 0 but all the rows are deleted
> from
> > table.
> > Is this something expected behaviour ?
>
> Yes.  We're certainly not going to make TRUNCATE update that count, since
> that would require making a pass over the table to count the to-be-deleted
> tuples, and the whole point of TRUNCATE is to not make a pass over the
> table.
>
>                         regards, tom lane
>

pgsql-bugs by date:

Previous
From: Sandeep Thakkar
Date:
Subject: Re: permission issues with PostgreSQL 9.2 EnterpriseDB one-click installer on windows 7 causes initcluster to fail
Next
From: gert.wieberdink@ziggo.nl
Date:
Subject: BUG #8683: pg_upgrade