From 94795500b5be8da1a46c8b8f32a69295e7f514cf Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Tue, 30 Jul 2024 15:08:03 +0000 Subject: [PATCH] analytics: Better indexed join to analytics_usercount, using realm_id. analytics_usercount_property_realm_id_end_time_591dbec1_idx, added back in b7df84d5a8d9, makes this lookup actually indexed. 195defb0310a rewrote this query in a way which stopped using the index. --- analytics/lib/counts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index f3941b6f70..1fc9ce5fd4 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -768,6 +768,7 @@ def count_realm_active_humans_query(realm: Realm | None) -> QueryFn: AND end_time = %(time_end)s ) active_usercount JOIN zerver_userprofile ON active_usercount.user_id = zerver_userprofile.id + AND active_usercount.realm_id = zerver_userprofile.realm_id JOIN ( SELECT DISTINCT ON (modified_user_id) modified_user_id, event_type