ExplainOpenGroup("Sort Space", memoryName.data, true, es);
ExplainPropertyInteger("Average Sort Space Used", "kB", avgSpace, es);
- ExplainPropertyInteger("Maximum Sort Space Used", "kB",
+ ExplainPropertyInteger("Peak Sort Space Used", "kB",
groupInfo->maxMemorySpaceUsed, es);
ExplainCloseGroup("Sort Spaces", memoryName.data, true, es);
ExplainOpenGroup("Sort Space", diskName.data, true, es);
ExplainPropertyInteger("Average Sort Space Used", "kB", avgSpace, es);
- ExplainPropertyInteger("Maximum Sort Space Used", "kB",
+ ExplainPropertyInteger("Peak Sort Space Used", "kB",
groupInfo->maxDiskSpaceUsed, es);
ExplainCloseGroup("Sort Spaces", diskName.data, true, es);
if (!es->analyze)
return;
+ /*
+ * Since we never have any prefix groups unless we've first sorted a full
+ * groups and transitioned modes (copying the tuples into a prefix group),
+ * we don't need to do anything if there were 0 full groups.
+ *
+ * We still have to continue after this block if there are no full groups,
+ * though, since it's possible that we have workers that did real work even
+ * if the leader didn't participate.
+ */
if (fullsortGroupInfo->groupCount > 0)
{
show_incremental_sort_group_info(fullsortGroupInfo, "Full-sort", true, es);
*/
fullsortGroupInfo = &incsort_info->fullsortGroupInfo;
prefixsortGroupInfo = &incsort_info->prefixsortGroupInfo;
+
+ /*
+ * Since we never have any prefix groups unless we've first sorted
+ * a full groups and transitioned modes (copying the tuples into a
+ * prefix group), we don't need to do anything if there were 0 full
+ * groups.
+ */
if (fullsortGroupInfo->groupCount == 0 &&
prefixsortGroupInfo->groupCount == 0)
continue;
for group_key in select unnest(array['Full-sort Groups', 'Presorted Groups']::text[]) t loop
for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop
node := jsonb_set(node, array[group_key, space_key, 'Average Sort Space Used'], '"NN"', false);
- node := jsonb_set(node, array[group_key, space_key, 'Maximum Sort Space Used'], '"NN"', false);
+ node := jsonb_set(node, array[group_key, space_key, 'Peak Sort Space Used'], '"NN"', false);
end loop;
end loop;
nodes := nodes || node;
for group_key in select unnest(array['Full-sort Groups', 'Presorted Groups']::text[]) t loop
group_stats := node->group_key;
for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop
- if (group_stats->space_key->'Maximum Sort Space Used')::bigint < (group_stats->space_key->'Maximum Sort Space Used')::bigint then
+ if (group_stats->space_key->'Peak Sort Space Used')::bigint < (group_stats->space_key->'Peak Sort Space Used')::bigint then
raise exception '% has invalid max space < average space', group_key;
end if;
end loop;
(9 rows)
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 55'));
- jsonb_pretty
---------------------------------------------------
- [ +
- { +
- "Sort Key": [ +
- "t.a", +
- "t.b" +
- ], +
- "Node Type": "Incremental Sort", +
- "Actual Rows": 55, +
- "Actual Loops": 1, +
- "Presorted Key": [ +
- "t.a" +
- ], +
- "Parallel Aware": false, +
- "Full-sort Groups": { +
- "Group Count": 2, +
- "Sort Methods Used": [ +
- "top-N heapsort", +
- "quicksort" +
- ], +
- "Sort Space Memory": { +
- "Average Sort Space Used": "NN",+
- "Maximum Sort Space Used": "NN" +
- } +
- }, +
- "Parent Relationship": "Outer" +
- } +
+ jsonb_pretty
+-------------------------------------------------
+ [ +
+ { +
+ "Sort Key": [ +
+ "t.a", +
+ "t.b" +
+ ], +
+ "Node Type": "Incremental Sort", +
+ "Actual Rows": 55, +
+ "Actual Loops": 1, +
+ "Presorted Key": [ +
+ "t.a" +
+ ], +
+ "Parallel Aware": false, +
+ "Full-sort Groups": { +
+ "Group Count": 2, +
+ "Sort Methods Used": [ +
+ "top-N heapsort", +
+ "quicksort" +
+ ], +
+ "Sort Space Memory": { +
+ "Peak Sort Space Used": "NN", +
+ "Average Sort Space Used": "NN"+
+ } +
+ }, +
+ "Parent Relationship": "Outer" +
+ } +
]
(1 row)
(9 rows)
select jsonb_pretty(explain_analyze_inc_sort_nodes_without_memory('select * from (select * from t order by a) s order by a, b limit 70'));
- jsonb_pretty
---------------------------------------------------
- [ +
- { +
- "Sort Key": [ +
- "t.a", +
- "t.b" +
- ], +
- "Node Type": "Incremental Sort", +
- "Actual Rows": 70, +
- "Actual Loops": 1, +
- "Presorted Key": [ +
- "t.a" +
- ], +
- "Parallel Aware": false, +
- "Full-sort Groups": { +
- "Group Count": 1, +
- "Sort Methods Used": [ +
- "quicksort" +
- ], +
- "Sort Space Memory": { +
- "Average Sort Space Used": "NN",+
- "Maximum Sort Space Used": "NN" +
- } +
- }, +
- "Presorted Groups": { +
- "Group Count": 5, +
- "Sort Methods Used": [ +
- "quicksort" +
- ], +
- "Sort Space Memory": { +
- "Average Sort Space Used": "NN",+
- "Maximum Sort Space Used": "NN" +
- } +
- }, +
- "Parent Relationship": "Outer" +
- } +
+ jsonb_pretty
+-------------------------------------------------
+ [ +
+ { +
+ "Sort Key": [ +
+ "t.a", +
+ "t.b" +
+ ], +
+ "Node Type": "Incremental Sort", +
+ "Actual Rows": 70, +
+ "Actual Loops": 1, +
+ "Presorted Key": [ +
+ "t.a" +
+ ], +
+ "Parallel Aware": false, +
+ "Full-sort Groups": { +
+ "Group Count": 1, +
+ "Sort Methods Used": [ +
+ "quicksort" +
+ ], +
+ "Sort Space Memory": { +
+ "Peak Sort Space Used": "NN", +
+ "Average Sort Space Used": "NN"+
+ } +
+ }, +
+ "Presorted Groups": { +
+ "Group Count": 5, +
+ "Sort Methods Used": [ +
+ "quicksort" +
+ ], +
+ "Sort Space Memory": { +
+ "Peak Sort Space Used": "NN", +
+ "Average Sort Space Used": "NN"+
+ } +
+ }, +
+ "Parent Relationship": "Outer" +
+ } +
]
(1 row)
for group_key in select unnest(array['Full-sort Groups', 'Presorted Groups']::text[]) t loop
for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop
node := jsonb_set(node, array[group_key, space_key, 'Average Sort Space Used'], '"NN"', false);
- node := jsonb_set(node, array[group_key, space_key, 'Maximum Sort Space Used'], '"NN"', false);
+ node := jsonb_set(node, array[group_key, space_key, 'Peak Sort Space Used'], '"NN"', false);
end loop;
end loop;
nodes := nodes || node;
for group_key in select unnest(array['Full-sort Groups', 'Presorted Groups']::text[]) t loop
group_stats := node->group_key;
for space_key in select unnest(array['Sort Space Memory', 'Sort Space Disk']::text[]) t loop
- if (group_stats->space_key->'Maximum Sort Space Used')::bigint < (group_stats->space_key->'Maximum Sort Space Used')::bigint then
+ if (group_stats->space_key->'Peak Sort Space Used')::bigint < (group_stats->space_key->'Peak Sort Space Used')::bigint then
raise exception '% has invalid max space < average space', group_key;
end if;
end loop;