@@ -1990,6 +1990,15 @@ def _set_push_actions_for_event_and_users_txn(
1990
1990
events_and_context.
1991
1991
"""
1992
1992
1993
+ # Only non outlier events will have push actions associated with them,
1994
+ # so let's filter them out. (This makes joining large rooms faster, as
1995
+ # these queries took seconds to process all the state events).
1996
+ non_outlier_events = [
1997
+ event
1998
+ for event , _ in events_and_contexts
1999
+ if not event .internal_metadata .is_outlier ()
2000
+ ]
2001
+
1993
2002
sql = """
1994
2003
INSERT INTO event_push_actions (
1995
2004
room_id, event_id, user_id, actions, stream_ordering,
@@ -2000,7 +2009,7 @@ def _set_push_actions_for_event_and_users_txn(
2000
2009
WHERE event_id = ?
2001
2010
"""
2002
2011
2003
- if events_and_contexts :
2012
+ if non_outlier_events :
2004
2013
txn .execute_batch (
2005
2014
sql ,
2006
2015
(
@@ -2010,12 +2019,12 @@ def _set_push_actions_for_event_and_users_txn(
2010
2019
event .depth ,
2011
2020
event .event_id ,
2012
2021
)
2013
- for event , _ in events_and_contexts
2022
+ for event in non_outlier_events
2014
2023
),
2015
2024
)
2016
2025
2017
2026
room_to_event_ids : Dict [str , List [str ]] = {}
2018
- for e , _ in events_and_contexts :
2027
+ for e in non_outlier_events :
2019
2028
room_to_event_ids .setdefault (e .room_id , []).append (e .event_id )
2020
2029
2021
2030
for room_id , event_ids in room_to_event_ids .items ():
@@ -2040,7 +2049,11 @@ def _set_push_actions_for_event_and_users_txn(
2040
2049
# persisted.
2041
2050
txn .execute_batch (
2042
2051
"DELETE FROM event_push_actions_staging WHERE event_id = ?" ,
2043
- ((event .event_id ,) for event , _ in all_events_and_contexts ),
2052
+ (
2053
+ (event .event_id ,)
2054
+ for event , _ in all_events_and_contexts
2055
+ if not event .internal_metadata .is_outlier ()
2056
+ ),
2044
2057
)
2045
2058
2046
2059
def _remove_push_actions_for_event_id_txn (self , txn , room_id , event_id ):
0 commit comments