From a94f1503abd720ab25c7f0e536f8158ffed3085c Mon Sep 17 00:00:00 2001
From: Paul Guo <paulguo@gmail.com>
Date: Wed, 27 Jan 2021 13:06:16 +0800
Subject: [PATCH v1] Freeze the tuples during CTAS.

Actually this is the behavior in materialized view code also. With this
unncessary vacuum could be avoided.
---
 src/backend/commands/createas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
 
 	/*
 	 * If WITH NO DATA is specified, there is no need to set up the state for
-- 
2.14.3

