0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00
posthog/ee/clickhouse/queries/sessions
Karl-Aksel Puulmann 09fe2859ae
Rework sessions list query to account for pagination (#3296)
* Fix and test more sessions pagination cases

Pagination previously did not work correctly on CH/postgres due to
LIMIT clauses

Simplifying the sessions query helps on clickhouse, though might
introduce new issues.

* Make sessions list pagination work

The key idea is divorce distinct_id lookups from result lookups.

This now works in the scenario where 101 users match person filter/have done
an event in time range, but only the 101st has a session matching
action/event filter (see tests)

This will perform even on superdaily, though it might slow down for very
specialized queries.

Potential future speedups:
- apply action/event filters on the distinct_id query -
  only return those which who have the possibility of matching.

- Make distinct_id LIMIT higher if we know action/event limit is
  involved

- Caching the distinct_id query heavily

* Reorganize code

* Make session list tests pass w/ pagination

* Add tests, fix another corner case for postgres sessions list

distinct_ids were not always returned in the right order.

* Include distinct_id in sessions query

This should now solve https://github.com/PostHog/posthog/issues/3055
2021-02-12 09:41:10 +02:00
..
__init__.py
average.py Round sessions value (#2925) 2021-01-21 13:24:59 -05:00
clickhouse_sessions.py Allow filtering by unseen recordings (#3000) 2021-01-21 09:42:00 +02:00
distribution.py
list.py Rework sessions list query to account for pagination (#3296) 2021-02-12 09:41:10 +02:00