Add index to improve user/notes endpoint performance

This commit is contained in:
Laura Hausmann 2023-09-28 02:42:14 +02:00
parent 6d648b87d2
commit 2efdbae42e
No known key found for this signature in database
GPG Key ID: D044E84C5BE01605
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,10 @@
export class IndexNoteUserId1695861526125 {
name = "IndexNoteUserId1695861526125";
async up(queryRunner) {
await queryRunner.query(`CREATE INDEX "IDX_note_userId_id" ON "note" ("userId", "id")`);
}
async down(queryRunner) {
await queryRunner.query(`DROP INDEX "IDX_note_userId_id"`);
}
}

View File

@ -16,6 +16,7 @@ import { Channel } from "./channel.js";
@Index("IDX_NOTE_TAGS", { synchronize: false })
@Index("IDX_NOTE_MENTIONS", { synchronize: false })
@Index("IDX_NOTE_VISIBLE_USER_IDS", { synchronize: false })
@Index("IDX_note_userId_id", ["userId", "id"])
export class Note {
@PrimaryColumn(id())
public id: string;