I have a question about the number of deadtuples after an update scenario in PGSQL.
Due to MVCC protocol in PGSQL, many updates cause the tables to bloat. We may track this with the number of dead tuples in the table. In the following scenario, I can't give any meaning the number of dead tuples in the following scenario.
I am updating "pgbench_accounts" table with the following testcase:
First, I turnedd off autovacuum in the system beforehand. ...=alter system set autovacuum to off; ...=# select pg_reload_conf();
Then I load the pgbench tables. > pgbench -i -- Now, pgbench_accounts has 100.000 tuples
Then I am updating randomly generated tuples as below: >pgbench -t10000 -fupdate-only -n
update-only tx is as the following:
\set aid random(1, 100000 * :scale)
\set delta random(-5000, 5000)
BEGIN;
UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
END;
As you guess, I want to update 10.000 tuples with a serial of simple update tx as shown above.
After the process end, I am seeing: 9543 updated tuples. That seems OK, because some tuples are updated twice or more. The problem is I am seeing only 3277 dead tuples.
Although I turned off autovacuum, some dead tuples disappear. how does this happen? I am expecting to see, at least the same number of updated tuples?