From af7e129b1eeecd196cdb14b9221c94959eacca85 Mon Sep 17 00:00:00 2001 From: Ezekiel Lee <80657402+zekexy@users.noreply.github.com> Date: Fri, 8 Sep 2023 07:44:46 +0800 Subject: [PATCH] fix(backend): timeout when querying mentions (#11799) --- packages/backend/src/server/api/endpoints/notes/mentions.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/notes/mentions.ts b/packages/backend/src/server/api/endpoints/notes/mentions.ts index 0d5cb1130a..6afe13be6f 100644 --- a/packages/backend/src/server/api/endpoints/notes/mentions.ts +++ b/packages/backend/src/server/api/endpoints/notes/mentions.ts @@ -63,6 +63,8 @@ export default class extends Endpoint { // eslint- .where(`'{"${me.id}"}' <@ note.mentions`) .orWhere(`'{"${me.id}"}' <@ note.visibleUserIds`); })) + // Avoid scanning primary key index + .orderBy('CONCAT(note.id)', 'DESC') .innerJoinAndSelect('note.user', 'user') .leftJoinAndSelect('note.reply', 'reply') .leftJoinAndSelect('note.renote', 'renote')