Обсуждение: REFRESH MATERIALIZED VIEW CONCURRENTLY is blocking autovacuum on table

Поиск
Список
Период
Сортировка

REFRESH MATERIALIZED VIEW CONCURRENTLY is blocking autovacuum on table

От
Dirk Krautschick
Дата:
Hi,

I have a situation here where a frequent 

REFRESH MATERIALIZED VIEW CONCURRENTLY

is preventing autovacuum on some tables kind of running into a circle of growing.

Why is this acutally blocking autovacuum and what is the best practice to prevent 
this excelt just not refreshing the materialized view frequently? :-)

Cheers

Dirk

Re: REFRESH MATERIALIZED VIEW CONCURRENTLY is blocking autovacuum on table

От
Adrian Klaver
Дата:
On 2/8/26 17:17, Dirk Krautschick wrote:
> Hi,
> 
> I have a situation here where a frequent
> 
> REFRESH MATERIALIZED VIEW CONCURRENTLY
> 
> is preventing autovacuum on some tables kind of running into a circle of 
> growing.

You will need to:

1) Show the original CREATE MATERIALIZED VIEW command.

2) Indicate if the blocked autovacuum is on the tables the view is 
pulling from or other tables.

3) Tell us the Postgres version and whether it is community version or a 
fork.

> 
> Why is this acutally blocking autovacuum and what is the best practice 
> to prevent
> this excelt just not refreshing the materialized view frequently? :-)
> 
> Cheers
> 
> Dirk


-- 
Adrian Klaver
adrian.klaver@aklaver.com



Re: REFRESH MATERIALIZED VIEW CONCURRENTLY is blocking autovacuum on table

От
Laurenz Albe
Дата:
On Mon, 2026-02-09 at 02:17 +0100, Dirk Krautschick wrote:
> I have a situation here where a frequent 
>
>  REFRESH MATERIALIZED VIEW CONCURRENTLY
>
> is preventing autovacuum on some tables kind of running into a circle of growing.

I'm not sure I understand you correctly.

REFRESH MATERIALIZED VIEW CONCURRENTLY will block VACUUM on the materialized
view, because the statements take conflicting locks.

But the statement won't block VACUUM on the underlying tables.
However, if REFRESH MATERIALIZED VIEW CONCURRENTLY is running for a long time,
you will have a long-running transaction, and VACUUM won't be able to clean
up tuples that became dead later.

> Why is this acutally blocking autovacuum and what is the best practice to prevent 
> this excelt just not refreshing the materialized view frequently? :-)

I also have trouble understanding that sentence.

Yours,
Laurenz Albe