[backend] Add a new index to the note table for faster generation of following query heuristics

This commit is contained in:
Laura Hausmann 2023-12-15 23:56:00 +01:00
parent bd63e16e5f
commit 384fb76a26
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 14 additions and 0 deletions

View file

@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddNoteCreatedatUseridIdx1702680809638 implements MigrationInterface {
name = 'AddNoteCreatedatUseridIdx1702680809638'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE INDEX IF NOT EXISTS "IDX_note_createdAt_userId" ON "note" ("createdAt", "userId")`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX IF EXISTS "public"."IDX_note_createdAt_userId"`);
}
}

View file

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