Introducing Insights Anomalies
Nov 28, 2023Rafer Hazen

Summary
This post introduces PlanetScale Insights Anomalies, a new feature that automatically detects and highlights performance issues in production databases. It defines an anomaly as periods where the percentage of queries exceeding two standard deviations above their historical mean execution time (for the same query pattern) increases. The implementation involves aggregating query response times using probabilistic sketches, calculating per-query pattern thresholds, and counting outlier queries. The post details how anomalies are presented with correlated metrics (rows read/written, CPU, disk IOPS) and specific query patterns identified using Pearson correlation coefficient, aiding in root cause analysis.