message: Move join to recipients outside of LIMIT, via CTE.

This commit is contained in:
Alex Vandiver
2025-03-20 15:45:42 +00:00
committed by Tim Abbott
parent 5f0a55544b
commit 70ed1ee46c
2 changed files with 49 additions and 16 deletions

View File

@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING
from django.db import models, transaction
from django.db.models import QuerySet
from django_cte import CTEManager
from typing_extensions import override
from zerver.lib.display_recipient import get_display_recipient
@@ -52,6 +53,8 @@ class Recipient(models.Model):
# The type group direct messages.
DIRECT_MESSAGE_GROUP = 3
objects = CTEManager() # type: ignore[django-manager-missing] # django-stubs cannot resolve the custom CTEManager yet https://github.com/typeddjango/django-stubs/issues/1023
class Meta:
unique_together = ("type", "type_id")