Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query).

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: in BeginCopyTo make materialized view using COPY TO instead of COPY (query).
Date: 2024-12-20 02:53:06
Message-ID: CACJufxGvy6QNMwZ5xd=L31F+4Rr6aXCASeMFyLZS+TVssK5+vA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Dec 20, 2024 at 8:02 AM Michael Paquier <michael(at)paquier(dot)xyz> 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.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2024-12-20 04:23:35 Eliminating SPI / SQL from some RI triggers - take 3
Previous Message Richard Guo 2024-12-20 02:35:58 Re: Can rs_cindex be < 0 for bitmap heap scans?