diff --git a/public/app/features/query/state/PanelQueryRunner.ts b/public/app/features/query/state/PanelQueryRunner.ts index 6f7d85c7db4..b13d54bc193 100644 --- a/public/app/features/query/state/PanelQueryRunner.ts +++ b/public/app/features/query/state/PanelQueryRunner.ts @@ -336,9 +336,30 @@ export class PanelQueryRunner { this.subscription = panelData.subscribe({ next: (data) => { - this.lastResult = skipPreProcess ? data : preProcessPanelData(data, this.lastResult); + const last = this.lastResult; + const next = skipPreProcess ? data : preProcessPanelData(data, last); + + if (last != null) { + let sameSeries = compareArrayValues(last.series ?? [], next.series ?? [], (a, b) => a === b); + let sameAnnotations = compareArrayValues(last.annotations ?? [], next.annotations ?? [], (a, b) => a === b); + + if (sameSeries) { + next.series = last.series; + } + + if (sameAnnotations) { + next.annotations = last.annotations; + } + + if (sameSeries && sameAnnotations) { + return; + } + } + + this.lastResult = next; + // Store preprocessed query results for applying overrides later on in the pipeline - this.subject.next(this.lastResult); + this.subject.next(next); }, }); }