diff --git a/Darling/Darling.Tests/FinOpsIndexAnalysisViewTests.cs b/Darling/Darling.Tests/FinOpsIndexAnalysisViewTests.cs index a326e4cefa..999c2bb9f3 100644 --- a/Darling/Darling.Tests/FinOpsIndexAnalysisViewTests.cs +++ b/Darling/Darling.Tests/FinOpsIndexAnalysisViewTests.cs @@ -137,19 +137,42 @@ public void Gb_RoundsAwayFromZero_ToThreeDecimals() } [Fact] - public void Notes_AreUptimeThenDedupeThenAnalyzerNotes() + public void Notes_AreUptimeThenAnalyzerNotes_WhenOnlyTheUptimeWarningApplies() { var root = Build(new IndexCleanupAnalysisResult { - DatabaseRollups = [Roll("d")], UptimeWarning = true, DedupeOnlyApplied = true, Notes = ["n1", "n2"], + DatabaseRollups = [Roll("d")], UptimeWarning = true, Notes = ["n1", "n2"], }); var notes = root.GetProperty("notes").EnumerateArray().Select(n => n.GetString()!).ToArray(); - Assert.Equal(4, notes.Length); + Assert.Equal(3, notes.Length); Assert.StartsWith("Server uptime is under 14 days", notes[0], StringComparison.Ordinal); - Assert.StartsWith("Dedupe-only mode is in effect", notes[1], StringComparison.Ordinal); - Assert.Equal(new[] { "n1", "n2" }, notes.Skip(2).ToArray()); + Assert.Equal(new[] { "n1", "n2" }, notes.Skip(1).ToArray()); } + /// #6653: dedupe-only mode flags no unused index, so the uptime caveat about premature "Unused Index" findings is left + /// out beside the dedupe notice; the raw uptime_warning fact stays on the payload. + [Fact] + public void Notes_LeaveOutTheUptimeCaveat_WhenDedupeOnlyIsInEffect() + { + var root = Build(new IndexCleanupAnalysisResult + { + DatabaseRollups = [Roll("d")], UptimeWarning = true, DedupeOnlyApplied = true, Notes = ["n1", "n2"], + }); + var notes = root.GetProperty("notes").EnumerateArray().Select(n => n.GetString()!).ToArray(); + Assert.Equal(3, notes.Length); + Assert.StartsWith("Dedupe-only mode is in effect", notes[0], StringComparison.Ordinal); + Assert.Equal(new[] { "n1", "n2" }, notes.Skip(1).ToArray()); + Assert.True(root.GetProperty("uptime_warning").GetBoolean()); + } + + [Theory] + [InlineData(true, false, true)] + [InlineData(true, true, false)] + [InlineData(false, true, false)] + [InlineData(false, false, false)] + public void ShowUptimeCaveat_IsTheUptimeWarning_OnlyWhenDedupeOnlyIsNotInEffect(bool uptimeWarning, bool dedupeOnly, bool expected) => + Assert.Equal(expected, new IndexCleanupAnalysisResult { UptimeWarning = uptimeWarning, DedupeOnlyApplied = dedupeOnly }.ShowUptimeCaveat); + [Fact] public void OverallRow_HasNoWorkloadKeys_AndDatabaseRowsDo() { diff --git a/Darling/Darling.Tests/Fixtures/FinOpsIndexAnalysis/golden.json b/Darling/Darling.Tests/Fixtures/FinOpsIndexAnalysis/golden.json index 820fa21b4b..6a1372b20b 100644 --- a/Darling/Darling.Tests/Fixtures/FinOpsIndexAnalysis/golden.json +++ b/Darling/Darling.Tests/Fixtures/FinOpsIndexAnalysis/golden.json @@ -385,6 +385,7 @@ }, "UptimeWarning": true, "DedupeOnlyApplied": true, + "ShowUptimeCaveat": false, "Notes": [ "Reverse Duplicate and Equal Except For Filter indexes are listed as REVIEW rows only and are never disabled for you. An index with the same columns in a different order, or with a different filter, can serve different queries or rows, so check each one by hand.", "Not covered: sp_IndexCleanup also reports a Same Keys Different Order review case. The Reverse Duplicate review rows above cover most of it." @@ -950,6 +951,7 @@ }, "UptimeWarning": false, "DedupeOnlyApplied": false, + "ShowUptimeCaveat": false, "Notes": [ "Reverse Duplicate and Equal Except For Filter indexes are listed as REVIEW rows only and are never disabled for you. An index with the same columns in a different order, or with a different filter, can serve different queries or rows, so check each one by hand.", "Not covered: sp_IndexCleanup also reports a Same Keys Different Order review case. The Reverse Duplicate review rows above cover most of it." diff --git a/Darling/Darling.Tests/Viewer4570Tests.cs b/Darling/Darling.Tests/Viewer4570Tests.cs index ff726f8546..9eca462150 100644 --- a/Darling/Darling.Tests/Viewer4570Tests.cs +++ b/Darling/Darling.Tests/Viewer4570Tests.cs @@ -29,7 +29,7 @@ public void RuntimeSummaryTitle_NoQueryTimeStats_IsPredictedRuntime() { var stmt = Statement(); Assert.Null(stmt.QueryTimeStats); - Assert.Equal("Predicted Runtime", PlanDisplayText.RuntimeSummaryTitle(stmt)); + Assert.Equal("Plan properties", PlanDisplayText.RuntimeSummaryTitle(stmt)); } [Fact] diff --git a/Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingMcpFinOpsTools.IndexAnalysis.cs b/Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingMcpFinOpsTools.IndexAnalysis.cs index e48154d847..2f7824bd00 100644 --- a/Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingMcpFinOpsTools.IndexAnalysis.cs +++ b/Darling/PerformanceMonitor.Darling.Service/Mcp/DarlingMcpFinOpsTools.IndexAnalysis.cs @@ -239,7 +239,7 @@ internal static string BuildIndexAnalysisPayload( } var notes = new List(); - if (result.UptimeWarning) notes.Add(IndexAnalysisUptimeNote); + if (result.ShowUptimeCaveat) notes.Add(IndexAnalysisUptimeNote); if (result.DedupeOnlyApplied) notes.Add(IndexAnalysisDedupeNote); notes.AddRange(result.Notes); diff --git a/Darling/PerformanceMonitor.Darling.Service/wwwroot/js/pages/finops/index-analysis.js b/Darling/PerformanceMonitor.Darling.Service/wwwroot/js/pages/finops/index-analysis.js index 6d1c255b1e..ec7032cec8 100644 --- a/Darling/PerformanceMonitor.Darling.Service/wwwroot/js/pages/finops/index-analysis.js +++ b/Darling/PerformanceMonitor.Darling.Service/wwwroot/js/pages/finops/index-analysis.js @@ -156,7 +156,8 @@ export const tab = { const recs = (data.recommendations || []).map((r) => recommendationRow(r, captured)); const rollups = (data.overall ? [rollupRow({ ...data.overall, database_name: "ALL DATABASES" })] : []) .concat((data.databases || []).map(rollupRow)); - const lead = (data.uptime_warning ? 1 : 0) + (data.dedupe_only_applied ? 1 : 0); + /* #6653: the notes lead with the uptime caveat only when dedupe-only is not in effect (the tool leaves it out beside the dedupe notice). */ + const lead = (data.uptime_warning && !data.dedupe_only_applied ? 1 : 0) + (data.dedupe_only_applied ? 1 : 0); const notes = data.notes || []; const parts = [noticeStrip(noticeText(data, recs.length, choice.db))]; notes.slice(0, lead).forEach((t) => parts.push(noticeStrip(t))); diff --git a/Darling/PerformanceMonitor.Darling.Viewer/FinOpsTab.IndexAnalysis.cs b/Darling/PerformanceMonitor.Darling.Viewer/FinOpsTab.IndexAnalysis.cs index f53f3e452d..5a9dd3ab29 100644 --- a/Darling/PerformanceMonitor.Darling.Viewer/FinOpsTab.IndexAnalysis.cs +++ b/Darling/PerformanceMonitor.Darling.Viewer/FinOpsTab.IndexAnalysis.cs @@ -71,7 +71,8 @@ private void BuildIndexAnalysisBanners(IndexCleanupAnalysisResult result) { FinOpsIndexAnalysisBannerPanel.Children.Clear(); - if (result.UptimeWarning) + /* #6653: dedupe-only mode flags no unused index, so the uptime caveat about them is left out beside its notice. */ + if (result.ShowUptimeCaveat) { AddIndexAnalysisBanner( "Server uptime is under 14 days — index usage data may be incomplete, so some \"Unused Index\" findings could be premature.", diff --git a/Darling/PerformanceMonitor.Darling.Viewer/SettingsWindow.xaml b/Darling/PerformanceMonitor.Darling.Viewer/SettingsWindow.xaml index 28e613dc18..048325c99e 100644 --- a/Darling/PerformanceMonitor.Darling.Viewer/SettingsWindow.xaml +++ b/Darling/PerformanceMonitor.Darling.Viewer/SettingsWindow.xaml @@ -88,8 +88,14 @@ + + @@ -119,12 +125,6 @@ - - diff --git a/PerformanceMonitor.Common/IndexCleanupModels.cs b/PerformanceMonitor.Common/IndexCleanupModels.cs index fd50e85604..89e4f1f5a7 100644 --- a/PerformanceMonitor.Common/IndexCleanupModels.cs +++ b/PerformanceMonitor.Common/IndexCleanupModels.cs @@ -472,6 +472,14 @@ public sealed record IndexCleanupAnalysisResult /// Dedupe-only was in effect (either requested, or auto-enabled because uptime <= 7 days), so unused indexes were not flagged. public bool DedupeOnlyApplied { get; init; } + /// + /// Whether the "uptime under 14 days" caveat is worth showing (#6653). It warns that usage data may be incomplete and some "Unused + /// Index" findings premature, but dedupe-only mode (uptime of 7 days or less, or requested) flags no unused index at all, so beside + /// the dedupe notice the caveat describes findings that are not there and contradicts it. Both the Viewer's banners and the + /// get_finops notes (which the web page shows) read this one rule; itself stays the raw fact. + /// + public bool ShowUptimeCaveat => UptimeWarning && !DedupeOnlyApplied; + /// Precisely-surfaced limitations of this data-driven reproduction (e.g. omitted filegroup placement, compression exclusions not reproducible, out-of-scope rules). public IReadOnlyList Notes { get; init; } = Array.Empty(); } diff --git a/PerformanceMonitor.PlanAnalysis/PlanDisplayText.cs b/PerformanceMonitor.PlanAnalysis/PlanDisplayText.cs index 83fcfb9f63..b614b80883 100644 --- a/PerformanceMonitor.PlanAnalysis/PlanDisplayText.cs +++ b/PerformanceMonitor.PlanAnalysis/PlanDisplayText.cs @@ -76,11 +76,13 @@ public static string CopyQueryText(PlanStatement statement, int statementCount, /// /// The runtime summary card's title, matching erikdarlingdata/PerformanceStudio@40ade29 (E7): - /// "Predicted Runtime" when the statement has no - /// (an estimated-plan-only statement), "Runtime Summary" otherwise. + /// "Plan properties" when the statement has no + /// (an estimated-plan-only statement), "Runtime Summary" otherwise. #6653: PerformanceStudio@40ade29 + /// titled the estimated card "Predicted Runtime", but it holds compile facts (compile time, memory, cached size), + /// not a predicted runtime, so the title is "Plan properties" here. /// public static string RuntimeSummaryTitle(PlanStatement statement) => - statement.QueryTimeStats == null ? "Predicted Runtime" : "Runtime Summary"; + statement.QueryTimeStats == null ? "Plan properties" : "Runtime Summary"; /// /// Walks a plan's node tree looking for any warning whose type ends in " Spill" (Sort Spill,