Re: Freeze the inserted tuples during CTAS? - Mailing list pgsql-hackers

From Paul Guo
Subject Re: Freeze the inserted tuples during CTAS?
Date
Msg-id B240EA11-CE4A-4850-82AE-26C32FB75295@vmware.com
Whole thread Raw
In response to Re: Freeze the inserted tuples during CTAS?  (Darafei "Komяpa" Praliaskouski <me@komzpa.net>)
List pgsql-hackers


On Jan 27, 2021, at 5:33 PM, Darafei Komяpa Praliaskouski <me@komzpa.net> wrote:

Hi,

I confirm that my analytic workflows often do the CTAS and VACUUM of the relation right after, before the index creation, to mark stuff as all-visible for IOS to work. Freezing and marking as visible will help.

Thanks for letting me know there is such a real case in production environment.
I attached the short patch. If no more other concerns, I will log the patch on commitfest.


-Paul


On Wed, Jan 27, 2021 at 12:29 PM Paul Guo <guopa@vmware.com> wrote:
Here is the simple patch,

diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index dce882012e..0391699423 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -552,7 +552,7 @@ intorel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
    myState->rel = intoRelationDesc;
    myState->reladdr = intoRelationAddr;
    myState->output_cid = GetCurrentCommandId(true);
-   myState->ti_options = TABLE_INSERT_SKIP_FSM;
+   myState->ti_options = TABLE_INSERT_SKIP_FSM | TABLE_INSERT_FROZEN;

MatView code already does this and COPY does this if specified. I’m not sure how
does the community think about this. Actually personally I expect more about the
all-visible setting due to TABLE_INSERT_FROZEN since I could easier use index only scan
if we create an index and table use CTAS, else people have to use index only scan
after vacuum. If people do not expect freeze could we at least introduce a option to
specify the visibility during inserting?

Regards,
Paul


Attachment

pgsql-hackers by date:

Previous
From: Zhihong Yu
Date:
Subject: Re: PoC Refactor AM analyse API
Next
From: Ajin Cherian
Date:
Subject: Re: repeated decoding of prepared transactions