@@ -375,7 +375,7 @@ pub fn describe_explain_analyze(
375
375
376
376
if skew {
377
377
relation_desc =
378
- relation_desc. with_column ( "worker_id" , ScalarType :: UInt64 . nullable ( false ) ) ;
378
+ relation_desc. with_column ( "worker_id" , ScalarType :: UInt64 . nullable ( true ) ) ;
379
379
}
380
380
381
381
let mut seen_properties = BTreeSet :: new ( ) ;
@@ -843,8 +843,8 @@ pub fn plan_explain_analyze(
843
843
SELECT mlm.lir_id AS lir_id,
844
844
SUM(mas.size) AS total_memory,
845
845
SUM(mas.records) AS total_records,
846
- SUM(mas.size) / COUNT(DISTINCT mas.worker_id) AS avg_memory,
847
- SUM(mas.records) / COUNT(DISTINCT mas.worker_id) AS avg_records
846
+ CASE WHEN COUNT(DISTINCT mas.worker_id) <> 0 THEN SUM(mas.size) / COUNT(DISTINCT mas.worker_id) ELSE NULL END AS avg_memory,
847
+ CASE WHEN COUNT(DISTINCT mas.worker_id) <> 0 THEN SUM(mas.records) / COUNT(DISTINCT mas.worker_id) ELSE NULL END AS avg_records
848
848
FROM mz_introspection.mz_lir_mapping mlm
849
849
LEFT JOIN mz_introspection.mz_arrangement_sizes_per_worker mas
850
850
ON ( mlm.operator_id_start <= mas.operator_id
@@ -878,11 +878,11 @@ GROUP BY mlm.lir_id, mas.worker_id"#,
878
878
}
879
879
880
880
columns. extend ( [
881
- "ROUND(pwm.worker_memory / sm.avg_memory, 2) AS memory_ratio" ,
881
+ "CASE WHEN pwm.worker_id IS NOT NULL AND sm.avg_memory <> 0 THEN ROUND(pwm.worker_memory / sm.avg_memory, 2) ELSE NULL END AS memory_ratio" ,
882
882
"pg_size_pretty(pwm.worker_memory) AS worker_memory" ,
883
883
"pg_size_pretty(sm.avg_memory) AS avg_memory" ,
884
884
"pg_size_pretty(sm.total_memory) AS total_memory" ,
885
- "ROUND(pwm.worker_records / sm.avg_records, 2) AS records_ratio" ,
885
+ "CASE WHEN pwm.worker_id IS NOT NULL AND sm.avg_records <> 0 THEN ROUND(pwm.worker_records / sm.avg_records, 2) ELSE NULL END AS records_ratio" ,
886
886
"pwm.worker_records AS worker_records" ,
887
887
"sm.avg_records AS avg_records" ,
888
888
"sm.total_records AS total_records" ,
@@ -900,7 +900,7 @@ GROUP BY mlm.lir_id, mas.worker_id"#,
900
900
r#"
901
901
SELECT mlm.lir_id AS lir_id,
902
902
SUM(mse.elapsed_ns) AS total_ns,
903
- SUM(mse.elapsed_ns) / COUNT(DISTINCT mse.worker_id) AS avg_ns
903
+ CASE WHEN COUNT(DISTINCT mse.worker_id) <> 0 THEN SUM(mse.elapsed_ns) / COUNT(DISTINCT mse.worker_id) ELSE NULL END AS avg_ns
904
904
FROM mz_introspection.mz_lir_mapping mlm,
905
905
mz_introspection.mz_scheduling_elapsed_per_worker mse
906
906
WHERE mlm.operator_id_start <= mse.id AND mse.id < mlm.operator_id_end
@@ -931,7 +931,7 @@ GROUP BY mlm.lir_id, mse.worker_id"#,
931
931
}
932
932
933
933
columns. extend ( [
934
- "ROUND(pwc.worker_ns / sc.avg_ns, 2) AS cpu_ratio" ,
934
+ "CASE WHEN pwc.worker_id IS NOT NULL AND sc.avg_ns <> 0 THEN ROUND(pwc.worker_ns / sc.avg_ns, 2) ELSE NULL END AS cpu_ratio" ,
935
935
"pwc.worker_ns / 1000 * '1 microsecond'::INTERVAL AS worker_elapsed" ,
936
936
"sc.avg_ns / 1000 * '1 microsecond'::INTERVAL AS avg_elapsed" ,
937
937
] ) ;
0 commit comments