Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmDno-0053Z7-Qp for pgsql-general@arkaria.postgresql.org; Sun, 23 Feb 2025 15:21:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tmDnm-00B0Sv-Bz for pgsql-general@arkaria.postgresql.org; Sun, 23 Feb 2025 15:21:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmDnl-00B0Sn-Up for pgsql-general@lists.postgresql.org; Sun, 23 Feb 2025 15:21:53 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tmDni-000JkC-2i for pgsql-general@lists.postgresql.org; Sun, 23 Feb 2025 15:21:53 +0000 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3cf82bd380bso33941225ab.0 for ; Sun, 23 Feb 2025 07:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740324111; x=1740928911; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hmgQHmmyTcRphXW3YGgNLJ9okJMP6kinlK0/m4pftuI=; b=aE1uMShtC3FQyQsMc2dk358sDTwCclgCQPVuKL1N4VLINmvbjrXcxg77Rpj70Qp0bB UhPs0hGOdR2YltzWRRGSIn6ZrcYGHkisw4i/XLp7bUGL6NM9um6v3qUj6nh4hNdF8xWr hKJO3D9enq5svmUsidzMYSbC1X1OfSJzQ2tZhlZEr0vT9CP0I1Wp8WfPHI7q7Rsdj6i6 K4GY/41Lf1gcTkiieIaF0QGgD1vfj3Fv4+cVMtA2c/uKV12ChB2M+UiN6oqVTO4Xw8v4 hbHVXEvgby05rUoqXsaXyW8Nr4FkpJ+OFA3ledKfnOwjiztUd49b3iOvuLoouNIw3UB6 eN5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740324111; x=1740928911; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hmgQHmmyTcRphXW3YGgNLJ9okJMP6kinlK0/m4pftuI=; b=cvC0XmGMq2qlpZwTGLUDxELkRa2Ggvut2t+4eKfav44WJvLZ5nba0koOHymGFP9Tmk CG05RP9oQTX4ZFuTTwRr6gYqQ0hFVVy24y38dgdstK9I6u25q9Ig46huyI2JFH42v5tp aOAclTrPTaMqbS8bLHHTzosMlaPIRHDqnXI91GZaw1vkDG4LyE1p/ZfeOPDG37HkshCv V5gcarLEvsfeW0Bn90ITVuxacsO8QljYHhs6PZzbwapxL/5Von5YRr3eNvwuOF0Q9X0Q 7BNZ6M2BvIXbw+sJJgvDaHaaSPv/qs3FeY8xllGkZ9aDzt5EQWn3K1Pff0BUEY3YnCm8 RQ2w== X-Gm-Message-State: AOJu0YwWq4nT/nSP784p4BtbKIpY8QZSj2wvdesSMpIc5v20APq5d5MG +MNISXX+CV35Ic/x9KNFQNZBDfSobM3F/uZbAUZSempbadbkV/2hSNb71GxjxoE8Pq+b0Y+B37I XpsZsJUxVwXY8wNZ4x7CXy9DXNHY= X-Gm-Gg: ASbGnctgaoijA7GHPA/T2DJW/0og2AY1mODmNSk9vlnGnYwRvAIzdk8V+uEMdaUmnVH +kzgb9/2V16Og7QW4MGc/1y7IvbuKiCVrDGx0YtANikMQFNuoWB3FYnGh/bmVnBOVuQjMk3DT3w xICi6CA+qwXOnSxnwV03UEdv6nnl5l77ltYRuuF/W0 X-Google-Smtp-Source: AGHT+IFGJ2e0WRaHoTy6mw6C55wIY09RcmHr2Ad2ly1ro/f502P3hHBGVIS6Ze995uwe4Fcd9dQ/2UwLqqhUA9eKrjI= X-Received: by 2002:a05:6e02:214e:b0:3cf:bb3e:884c with SMTP id e9e14a558f8ab-3d2cb51e0b9mr83020275ab.16.1740324110710; Sun, 23 Feb 2025 07:21:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Sun, 23 Feb 2025 10:21:14 -0500 X-Gm-Features: AWEUYZlKLf8syLfsTJEvRKdgK_PvRwC16yS9F95P5dL1CZ9S3TQaf5RIyYZ8Oog Message-ID: Subject: Re: documentation question regarding REFRESH MATERIALIZED VIEW CONCURRENTLY To: Tobias McNulty Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000069c4b6062ed0c82f" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000069c4b6062ed0c82f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Feb 22, 2025 at 8:58=E2=80=AFPM Tobias McNulty wrote: > "Without this option a refresh which affects a lot of rows will tend to > use fewer resources" ... > either that (1) the refresh operation actually updates the contents of a > lot of rows in the materialized view This is the correct interpretation. A regular refresh simply runs the query and replaces the old view, regardless of the number of rows that have changed. A concurrent refresh runs the query and updates the rows in place, so it is very sensitive as to how many of those rows have changed. This also means that many concurrent refreshes can lead to table bloat. And it will generate more WAL than a regular refresh. My takeaway: use regular refresh when you can. Switch to concurrent if the number of changes is very small, or if constant client access to the view is very important. --=20 Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support --00000000000069c4b6062ed0c82f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, Feb 22, 2025 at 8:58=E2=80=AFPM T= obias McNulty <tobias@caktusgr= oup.com> wrote:
"Without this opti= on a refresh which affects a lot of rows will tend to use fewer resources&q= uot;
...=C2=A0
either that (1) the refresh operation actually updates the cont= ents of a lot of rows in the materialized view

<= div>This is the correct interpretation. A regular refresh simply runs the q= uery and replaces the old view, regardless of the number of rows that have = changed. A concurrent refresh runs the query and updates the rows in place,= so it is very sensitive as to how many of those rows have changed. This al= so means that many concurrent refreshes can lead to table bloat. And it wil= l generate more WAL than a regular refresh.

My tak= eaway: use regular refresh when you can. Switch to concurrent if the number= of changes is very small, or if constant client access to the view is very= important.

--
Cheers,
Greg

--
Enterprise Postgres Software Products &= Tech Support

--00000000000069c4b6062ed0c82f--