mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Previously, get_recent_private_messages could take 100ms-1s to run, contributing a substantial portion of the total runtime of `/`. We fix this by taking advantage of the recent denormalization of personal_recipient into the UserProfile model, allowing us to avoid the complex join with Recipient that was previously required. The change that requires additional commentary is the change to the main, big SQL query: 1. We eliminate UserMessage table from the query, because the condition m.recipient_id=%(my_recipient_id)d implies m is a personal message to the user being processed - so joining with usermessage to check for user_profile_id and flags&2048 (which checks the message is private) is redundant. 2. We only need to join the Message table with UserProfile (on sender_id) and get the sender's personal_recipient_id from their UserProfile row. Fixes #13437.
41 KiB
41 KiB