From 022f99cec974e0bd4bfcda3a46ae0c653c1da558 Mon Sep 17 00:00:00 2001 From: Ezekiel Lee Date: Thu, 7 Sep 2023 19:53:04 +0800 Subject: [PATCH] fix(backend): timeout when querying mentions --- 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 0d5cb1130a54..6afe13be6f6c 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')