Skip to content

[upstream #16245] #16245: Bound the sharedOnly and hasFiles list facets server-side #129

Description

@berry-13

From LibreChat-AI#16245 (finding LibreChat-AI#16245 (comment), plus the same cause from the local review on 05569a9).

sharedOnly=true and hasFiles=true each resolve the user's full ID set before the paged conversation query (SharedLink.distinct('conversationId'), Message.find({ user, 'files.0': { $exists: true } }).distinct('conversationId')) and send it back as $in. The work is proportional to the user's whole share or attachment history on every page, and at a few hundred thousand IDs the $in would approach the 16MB command limit.

Options: move the list query to an aggregation with a $lookup on sharedlinks/messages scoped by user, or add a partial index on messages with files and denormalize a hasFiles flag written by the upload paths (the share facet cannot be denormalized because links expire). Measure with a seeded heavy user before choosing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: packagesreviewctl followups stateperfreviewctl followups statereadyreviewctl followups state

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions