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 1tOT9B-006VEx-Ht for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2024 02:53:49 +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 1tOT99-0042tu-LC for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Dec 2024 02:53:47 +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 1tOT99-0042tm-BZ for pgsql-hackers@lists.postgresql.org; Fri, 20 Dec 2024 02:53:47 +0000 Received: from mail-vk1-xa2e.google.com ([2607:f8b0:4864:20::a2e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tOT96-000Tzm-8a for pgsql-hackers@lists.postgresql.org; Fri, 20 Dec 2024 02:53:45 +0000 Received: by mail-vk1-xa2e.google.com with SMTP id 71dfb90a1353d-5188311e61cso480747e0c.2 for ; Thu, 19 Dec 2024 18:53:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734663223; x=1735268023; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QR1Q1Roh5ZmDRormqwk2ONHeI9ZzlpYlwjQv8ZaE2ek=; b=ZR/RZyRhGbmlK8utKFYT5XNsPq6ZJ2seD7wz76UcCNV5NVALSteflSjVHtWksnj56w oVqDrycuDLHDiccIMWuXTE3gS2lZbYLj6BBGS2qgsUrMDBoc1+p6QWsXIzgQz5SkvE/I IIFlvb+dk0JI2P2LQ88fllGVZewuMi3WitbdpsT9C+GqEShVDSO4/6KIeNum17YvWmql 205tMtHcdaZGL6NsypbbUxl8XMTvOh/5AXHfX4VS75sBeAXggCKlVjDDSDjSKZ5kwGoG w5bLFr47KTWtB5E8qMke6UWEGo5qCEa5A7i2ycYqskcNA3Rtsw0u6o3Ripxvn2cNnW2c 7seA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734663223; x=1735268023; h=content-transfer-encoding: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=QR1Q1Roh5ZmDRormqwk2ONHeI9ZzlpYlwjQv8ZaE2ek=; b=aMwLtcaRkCwwa19azbAqEP5AxwW12sZvdstRNDdU2r0bDKM/iO/1QkyaDx2e+jzSOu usghCiQ/zwtM3PxqZ4IvO2AD5Wc9/CcVM+Ay7jgAdNFDrdLRgaPgs7oHvyOHOo0T3MJd +mZqCQKhcGchaKnajYI7jDlBicqNZFdBF2ImxmwRD7jqXI7CzbcVFtC7mO4aTN2et1X0 jLsvly5BYgNdfE4HjwR6KI5ll3JVZ/NJ/2pTlPpHTL/Ih9/vp3+NL0wceYTz9ttmbLxL lkypLZv4plLIMqMThvlH0LM1wOxYDCKOBzEl0BRnO2nB7pfdgEipRz2uYoR4iebi5MWE bJKw== X-Gm-Message-State: AOJu0YyYG6nu7KHJ7gRHXMQHq9B/iqPnOGlliorcXqruGUtLNmDd4/rF 38gkselxWZIjCHA7A8kuRkm/5mPaPXPH7u8qtJEsW4ICnzzhoZONw078xDUmPkSP+kdSXS8aZZr hhct7A6LIIFcOzJGP/FJHERSTZUFxuh1p X-Gm-Gg: ASbGnct6LMyPreYqyimPuKZXXQeNBFrYbWZIa4i+Aii3jdXgKf0Bv8gZZ51ZFLLATNu 2UfGVBTG7frsZK6l3GMjqWricmVyjeLoFBYmdy1s= X-Google-Smtp-Source: AGHT+IHIiuDO4TUd3SWhXFmP9/QhC0m579b15/9Ey8J1M5jimWZ4JsoShp2DB8nLOlOUApW3EtzHT/0zMWcqZq+NzIk= X-Received: by 2002:a05:6102:b12:b0:4b2:48cc:5c5a with SMTP id ada2fe7eead31-4b2cc399b84mr1655025137.15.1734663223238; Thu, 19 Dec 2024 18:53:43 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: jian he Date: Fri, 20 Dec 2024 10:53:06 +0800 Message-ID: Subject: Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query). To: Michael Paquier Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Dec 20, 2024 at 8:02=E2=80=AFAM Michael Paquier wrote: > > On Thu, Dec 19, 2024 at 02:28:21PM +0800, jian he wrote: > > Since materialized views have physical storage, > > > > we can make materialized views also using COPY table_name, instead of > > COPY(query). > > > > Some simple tests show around %3.7 or 4.3% speed up. > > This restriction comes from 3bf3ab8c5636 as such relations may not be > scannable when they have no data, no? Perhaps this restriction could > be lifted, but I'd suggest to dig more into the lists, there should be > arguments and ideas explaining what could be done in this case > (spoiler: I did not look at that). > -- Thanks for the suggestion. it was mentioned in link [1] and [2]. [1] https://www.postgresql.org/message-id/flat/8967.1353167301%40sss.pgh.pa= .us#f5e947cfa9357dba780d238f1c5f6932 [2] https://www.postgresql.org/message-id/20121116162558.90150%40gmx.com Basically we want to have the two directions of COPY. so copy the_materialized_view to stdout; copy the_materialized_view from stdin; both will work fine. obviously "copy the_materialized_view from stdin; " will not work.