[backend] Add multi column index for userHost to note table

This drastically improves local and social timeline performance
This commit is contained in:
Laura Hausmann 2023-11-22 04:20:27 +01:00
parent eff0f32dc1
commit 6e82e18eea
Signed by: zotan
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 AddNoteIdUserhostIdx1700623165718 implements MigrationInterface {
name = 'AddNoteIdUserhostIdx1700623165718'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE INDEX "IDX_note_id_userHost" ON "note" ("id", "userHost") `);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "public"."IDX_note_id_userHost"`);
}
}

View file

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