@@ -358,7 +358,7 @@ function printStats(stats, isCoord) {
358
358
359
359
stringBuilder . appendLine ( ' ' + pad ( 1 + maxWELen - String ( stats . writesExecuted ) . length ) + value ( stats . writesExecuted ) + spc +
360
360
pad ( 1 + maxWILen - String ( stats . writesIgnored ) . length ) + value ( stats . writesIgnored ) + spc +
361
- pad ( 1 + maxDLLen - String ( stats . documentLookups ) . length ) + value ( stats . documentLookups ) + spc +
361
+ pad ( 1 + maxDLLen - String ( ( stats . documentLookups || 0 ) ) . length ) + value ( stats . documentLookups || 0 ) + spc +
362
362
pad ( 1 + maxSFLen - String ( stats . scannedFull ) . length ) + value ( stats . scannedFull ) + spc +
363
363
pad ( 1 + maxSILen - String ( stats . scannedIndex ) . length ) + value ( stats . scannedIndex ) + spc +
364
364
pad ( 1 + maxCHMLen - ( String ( stats . cacheHits || 0 ) + ' / ' + String ( stats . cacheMisses || 0 ) ) . length ) + value ( stats . cacheHits || 0 ) + ' / ' + value ( stats . cacheMisses || 0 ) + spc +
@@ -876,31 +876,41 @@ function processQuery(query, explain, planIndex) {
876
876
} ;
877
877
recursiveWalk ( plan . nodes , 0 , 'COOR' ) ;
878
878
879
- if ( profileMode ) { // merge runtime info into plan
879
+ if ( profileMode ) {
880
+ // merge runtime info into plan.
881
+ // note that this is only necessary for server versions <= 3.11.
882
+ // the code can be removed when only supporting server versions
883
+ // >= 3.12.
884
+ stats . nodes . forEach ( n => {
885
+ nodes [ n . id ] . runtime = n . runtime ;
886
+ } ) ;
880
887
stats . nodes . forEach ( n => {
881
888
if ( nodes . hasOwnProperty ( n . id ) && ! n . hasOwnProperty ( 'fetching' ) ) {
882
889
// no separate fetching stats. that means the runtime is cumulative.
883
890
// by subtracting the dependencies from parent runtime we get the runtime per node
884
- nodes [ n . id ] . fetching = 0 ;
885
891
if ( parents . hasOwnProperty ( n . id ) ) {
886
892
parents [ n . id ] . forEach ( pid => {
887
- if ( typeof nodes [ pid ] . runtime === 'number' ) {
888
- nodes [ pid ] . runtime -= n . runtime ;
889
- nodes [ pid ] . fetching = 0 ;
890
- }
893
+ nodes [ pid ] . runtime -= n . runtime ;
891
894
} ) ;
892
895
}
893
896
}
894
897
} ) ;
895
898
896
899
stats . nodes . forEach ( n => {
897
900
if ( nodes . hasOwnProperty ( n . id ) ) {
898
- let runtime = n . runtime || 0 ;
901
+ let runtime = 0 ;
899
902
if ( n . hasOwnProperty ( 'fetching' ) ) {
903
+ // this branch is taken for servers >= 3.12.
904
+ runtime = n . runtime ;
900
905
// we have separate runtime (including fetching time)
901
906
// and fetching stats
902
907
runtime -= n . fetching ;
908
+ } else if ( nodes [ n . id ] . hasOwnProperty ( 'runtime' ) ) {
909
+ // this branch is taken for servers <= 3.11 and can be removed
910
+ // eventually.
911
+ runtime = nodes [ n . id ] . runtime ;
903
912
}
913
+
904
914
nodes [ n . id ] . calls = String ( n . calls || 0 ) ;
905
915
nodes [ n . id ] . parallel = ( nodes [ n . id ] . isAsyncPrefetchEnabled ? String ( n . parallel || 0 ) : '-' ) ;
906
916
nodes [ n . id ] . items = String ( n . items || 0 ) ;
0 commit comments