fix_explain_parallel.patch

text/x-patch

Filename: fix_explain_parallel.patch
Type: text/x-patch
Part: 0
Message: Re: [PATCH] Incremental sort (was: PoC: Partial sort)

Patch

Format: unified
File+
src/backend/commands/explain.c 11 8
src/test/regress/sql/incremental_sort.sql 2 0
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 62c86ecdc5..c31f3e0987 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -2880,19 +2880,22 @@ show_incremental_sort_info(IncrementalSortState *incrsortstate,
 
 	fullsortGroupInfo = &incrsortstate->incsort_info.fullsortGroupInfo;
 
-	if (!(es->analyze && fullsortGroupInfo->groupCount > 0))
+	if (!es->analyze)
 		return;
 
-	show_incremental_sort_group_info(fullsortGroupInfo, "Full-sort", true, es);
-	prefixsortGroupInfo = &incrsortstate->incsort_info.prefixsortGroupInfo;
-	if (prefixsortGroupInfo->groupCount > 0)
+	if (fullsortGroupInfo->groupCount > 0)
 	{
+		show_incremental_sort_group_info(fullsortGroupInfo, "Full-sort", true, es);
+		prefixsortGroupInfo = &incrsortstate->incsort_info.prefixsortGroupInfo;
+		if (prefixsortGroupInfo->groupCount > 0)
+		{
+			if (es->format == EXPLAIN_FORMAT_TEXT)
+				appendStringInfo(es->str, " ");
+			show_incremental_sort_group_info(prefixsortGroupInfo, "Presorted", false, es);
+		}
 		if (es->format == EXPLAIN_FORMAT_TEXT)
-			appendStringInfo(es->str, " ");
-		show_incremental_sort_group_info(prefixsortGroupInfo, "Presorted", false, es);
+			appendStringInfo(es->str, "\n");
 	}
-	if (es->format == EXPLAIN_FORMAT_TEXT)
-		appendStringInfo(es->str, "\n");
 
 	if (incrsortstate->shared_info != NULL)
 	{
diff --git a/src/test/regress/sql/incremental_sort.sql b/src/test/regress/sql/incremental_sort.sql
index 3b359efa29..c46443358a 100644
--- a/src/test/regress/sql/incremental_sort.sql
+++ b/src/test/regress/sql/incremental_sort.sql
@@ -1,3 +1,5 @@
+set force_parallel_mode = regress;
+
 -- When we have to sort the entire table, incremental sort will
 -- be slower than plain sort, so it should not be used.
 explain (costs off)