@@ -403,7 +403,8 @@ private void RenderStatement(PlanStatement statement)
403403 PlanCanvas . Height = height ;
404404
405405 // Render edges first (behind nodes)
406- RenderEdges ( statement . RootNode ) ;
406+ var divergenceLimit = Math . Max ( 2.0 , AppSettingsService . Load ( ) . AccuracyRatioDivergenceLimit ) ;
407+ RenderEdges ( statement . RootNode , divergenceLimit ) ;
407408
408409 // Render nodes — pass total warning count to root node for badge
409410 var allWarnings = new List < PlanWarning > ( ) ;
@@ -656,10 +657,11 @@ private Border CreateNodeVisual(PlanNode node, int totalWarningCount = -1)
656657 HorizontalAlignment = HorizontalAlignment . Center
657658 } ) ;
658659
659- // Actual rows of Estimated rows (accuracy %) -- red if off by 10x+
660+ // Actual rows of Estimated rows (accuracy %) -- red if off by divergence limit
660661 var estRows = node . EstimateRows ;
661662 var accuracyRatio = estRows > 0 ? node . ActualRows / estRows : ( node . ActualRows > 0 ? double . MaxValue : 1.0 ) ;
662- IBrush rowBrush = ( accuracyRatio < 0.1 || accuracyRatio > 10.0 ) ? OrangeRedBrush : fgBrush ;
663+ var nodeDivLimit = Math . Max ( 2.0 , AppSettingsService . Load ( ) . AccuracyRatioDivergenceLimit ) ;
664+ IBrush rowBrush = ( accuracyRatio < 1.0 / nodeDivLimit || accuracyRatio > nodeDivLimit ) ? OrangeRedBrush : fgBrush ;
663665 var accuracy = estRows > 0
664666 ? $ " ({ accuracyRatio * 100 : F0} %)"
665667 : "" ;
@@ -727,14 +729,14 @@ private Border CreateNodeVisual(PlanNode node, int totalWarningCount = -1)
727729
728730 #region Edge Rendering
729731
730- private void RenderEdges ( PlanNode node )
732+ private void RenderEdges ( PlanNode node , double divergenceLimit )
731733 {
732734 foreach ( var child in node . Children )
733735 {
734- var path = CreateElbowConnector ( node , child ) ;
736+ var path = CreateElbowConnector ( node , child , divergenceLimit ) ;
735737 PlanCanvas . Children . Add ( path ) ;
736738
737- RenderEdges ( child ) ;
739+ RenderEdges ( child , divergenceLimit ) ;
738740 }
739741 }
740742
@@ -747,6 +749,7 @@ private static IBrush GetLinkColorBrush(PlanNode child, double divergenceLimit)
747749 if ( ! child . HasActualStats )
748750 return EdgeBrush ;
749751
752+ divergenceLimit = Math . Max ( 2.0 , divergenceLimit ) ;
750753 var estRows = child . EstimateRows ;
751754 var accuracyRatio = estRows > 0
752755 ? child . ActualRows / estRows
@@ -774,7 +777,7 @@ private static IBrush GetLinkColorBrush(PlanNode child, double divergenceLimit)
774777 return LinkBlueBrush ;
775778 }
776779
777- private AvaloniaPath CreateElbowConnector ( PlanNode parent , PlanNode child )
780+ private AvaloniaPath CreateElbowConnector ( PlanNode parent , PlanNode child , double divergenceLimit )
778781 {
779782 var parentRight = parent . X + PlanLayoutEngine . NodeWidth ;
780783 var parentCenterY = parent . Y + PlanLayoutEngine . GetNodeHeight ( parent ) / 2 ;
@@ -798,8 +801,7 @@ private AvaloniaPath CreateElbowConnector(PlanNode parent, PlanNode child)
798801 figure . Segments . Add ( new LineSegment { Point = new Point ( childLeft , childCenterY ) } ) ;
799802 geometry . Figures ! . Add ( figure ) ;
800803
801- var settings = AppSettingsService . Load ( ) ;
802- var linkBrush = GetLinkColorBrush ( child , settings . AccuracyRatioDivergenceLimit ) ;
804+ var linkBrush = GetLinkColorBrush ( child , divergenceLimit ) ;
803805
804806 var path = new AvaloniaPath
805807 {
@@ -3612,7 +3614,8 @@ private void RenderMinimap()
36123614 RenderMinimapBranches ( _currentStatement . RootNode , scale ) ;
36133615
36143616 // Render edges
3615- RenderMinimapEdges ( _currentStatement . RootNode , scale ) ;
3617+ var minimapDivergenceLimit = Math . Max ( 2.0 , AppSettingsService . Load ( ) . AccuracyRatioDivergenceLimit ) ;
3618+ RenderMinimapEdges ( _currentStatement . RootNode , scale , minimapDivergenceLimit ) ;
36163619
36173620 // Render nodes
36183621 RenderMinimapNodes ( _currentStatement . RootNode , scale ) ;
@@ -3676,7 +3679,7 @@ private static void CollectSubtreeBounds(PlanNode node, ref double minX, ref dou
36763679 CollectSubtreeBounds ( child , ref minX , ref minY , ref maxX , ref maxY ) ;
36773680 }
36783681
3679- private void RenderMinimapEdges ( PlanNode node , double scale )
3682+ private void RenderMinimapEdges ( PlanNode node , double scale , double divergenceLimit )
36803683 {
36813684 foreach ( var child in node . Children )
36823685 {
@@ -3698,8 +3701,7 @@ private void RenderMinimapEdges(PlanNode node, double scale)
36983701 figure . Segments . Add ( new LineSegment { Point = new Point ( childLeft , childCenterY ) } ) ;
36993702 geometry . Figures ! . Add ( figure ) ;
37003703
3701- var settings = AppSettingsService . Load ( ) ;
3702- var linkBrush = GetLinkColorBrush ( child , settings . AccuracyRatioDivergenceLimit ) ;
3704+ var linkBrush = GetLinkColorBrush ( child , divergenceLimit ) ;
37033705
37043706 var path = new AvaloniaPath
37053707 {
@@ -3710,7 +3712,7 @@ private void RenderMinimapEdges(PlanNode node, double scale)
37103712 } ;
37113713 MinimapCanvas . Children . Add ( path ) ;
37123714
3713- RenderMinimapEdges ( child , scale ) ;
3715+ RenderMinimapEdges ( child , scale , divergenceLimit ) ;
37143716 }
37153717 }
37163718
0 commit comments