Skip to content

Commit

Permalink
fix: more artisanal querying for cohort performance (#25770)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Oct 23, 2024
1 parent 9cecc2e commit a42c2ae
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,12 @@ class CohortPropertyGroupsSubQuery:
_ttl_days: int

raw_cohort_to_distinct_id = """
select distinct_id
from person_distinct_ids
where {cohort_predicate}
SELECT
distinct_id
FROM raw_person_distinct_ids
WHERE distinct_id in (SELECT distinct_id FROM raw_person_distinct_ids WHERE 1=1 AND {cohort_predicate})
GROUP BY distinct_id
HAVING argMax(is_deleted, version) = 0 AND {cohort_predicate}
"""

def __init__(self, team: Team, filter: SessionRecordingsFilter, ttl_days: int):
Expand Down
Loading

0 comments on commit a42c2ae

Please sign in to comment.