From bae8a2bd5d92088ff19faf1ef498ca0f21cf90f0 Mon Sep 17 00:00:00 2001 From: Nikhil Mohite Date: Fri, 24 Dec 2021 16:11:58 +0530 Subject: [PATCH] Fixed an issue where Explain Analyze shows negative exclusive time. Fixes #7003 --- docs/en_US/release_notes_6_4.rst | 1 + web/pgadmin/misc/static/explain/js/explain.js | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/en_US/release_notes_6_4.rst b/docs/en_US/release_notes_6_4.rst index fe49022de..cca7a3f88 100644 --- a/docs/en_US/release_notes_6_4.rst +++ b/docs/en_US/release_notes_6_4.rst @@ -18,5 +18,6 @@ Bug fixes ********* | `Issue #6745 `_ - Fixed an issue where Tablespace is created though an error is shown on the dialog. +| `Issue #7003 `_ - Fixed an issue where Explain Analyze shows negative exclusive time. | `Issue #7034 `_ - Fixed an issue where Columns with default value not showing when adding a new row. | `Issue #7077 `_ - Fixed an issue where the Owner is not displayed in the reverse engineering SQL for Procedures. diff --git a/web/pgadmin/misc/static/explain/js/explain.js b/web/pgadmin/misc/static/explain/js/explain.js index d97fec9d3..4b49387ab 100644 --- a/web/pgadmin/misc/static/explain/js/explain.js +++ b/web/pgadmin/misc/static/explain/js/explain.js @@ -660,7 +660,7 @@ define('pgadmin.misc.explain', [ if ('Actual Total Time' in data && 'Actual Loops' in data) { data['inclusive'] = Math.ceil10( - data['Actual Total Time'] * data['Actual Loops'], -3 + data['Actual Total Time'], -3 ); data['exclusive'] = data['inclusive']; data['inclusive_factor'] = data['inclusive'] / ( @@ -687,7 +687,11 @@ define('pgadmin.misc.explain', [ data['rowsx_flag'] = data['rowsx'] <= 10 ? '1' : ( data['rowsx'] <= 100 ? '2' : (data['rowsx'] <= 1000 ? '3' : '4') ); - data['rowsx'] = Math.ceil10(data['rowsx'], -2); + if('loops' in data) { + data['rowsx'] = Math.ceil10(data['rowsx'] / data['loops'] || 1, -2); + } else { + data['rowsx'] = Math.ceil10(data['rowsx'], -2); + } } // Start calculating xpos, ypos, width and height for child plans if any @@ -709,6 +713,7 @@ define('pgadmin.misc.explain', [ ypos: ypos, total_time: data['total_time'] || data['Actual Total Time'], parent_node: lvl.join('_'), + loops: data['Actual Loops'] }), _opt)); if (maxChildWidth < plan.get('width')) { @@ -717,7 +722,7 @@ define('pgadmin.misc.explain', [ if ('exclusive' in data) { inclusive = plan.get('inclusive'); - if (inclusive) { + if (inclusive && inclusive < data['exclusive']) { data['exclusive'] -= inclusive; } } @@ -734,6 +739,11 @@ define('pgadmin.misc.explain', [ plans.push(plan); idx++; }); + } else{ + if('loops' in data && 'exclusive' in data) { + data['inclusive'] = Math.ceil10(data['Actual Total Time'] / data['loops'] || 1, -3); + data['exclusive'] = data['inclusive']; + } } if ('exclusive' in data) { @@ -1104,6 +1114,7 @@ define('pgadmin.misc.explain', [ data['Plan'], { xpos: 0, ypos: 0, + loops: 1 }), _opt ));