-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(err): sparkline query is too expensive #29144
base: master
Are you sure you want to change the base?
Conversation
Hey @oliverb123! 👋 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR optimizes error tracking sparkline queries by implementing Common Table Expressions (CTEs) for more efficient volume calculations and event counting.
- Refactored
ErrorTrackingQueryRunner
in/posthog/hogql_queries/error_tracking_query_runner.py
to use CTEs for better query performance - Added predefined sparkline configurations for day/month views with configurable intervals
- Added new test file
/posthog/management/commands/test_error_tracking_query_runner.py
but needs improvement in test coverage and assertions - Implemented cross-joins with CTEs to efficiently calculate event counts across time intervals
- Added proper handling of custom volume configurations through
sparkLineConfigs
dictionary
2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile
posthog/management/commands/test_error_tracking_query_runner.py
Outdated
Show resolved
Hide resolved
self.sparkLineConfigs = { | ||
"volumeDay": ErrorTrackingSparklineConfig(interval=Interval.HOUR, value=24), | ||
"volumeMonth": ErrorTrackingSparklineConfig(interval=Interval.DAY, value=31) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: inconsistent naming: sparkLineConfigs vs sparklineConfigs (camelCase)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daibhin 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AIs fight just as much as developers. Greptile is a tabs man, Cursor is spaces
Going to take another swing at this form a perf perspective |
Final query structure looks like the below. I've tested this in production, comparing its results to the previous designs for our team, and it looks right.