diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 1f7c732c02..0026442610 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -160,6 +160,7 @@ typedef struct AlteredTableInfo
 	List	   *newvals;		/* List of NewColumnValue */
 	bool		new_notnull;	/* T if we added new NOT NULL constraints */
 	int			rewrite;		/* Reason for forced rewrite, if any */
+	bool		check_toast;	/* check for toast table */
 	Oid			newTableSpace;	/* new tablespace; 0 means no change */
 	bool		chgPersistence; /* T if SET LOGGED/UNLOGGED is used */
 	char		newrelpersistence;		/* if above is true */
@@ -3445,8 +3446,7 @@ ATRewriteCatalogs(List **wqueue, LOCKMODE lockmode)
 	{
 		AlteredTableInfo *tab = (AlteredTableInfo *) lfirst(ltab);
 
-		if (tab->relkind == RELKIND_RELATION ||
-			tab->relkind == RELKIND_MATVIEW)
+		if (tab->check_toast)
 			AlterTableCreateToastTable(tab->relid, (Datum) 0, lockmode);
 	}
 }
@@ -4272,6 +4272,14 @@ ATGetQueueEntry(List **wqueue, Relation rel)
 	tab->newrelpersistence = RELPERSISTENCE_PERMANENT;
 	tab->chgPersistence = false;
 
+	/* We don't check for toast table of mapped relations */
+	if ((tab->relkind == RELKIND_MATVIEW ||
+		 tab->relkind == RELKIND_RELATION) &&
+		!RelationIsMapped(rel))
+		tab->check_toast = true;
+	else
+		tab->check_toast = false;
+
 	*wqueue = lappend(*wqueue, tab);
 
 	return tab;
