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

Cohorts page hangs #439

Closed
jamesefhawkins opened this issue Apr 3, 2020 · 4 comments
Closed

Cohorts page hangs #439

jamesefhawkins opened this issue Apr 3, 2020 · 4 comments
Assignees
Labels
bug Something isn't working right

Comments

@jamesefhawkins
Copy link
Collaborator

Describe the bug
Cohorts won't load on app.

To Reproduce
Steps to reproduce the behavior:

  1. Go to cohorts
  2. Try to view a cohort
  3. It hangs

Screenshot 2020-04-03 at 16 44 34

Expected behavior
It should load.

Screenshots
Attached.

@jamesefhawkins jamesefhawkins added bug Something isn't working right priority-2 labels Apr 6, 2020
@jamesefhawkins jamesefhawkins added this to To Do in App via automation Apr 6, 2020
timgl added a commit that referenced this issue Apr 6, 2020
@jamesefhawkins jamesefhawkins removed their assignment Apr 7, 2020
timgl added a commit that referenced this issue Apr 7, 2020
Adds to #439 try to fix cohort page hangs
@timgl
Copy link
Collaborator

timgl commented Apr 9, 2020

The basic problem with the Cohort query (and the Funnel queries) is that for each person in the database, it does a query against the Events table. Those events queries are pretty quick (and usually indexed correctly) but we end up doing 40k of them for our own instance for example.

There's got to be a better way to do this, I just don't know how.

@mariusandra
Copy link
Collaborator

When you say "does a query against the events table", are you referring to the subqueries I see for example in the funnels code? Or is there a legit python loop that makes these queries? I remember seeing one a long time ago, but I couldn't find it now.

There is something called the postgres LATERAL JOIN that should speed up the funnels a bit more than the subqueries.

For cohorts, I need to think a bit more about this. I seem to have run out of brainpower for today :).

@timgl
Copy link
Collaborator

timgl commented Apr 9, 2020

yep I'm talking about the subqueries. For funnels and cohorts we really only do one query, but they take 10-30 seconds (and probably longer for the cohorts ones).

I hadn't heard of LATERAL JOIN but that looks like it's exactly what we're looking for. There's even an example of someone doing a funnel.

Annoyingly I think Django doesn't support this in the ORM but I think that's worth the tradeoff

@timgl timgl moved this from To do to In progress in Parity (Roadmap phase 1) Apr 13, 2020
@timgl
Copy link
Collaborator

timgl commented Apr 13, 2020

@jamesefhawkins I think I actually fixed this with my previous attempt, if I go on app now cohorts just work... would you mind checking again?

There was an issue with duplicate people within cohorts, so have created a pr for that #552.

@timgl timgl moved this from In progress to Review in progress in Parity (Roadmap phase 1) Apr 13, 2020
@timgl timgl moved this from Review in progress to Done in Parity (Roadmap phase 1) May 4, 2020
@EDsCODE EDsCODE closed this as completed May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right
Projects
No open projects
Development

No branches or pull requests

4 participants