mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
Our previous set of indexes for the Message table did not contain anything to optimize queries for all the messages in a topic in an organization where the same topic name might appear in 10,000s of messages in many streams. We add two indexes here to support common queries * A `(recipient_id, upper(subject), id)` index to support "Fetch all messages from a topic" queries. * A `(recipient_id, subject, id)` index to support "Fetch all messages by topic" We use the `DESC NULLS last` on both indexes because we almost always want to query from the "Latest N messages" on a topic, not the "Earliest N messages". These indexes dramatically improve the performance of fetching topic history (which remains not good enough in my opinion; we'll likely need caching to make it nice), and more importantly make it possible to check quickly which users have sent messages to a topic for the "Topics I follow" feature. Fixes part of #13726.
651 B
651 B