Skip to content

Commit

Permalink
Add help message for IO Timings in parallel nodes
Browse files Browse the repository at this point in the history
The timings may be confusing because greater than global timing. In the
case of parallel aware nodes, we show a message in node detail, plan
stats and diagram tooltip.

Fixes #305
  • Loading branch information
pgiraud committed Oct 10, 2024
1 parent 26825f0 commit d55aaf2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/DiagramRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ViewOptionsKey,
} from "@/symbols"
import type { IPlan, Node, ViewOptions } from "@/interfaces"
import { HelpService } from "@/services/help-service"
import { EstimateDirection, BufferLocation, NodeProp, Metric } from "../enums"
import LevelDivider from "@/components/LevelDivider.vue"
import useNode from "@/node"
Expand Down Expand Up @@ -40,6 +41,9 @@ if (!selectNode) {
}
const highlightedNodeId = inject(HighlightedNodeIdKey)
const helpService = new HelpService()
const getHelpMessage = helpService.getHelpMessage
const viewOptions = inject(ViewOptionsKey) as ViewOptions
const {
buffersByLocationTooltip,
Expand Down Expand Up @@ -74,6 +78,13 @@ function getTooltipContent(node: Node): string {
break
case Metric.io:
content += ioTooltip.value
if (
node[NodeProp.WORKERS_PLANNED] ||
node[NodeProp.WORKERS_PLANNED_BY_GATHER]
) {
content += `<br><small>${getHelpMessage("io timings parallel")}</small>`
}
break
}
if (node[NodeProp.CTE_NAME]) {
Expand Down
12 changes: 12 additions & 0 deletions src/components/PlanNodeDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const activeTab = ref<string>("general")
const helpService = new HelpService()
const getNodeTypeDescription = helpService.getNodeTypeDescription
const getHelpMessage = helpService.getHelpMessage
const {
costClass,
Expand Down Expand Up @@ -336,6 +337,17 @@ watch(activeTab, () => {
<b>Read:&nbsp;</b>
{{ formattedProp("EXCLUSIVE_IO_READ_TIME") }}
<small>~{{ formattedProp("AVERAGE_IO_READ_TIME") }}</small>
<FontAwesomeIcon
:icon="faInfoCircle"
class="cursor-help d-inline-block text-secondary"
v-tippy="{
content: getHelpMessage('io timings parallel'),
}"
v-if="
node[NodeProp.WORKERS_PLANNED] ||
node[NodeProp.WORKERS_PLANNED_BY_GATHER]
"
></FontAwesomeIcon>
</span>
<br />
<span v-if="node[NodeProp.EXCLUSIVE_IO_WRITE_TIME]" class="ms-2">
Expand Down
17 changes: 17 additions & 0 deletions src/components/PlanStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ function averageIO(node: Node) {
}
return r.join(", ")
}
function hasParallelChildren(node: Node) {
return node.Plans.some(function iter(a) {
if (a[NodeProp.WORKERS_PLANNED] || a[NodeProp.WORKERS_PLANNED_BY_GATHER]) {
return true
}
return Array.isArray(a.Plans) && a.Plans.some(iter)
})
}
</script>

<template>
Expand Down Expand Up @@ -260,6 +269,14 @@ function averageIO(node: Node) {
"
>
IO: <span v-html="averageIO(rootNode)"></span>
<FontAwesomeIcon
:icon="faInfoCircle"
class="cursor-help d-inline-block text-secondary"
v-tippy="{
content: getHelpMessage('io timings parallel'),
}"
v-if="hasParallelChildren(rootNode)"
></FontAwesomeIcon>
</div>
</div>
</template>
1 change: 1 addition & 0 deletions src/services/help-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Consider modifying max_parallel_workers or max_parallel_workers_per_gather.`,
"WORKERS DETAILED INFO MISSING": `Consider using EXPLAIN (ANALYZE, VERBOSE)`,
"FUZZY NEEDS VERBOSE": `Information may not be accurate. Use EXPLAIN VERBOSE mode.`,
"HINT TRACK_IO_TIMING": `HINT: activate <em><b>track_io_timing</b></em> to have details on time spent outside the PG cache.`,
"IO TIMINGS PARALLEL": "Distributed among parallel workers",
}

interface EaseInOutQuadOptions {
Expand Down

0 comments on commit d55aaf2

Please sign in to comment.