diff --git a/latest_migrations.manifest b/latest_migrations.manifest index a5c0761b19278..3a4fca6b52cf8 100644 --- a/latest_migrations.manifest +++ b/latest_migrations.manifest @@ -5,7 +5,7 @@ contenttypes: 0002_remove_content_type_name ee: 0016_rolemembership_organization_member otp_static: 0002_throttling otp_totp: 0002_auto_20190420_0723 -posthog: 0410_action_steps_population +posthog: 0411_eventproperty_indexes sessions: 0001_initial social_django: 0010_uid_db_index two_factor: 0007_auto_20201201_1019 diff --git a/posthog/api/property_definition.py b/posthog/api/property_definition.py index 93d7a028dabf8..2bab343e5249f 100644 --- a/posthog/api/property_definition.py +++ b/posthog/api/property_definition.py @@ -215,7 +215,7 @@ def with_event_property_filter( event_names = json.loads(event_names) if event_names and len(event_names) > 0: - event_property_field = f"{self.posthog_eventproperty_table_join_alias}.property is not null" + event_property_field = f"{self.posthog_eventproperty_table_join_alias}.property IS NOT NULL" event_name_join_filter = "AND event = ANY(%(event_names)s)" return dataclasses.replace( diff --git a/posthog/migrations/0411_eventproperty_indexes.py b/posthog/migrations/0411_eventproperty_indexes.py new file mode 100644 index 0000000000000..3312ec0840176 --- /dev/null +++ b/posthog/migrations/0411_eventproperty_indexes.py @@ -0,0 +1,17 @@ +# Created manually on 2024-04-10 18:46 + +from django.db import migrations + + +class Migration(migrations.Migration): + atomic = False + dependencies = [ + ("posthog", "0410_action_steps_population"), + ] + + operations = [ + migrations.RunSQL( + "CREATE INDEX CONCURRENTLY posthog_eventproperty_team_id_and_property_r32khd9s ON posthog_eventproperty(team_id, property)", + reverse_sql='DROP INDEX "posthog_eventproperty_team_id_and_property_r32khd9s"', + ), + ]