Speed up `get_unread_event_push_actions_by_room` (#13005)
Fixes #11887 hopefully. The core change here is that `event_push_summary` now holds a summary of counts up until a much more recent point, meaning that the range of rows we need to count in `event_push_actions` is much smaller. This needs two major changes: 1. When we get a receipt we need to recalculate `event_push_summary` rather than just delete it 2. The logic for deleting `event_push_actions` is now divorced from calculating `event_push_summary`. In future it would be good to calculate `event_push_summary` while we persist a new event (it should just be a case of adding one to the relevant rows in `event_push_summary`), as that will further simplify the get counts logic and remove the need for us to periodically update `event_push_summary` in a background job.
Showing
- changelog.d/13005.misc 1 addition, 0 deletionschangelog.d/13005.misc
- synapse/_scripts/synapse_port_db.py 4 additions, 0 deletionssynapse/_scripts/synapse_port_db.py
- synapse/handlers/sync.py 3 additions, 7 deletionssynapse/handlers/sync.py
- synapse/push/push_tools.py 13 additions, 20 deletionssynapse/push/push_tools.py
- synapse/storage/database.py 1 addition, 0 deletionssynapse/storage/database.py
- synapse/storage/databases/main/__init__.py 2 additions, 2 deletionssynapse/storage/databases/main/__init__.py
- synapse/storage/databases/main/event_push_actions.py 189 additions, 69 deletionssynapse/storage/databases/main/event_push_actions.py
- synapse/storage/databases/main/push_rule.py 1 addition, 1 deletionsynapse/storage/databases/main/push_rule.py
- synapse/storage/databases/main/receipts.py 41 additions, 33 deletionssynapse/storage/databases/main/receipts.py
- synapse/storage/schema/main/delta/40/event_push_summary.sql 4 additions, 3 deletionssynapse/storage/schema/main/delta/40/event_push_summary.sql
- synapse/storage/schema/main/delta/71/02event_push_summary_unique.sql 18 additions, 0 deletions...rage/schema/main/delta/71/02event_push_summary_unique.sql
- tests/push/test_http.py 8 additions, 8 deletionstests/push/test_http.py
- tests/replication/slave/storage/test_events.py 17 additions, 6 deletionstests/replication/slave/storage/test_events.py
- tests/storage/test_event_push_actions.py 21 additions, 3 deletionstests/storage/test_event_push_actions.py
Loading
Please register or sign in to comment