Skip to content

Conversation

@seer-by-sentry
Copy link

Fixes HACKATIME-19H. The issue was that: Complex window functions without optimal index support cause sequential scans and sorts, leading to slow queries.

  • Add a new database index on heartbeats for (user_id, language, time) to optimize window functions partitioned by language.
  • Refactor daily_durations_for_users to improve index usage by simplifying the inner window function's PARTITION BY to user_id and moving day grouping to the outer aggregation.
  • Enhance total_duration_for_scope to dynamically include user_id in window function PARTITION BY clauses when user_id is present in the query's WHERE clause, leveraging composite indexes.

This fix was generated by Seer in Sentry, triggered by mahadkalam1234@gmail.com. 👁️ Run ID: 9956850

Not quite right? Click here to continue debugging with Seer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants