Back to feed
Dev.to
Dev.to
6/30/2026
When a KPI reads 163 billion instead of 819

When a KPI reads 163 billion instead of 819

Short summary

A metrics engine with dual query paths (SQL push-down vs. in-memory aggregation) drifted when a parameter was bound but never used in the WHERE clause, causing a KPI to sum across multiple series instead of filtering correctly—inflating one value from 819 to 163 billion. The fix: place shared predicates in a base WHERE inherited by all compile paths, and test both paths produce identical queries and results.

  • Two query paths drifted: parameter was bound but never referenced in WHERE clause, causing KPI to sum all series instead of filtering
  • KPI inflated from 819 to 163 billion by including hashed values from a second metric series
  • Solution: put shared predicates in base WHERE inherited by all paths, and test that both produce identical filters and answers

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more