RE: Consider Parallelism While Planning For REFRESH MATERIALIZED VIEW

Hou, Zhijie <houzj.fnst@cn.fujitsu.com>

From: "Hou, Zhijie" <houzj.fnst@cn.fujitsu.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2020-12-22T11:23:48Z
Lists: pgsql-hackers
Hi

> Added this to commitfest, in case it is useful -
> https://commitfest.postgresql.org/31/2856/

I have an issue about the safety of enable parallel select.

I checked the [parallel insert into select] patch.
https://commitfest.postgresql.org/31/2844/
It seems parallel select is not allowed when target table is temporary table.

+	/*
+	 * We can't support table modification in parallel-mode if it's a foreign
+	 * table/partition (no FDW API for supporting parallel access) or a
+	 * temporary table.
+	 */
+	if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE ||
+		RelationUsesLocalBuffers(rel))
+	{
+		table_close(rel, lockmode);
+		context->max_hazard = PROPARALLEL_UNSAFE;
+		return context->max_hazard;
+	}

For Refresh MatView.
if CONCURRENTLY is specified, It will builds new data in temp tablespace:
	if (concurrent)
	{
		tableSpace = GetDefaultTablespace(RELPERSISTENCE_TEMP, false);
		relpersistence = RELPERSISTENCE_TEMP;
	}

For the above case, should we still consider parallelism ?

Best regards,
houzj



Commits

  1. Enable parallelism in REFRESH MATERIALIZED VIEW.

  2. Allow DML commands that create tables to use parallel query.