Skip to content
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

Speed up filtering by events in sessions #3707

Merged
merged 3 commits into from Mar 19, 2021
Merged

Conversation

macobo
Copy link
Contributor

@macobo macobo commented Mar 19, 2021

  • restructure the code

  • Clean up complicated function using namedtuple

  • Speed up action/event filtering in clickhouse

    For very rare events, filtering by them in sessions previously was slow.
    This was because the the distinct_id query contained a lot of users who
    hadn't done the action, resulting in more looping.

    This commit speeds things up by querying users who have done any events matching the
    event/action filter.

No benchmarks (sorry) since I did not have access to clickhouse outside of metabase.

Checklist

  • All querysets/queries filter by Organization, by Team, and by User
  • Django backend tests
  • Jest frontend tests
  • Cypress end-to-end tests

@macobo macobo requested a review from EDsCODE March 19, 2021 12:55
@timgl timgl temporarily deployed to posthog-session-filteri-zf9udz March 19, 2021 13:00 Inactive
@macobo macobo temporarily deployed to posthog-session-filteri-zf9udz March 19, 2021 13:08 Inactive
For very rare events, filtering by them in sessions previously was slow.
This was because the the distinct_id query contained a lot of users who
hadn't done the action, resulting in more looping.

This commit speeds things up by querying users who have done any events matching the
event/action filter.
@macobo macobo temporarily deployed to posthog-session-filteri-zf9udz March 19, 2021 13:10 Inactive
Copy link
Member

@EDsCODE EDsCODE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@macobo macobo merged commit e234b8d into master Mar 19, 2021
@macobo macobo deleted the session-filtering-speedup branch March 19, 2021 18:16
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.

None yet

3 participants