merge: Rework queries and add indexes to improve timeline performance (!1091)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1091

Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
Hazelnoot 2025-06-04 12:40:13 +00:00
commit dae544b353
33 changed files with 743 additions and 548 deletions

View file

@ -6,7 +6,8 @@
import { Entity, PrimaryColumn, Index, Column } from 'typeorm';
import { id } from './util/id.js';
@Index('IDX_instance_host_key', { synchronize: false })
@Index('IDX_instance_host_key', { synchronize: false }) // ((lower(reverse("host"::text)) || '.'::text)
@Index('IDX_instance_host_filters', { synchronize: false }) // ("host", "isBlocked", "isSilenced", "isMediaSilenced", "isAllowListed", "isBubbled", "suspensionState")
@Entity('instance')
export class MiInstance {
@PrimaryColumn(id())

View file

@ -12,6 +12,8 @@ import { MiChannel } from './Channel.js';
import type { MiDriveFile } from './DriveFile.js';
@Index('IDX_724b311e6f883751f261ebe378', ['userId', 'id'])
@Index('IDX_note_userHost_id', { synchronize: false }) // (userHost, id desc)
@Index('IDX_note_for_timelines', { synchronize: false }) // (id desc, channelId, visibility, userHost)
@Entity('note')
export class MiNote {
@PrimaryColumn(id())
@ -216,7 +218,6 @@ export class MiNote {
public processErrors: string[] | null;
//#region Denormalized fields
@Index()
@Column('varchar', {
length: 128, nullable: true,
comment: '[Denormalized]',

View file

@ -200,6 +200,10 @@ export const packedUserLiteSchema = {
type: 'string',
nullable: true, optional: false,
},
isSilenced: {
type: 'boolean',
nullable: false, optional: false,
},
},
},
emojis: {