Re: why generated columsn cannot be used in COPY TO?

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: why generated columsn cannot be used in COPY TO?
Date: 2023-10-06 15:06:43
Message-ID: CAFCRh-86krUaoSJdnR0Gf5mDuXq=pAGkv1vdXHAoxpPHd5hFaQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 6, 2023 at 4:59 PM Rob Sargent <robjsargent(at)gmail(dot)com> wrote:

> What would be copied? The formula?

Of course not. That's DDL, not DML IMHO.

> Seems to me one is using “the fast option” so adding the column which can
> be regenerated is overhead.
>

Regenerated by whom? COPY TO to is output to the outside world.
Nothing says it will come back to PostgreSQL later. COPY is not only for
backups.
I use COPY to "stream" rows out for processing, combines the best of SELECT
and the incremental nature of CURSOR, for the best latency and throughput.

All that said, that's a work-around like Andreas showed.
I agree with Tom that ignoring them in the default list makes sense,
but that if explicitly asked for, they should be copied out. My $0.02.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2023-10-06 15:45:58 Re: why generated columsn cannot be used in COPY TO?
Previous Message David G. Johnston 2023-10-06 15:03:48 Re: why generated columsn cannot be used in COPY TO?