-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Swap out person_distinct_id in queries with subquery #3828
Conversation
…consider latest distinct_ids
I did some manual testing across the analytics and the one that I had to skip for significant degraded performance was the lifecycle query |
@@ -65,6 +65,13 @@ | |||
{query} | |||
""" | |||
|
|||
GET_LATEST_PERSON_DISTINCT_ID_SQL = """ | |||
SELECT * FROM person_distinct_id JOIN ( | |||
SELECT distinct_id, max(_offset) as _offset FROM person_distinct_id WHERE team_id = %(team_id)s GROUP BY distinct_id |
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.
I'm using offset because it has more precision than _timestamp since _timestamp doesn't consider seconds
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.
This looks good.
I'm just curious if we could maybe test out the impact of changing these queries to optionally use FINAL
in the select if it would be faster?
Changes
Please describe.
person_distinct_id
use a subquery to ensure the distinct_ids in consideration are always the latestIf this affects the frontend, include screenshots.
Checklist