Compare commits

...

5 commits

Author SHA1 Message Date
598b88b142 Merge pull request 'Replace notes(userId) index with (userId, id)' (#28) from sugar/forkey:replace-notes-user-id-index-with-user-id-id into main
Reviewed-on: woem.men/forkey#28
Reviewed-by: leah <leah@noreply.woem.men>
2025-02-23 13:05:54 +00:00
884caa8c1e Merge branch 'main' into replace-notes-user-id-index-with-user-id-id 2025-01-19 07:56:10 +00:00
9f4a76a1d9 Merge branch 'main' into replace-notes-user-id-index-with-user-id-id 2025-01-19 06:06:19 +00:00
44edae531a Merge branch 'main' into replace-notes-user-id-index-with-user-id-id 2025-01-18 20:38:54 -08:00
93dba136ab Replace notes(userId) index with (userId, id)
This improves performance of queries searching posts by a given user,
optionally with a provided range of dates, and then using ORDER BY to
sort posts by date.

Examples of such queries include: viewing posts by a given user, as
well as checking when the last post by a given user was written for
Mastodon API.
2025-01-17 15:29:08 +00:00
2 changed files with 12 additions and 0 deletions

View file

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

View file

@ -15,6 +15,7 @@ import type { MiDriveFile } from './DriveFile.js';
@Index('IDX_NOTE_MENTIONS', { synchronize: false }) @Index('IDX_NOTE_MENTIONS', { synchronize: false })
@Index('IDX_NOTE_FILE_IDS', { synchronize: false }) @Index('IDX_NOTE_FILE_IDS', { synchronize: false })
@Index('IDX_NOTE_VISIBLE_USER_IDS', { synchronize: false }) @Index('IDX_NOTE_VISIBLE_USER_IDS', { synchronize: false })
@Index('IDX_note_userId_id', ['userId', 'id'])
export class MiNote { export class MiNote {
@PrimaryColumn(id()) @PrimaryColumn(id())
public id: string; public id: string;