Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVyRP-00029W-6p for pgsql-general@arkaria.postgresql.org; Fri, 23 Oct 2020 14:53:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVyRO-0001SJ-5r for pgsql-general@arkaria.postgresql.org; Fri, 23 Oct 2020 14:53:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVyRN-0001SB-RD for pgsql-general@lists.postgresql.org; Fri, 23 Oct 2020 14:53:13 +0000 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kVyRL-00071i-LU for pgsql-general@lists.postgresql.org; Fri, 23 Oct 2020 14:53:13 +0000 Received: by mail-qv1-xf34.google.com with SMTP id b11so799484qvr.9 for ; Fri, 23 Oct 2020 07:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=americanefficient-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=0EzOUiX5qnOavRYHB7l0U7R1cwqXrxPTC4RD75G0PhU=; b=mZqOQUdpgX+BKo8lqEYK0HQvS6X0OIOfb1aJN0cHuGty6UnKzx1yI8lcwUxIfKdDWf 0tt2e8uGgh6XECKZ36iHWqEo0V8kzODJv6xvZaWkhsGNDBbLvIwc4u3OryERiGiJMjHZ R5HdzcvcbJZdMCDF98SYFFdVyRtun95+l20J3XAGjWt3/Km29n5NB9Yf7sVlpo6JslY9 ph3+DGu4Wz5n/sJhGvx7z+mkAUonkFeJbCYkDFTWv8OJhtNNleTdBqix4vHcmx9eyGmN 258tgrtxbmTcSjMNa0L2mBr8XmsqVwKEJ/jctya+O5nIdgvlgADpdQadFBIs4M9uml15 yByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=0EzOUiX5qnOavRYHB7l0U7R1cwqXrxPTC4RD75G0PhU=; b=dygqX2+MJ5ebbawzrAlFvCh4/Nx8ctajt02y3D/QCm00m4HKHrv5F59KFlxizJeYOo 82kNNpqfkBkVW0QRUvhvt8jD89b1i9Pu77tDevGQtF8kljv5wNtqBwxRJRAZAeMVu+tF xhywv9SIM5qNhBUSxP8OfNo32q17A4dQojSFF5KHqfYIan7VqPpPemxfqHBcqtoOGaaT NiIVP/EzdLhjM/un/waRojszSgQG44GO8xqfAW/+UM3vi9hUvTRQr7jbS1U76EV09rqJ 8O3FyoiHHhcbZTclTb2gE8pvnhBVKaGrEsGkXY4OLN8GRNn7NRm3qjbB9e6oUFszuBp5 88fQ== X-Gm-Message-State: AOAM530aLFKRXQYvI+9tiuqthTMxSEU6yXvHuKNjEYOasaSIPe/xEFSW qe3IPEH9DDzez8KiWZY/stCkdA== X-Google-Smtp-Source: ABdhPJxAh1rkJQO9rdCzTMNAKcBkftruJ3nSKMaGxxRrzJohfBOMdpHIbDSEBPR7JG8YQV64oGQhPg== X-Received: by 2002:ad4:4105:: with SMTP id i5mr2657496qvp.47.1603464789976; Fri, 23 Oct 2020 07:53:09 -0700 (PDT) Received: from [10.0.1.7] (user-10lff1p.cable.mindspring.com. [65.87.188.57]) by smtp.gmail.com with ESMTPSA id g2sm1012089qts.8.2020.10.23.07.53.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Oct 2020 07:53:09 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: postgres materialized view refresh performance From: Philip Semanchuk In-Reply-To: Date: Fri, 23 Oct 2020 10:53:07 -0400 Cc: Ayub M , PostgreSQL General Content-Transfer-Encoding: quoted-printable Message-Id: References: <2626DFA9-3446-49D7-A8D7-31EC4863E7D7@americanefficient.com> To: Ravi Krishna X-Mailer: Apple Mail (2.3608.120.23.2.4) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Oct 23, 2020, at 9:52 AM, Ravi Krishna = wrote: >=20 >> My understanding is that when CONCURRENTLY is specified, Postgres = implements the refresh as a series of INSERT, UPDATE, >> and DELETE statements on the existing view. So the answer to your = question is no, Postgres doesn=E2=80=99t create another table and >> then swap it. >=20 > The INSERTS/UPDATE/DELETE happens only for the difference. PG first = creates a new temp table and then compares it with > the MV and detects the difference. That is why for CONCURRENTLY, a = unique index is required on the MV. Yes, thank you, that=E2=80=99s what I understand too but I expressed it = very poorly.=20