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.
From LibreChat-AI#16245 (finding LibreChat-AI#16245 (comment), plus the same cause from the local review on 05569a9).
sharedOnly=trueandhasFiles=trueeach 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$inwould approach the 16MB command limit.Options: move the list query to an aggregation with a
$lookuponsharedlinks/messagesscoped by user, or add a partial index on messages with files and denormalize ahasFilesflag written by the upload paths (the share facet cannot be denormalized because links expire). Measure with a seeded heavy user before choosing.