-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reduce cohort calculation memory usage (#23419)
- Loading branch information
Showing
6 changed files
with
35 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ | |
WHERE 1 = 1 | ||
AND ((((performed_event_condition_None_level_level_0_level_0_level_0_0) | ||
OR (performed_event_condition_None_level_level_0_level_0_level_1_0)) | ||
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) | ||
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_cohort_filter_with_another_cohort_with_event_sequence | ||
|
@@ -117,7 +117,7 @@ | |
AND (((has(['test'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), 'name'), '^"|"$', ''))))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = funnel_query.person_id | ||
WHERE 1 = 1 | ||
AND ((((steps_0)) | ||
AND (steps_1))) | ||
AND (steps_1))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_cohort_filter_with_extra | ||
|
@@ -159,7 +159,7 @@ | |
HAVING max(is_deleted) = 0 | ||
AND ((((has(['test'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), 'name'), '^"|"$', '')))))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id | ||
WHERE 1 = 1 | ||
AND (((performed_event_condition_None_level_level_0_level_0_0))) | ||
AND (((performed_event_condition_None_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_cohort_filter_with_extra.1 | ||
|
@@ -197,7 +197,7 @@ | |
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id | ||
WHERE 1 = 1 | ||
AND ((((has(['test'], replaceRegexpAll(JSONExtractRaw(person_props, 'name'), '^"|"$', '')))) | ||
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) | ||
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_performed_event_sequence | ||
|
@@ -240,7 +240,7 @@ | |
AND timestamp >= now() - INTERVAL 7 day )) | ||
GROUP BY person_id) funnel_query | ||
WHERE 1 = 1 | ||
AND (((steps_0))) | ||
AND (((steps_0))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_performed_event_sequence_and_clause_with_additional_event | ||
|
@@ -288,7 +288,7 @@ | |
GROUP BY person_id) funnel_query | ||
WHERE 1 = 1 | ||
AND (((steps_0) | ||
OR (performed_event_multiple_condition_None_level_level_0_level_1_0))) | ||
OR (performed_event_multiple_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_performed_event_sequence_with_person_properties | ||
|
@@ -351,34 +351,7 @@ | |
AND ((has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), 'email'), '^"|"$', '')))) SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = funnel_query.person_id | ||
WHERE 1 = 1 | ||
AND (((steps_0) | ||
AND (performed_event_multiple_condition_None_level_level_0_level_1_0))) | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_performed_event_with_event_filters | ||
''' | ||
|
||
SELECT behavior_query.person_id AS id | ||
FROM | ||
(SELECT pdi.person_id AS person_id, | ||
countIf(timestamp > now() - INTERVAL 1 week | ||
AND timestamp < now() | ||
AND event = '$pageview' | ||
AND (has(['something'], replaceRegexpAll(JSONExtractRaw(properties, '$filter_prop'), '^"|"$', '')))) > 0 AS performed_event_condition_None_level_level_0_level_0_0 | ||
FROM events e | ||
INNER JOIN | ||
(SELECT distinct_id, | ||
argMax(person_id, version) as person_id | ||
FROM person_distinct_id2 | ||
WHERE team_id = 2 | ||
GROUP BY distinct_id | ||
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id | ||
WHERE team_id = 2 | ||
AND event IN ['$pageview'] | ||
AND timestamp <= now() | ||
AND timestamp >= now() - INTERVAL 1 week | ||
GROUP BY person_id) behavior_query | ||
WHERE 1 = 1 | ||
AND (((performed_event_condition_None_level_level_0_level_0_0))) | ||
AND (performed_event_multiple_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_performed_event_with_event_filters_and_explicit_date | ||
|
@@ -405,7 +378,7 @@ | |
AND timestamp >= now() - INTERVAL 4 day | ||
GROUP BY person_id) behavior_query | ||
WHERE 1 = 1 | ||
AND (((performed_event_condition_None_level_level_0_level_0_0))) | ||
AND (((performed_event_condition_None_level_level_0_level_0_0))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_person | ||
|
@@ -443,7 +416,7 @@ | |
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id | ||
WHERE 1 = 1 | ||
AND (((performed_event_condition_None_level_level_0_level_0_0) | ||
OR (has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(person_props, '$sample_field'), '^"|"$', ''))))) | ||
OR (has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(person_props, '$sample_field'), '^"|"$', ''))))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_person_materialized | ||
|
@@ -481,7 +454,7 @@ | |
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id | ||
WHERE 1 = 1 | ||
AND (((performed_event_condition_None_level_level_0_level_0_0) | ||
OR (has(['[email protected]'], "pmat_$sample_field")))) | ||
OR (has(['[email protected]'], "pmat_$sample_field")))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_person_properties_with_pushdowns | ||
|
@@ -533,7 +506,7 @@ | |
AND ((((performed_event_condition_None_level_level_0_level_0_level_0_0) | ||
OR (performed_event_condition_None_level_level_0_level_0_level_1_0) | ||
OR (has(['special'], replaceRegexpAll(JSONExtractRaw(person_props, 'name'), '^"|"$', '')))) | ||
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) | ||
AND ((first_time_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_person_props_only | ||
|
@@ -623,7 +596,7 @@ | |
(SELECT person_id as id | ||
FROM person_static_cohort | ||
WHERE cohort_id = 2 | ||
AND team_id = 2)))) | ||
AND team_id = 2)))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_static_cohort_filter_with_extra | ||
|
@@ -673,7 +646,7 @@ | |
FROM person_static_cohort | ||
WHERE cohort_id = 2 | ||
AND team_id = 2)) | ||
AND (performed_event_condition_None_level_level_0_level_1_0))) | ||
AND (performed_event_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_static_cohort_filter_with_extra.2 | ||
|
@@ -714,7 +687,7 @@ | |
FROM person_static_cohort | ||
WHERE cohort_id = 2 | ||
AND team_id = 2))) | ||
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) | ||
OR ((performed_event_condition_None_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- | ||
# name: TestCohortQuery.test_unwrapping_static_cohort_filter_hidden_in_layers_of_cohorts | ||
|
@@ -769,6 +742,6 @@ | |
FROM person_static_cohort | ||
WHERE cohort_id = 2 | ||
AND team_id = 2))) | ||
OR (performed_event_condition_None_level_level_0_level_1_0))) | ||
OR (performed_event_condition_None_level_level_0_level_1_0))) SETTINGS optimize_aggregation_in_order=1 | ||
''' | ||
# --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters