mirror of
https://github.com/zulip/zulip.git
synced 2026-07-06 21:18:58 +08:00
The unique index on `(user_id, message_id)` that is the `zerver_usermessage` table is rather specific, and even the PostgreSQL extended statistics are not enough for it to realize there is a correlation between the `realm_id` in the message table and the `user_id` in the usermessage table. This means that adding the `realm_id` limit when there is a join to `zerver_usermessage` flips the query plan from a nested loop of unique usermessage index-only scan, with an index scan of the messages pkey -- to a parallel hash join of the messages limit with a index scan of just the user_id limit on usermessages. It thinks this is necessary because it thinks that the `realm_id` limit may remove a large number of messages from the usermessage set -- which is totally untrue. Remove the `realm_id` limit if we have a usermessage join. |
||
|---|---|---|
| .. | ||
| actions | ||
| data_import | ||
| integration_fixtures/nagios | ||
| lib | ||
| management | ||
| migrations | ||
| openapi | ||
| tests | ||
| tornado | ||
| transaction_tests | ||
| views | ||
| webhooks | ||
| worker | ||
| __init__.py | ||
| apps.py | ||
| context_processors.py | ||
| decorator.py | ||
| filters.py | ||
| forms.py | ||
| logging_handlers.py | ||
| middleware.py | ||
| models.py | ||
| signals.py | ||