Re: does refreshing materialized view make the database bloat?

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: pgsql-general list <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: does refreshing materialized view make the database bloat?
Date: 2023-01-16 05:29:15
Message-ID: CACJufxFih3vdjpG2SW-Q1aTEv20pR6P2o9V1JV4DPz9L08rD6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 16, 2023 at 10:28 AM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Sunday, January 15, 2023, jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
>>
>>
>> Hi,
>> why the materialized view itself bloats. If no refresh then no bloat
>> right? If fresh then set based delete operation will make materialized view
>> bloat?
>> I also found the same question online.
>> https://dba.stackexchange.com/questions/219079/bloat-on-materialized-views
>> Unfortunately nobody answered...
>>
>>
> The definition of bloat is a deleted row. Bloat can be reduced by
> subsequent row insertions.
>
> David J.
>
>
Hi.
In the following example, I cannot see bloat (via extension pgstattuple
dead_tuple_count>0). Wondering where the bloat is.

BEGIN;create table tbt( a int) with(fillfactor=40, autovacuum_enabled=off);
insert into tbt select g from generate_series(1,2000) g;
create materialized view tbtmv as select * from tbt;
commit;

--------do the update.
update tbt set a = 10 + a where a < 20;
REFRESH MATERIALIZED view tbtmv;
SELECT * FROM pgstattuple('tbtmv'); -----no dead tuples count.

------try delete.
delete from tbt where a < 50;
REFRESH MATERIALIZED view tbtmv;
SELECT * FROM pgstattuple('tbtmv');-------still no dead tuples.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2023-01-16 05:43:41 Re: does refreshing materialized view make the database bloat?
Previous Message David G. Johnston 2023-01-16 04:58:17 Re: does refreshing materialized view make the database bloat?