analytics: Better indexed join to analytics_usercount, using realm_id.

analytics_usercount_property_realm_id_end_time_591dbec1_idx, added
back in b7df84d5a8, makes this lookup actually indexed.
195defb031 rewrote this query in a way which stopped using the
index.
This commit is contained in:
Alex Vandiver 2024-07-30 15:08:03 +00:00 committed by Tim Abbott
parent a88445a6d2
commit 94795500b5
1 changed files with 1 additions and 0 deletions

View File

@ -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