Re: BUG #8681: column 'n_tup_del' of pg_stat_user_tables doesn't change in case of truncate

From: Anit Chakkarwar <anitchakkarwar(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8681: column 'n_tup_del' of pg_stat_user_tables doesn't change in case of truncate
Date: 2013-12-16 13:21:40
Message-ID: CABkhq9EdDA_Zxqyv3eYbc=uQpSHyavs1268F0PbbSdcobqA-Ag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> anitchakkarwar(at)gmail(dot)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
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Stephen Frost 2013-12-16 15:50:37 Re: BUG #8681: column 'n_tup_del' of pg_stat_user_tables doesn't change in case of truncate
Previous Message Sandeep Thakkar 2013-12-16 06:35:16 Re: permission issues with PostgreSQL 9.2 EnterpriseDB one-click installer on windows 7 causes initcluster to fail