perf(backend): optimize drive/files query for old root content
This commit is contained in:
parent
6e3354f95d
commit
4ec9c3ea73
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class OptimizeDriveFilesQuery1756824506000 {
|
||||
name = 'OptimizeDriveFilesQuery1756824506000'
|
||||
|
||||
async up(queryRunner) {
|
||||
// Create optimized partial index for drive files query performance
|
||||
// This index is specifically designed for the common query pattern:
|
||||
// SELECT * FROM drive_file WHERE userId = ? AND folderId IS NULL ORDER BY id DESC
|
||||
await queryRunner.query(`CREATE INDEX "IDX_drive_file_userid_null_folderid_id_desc" ON "drive_file" ("userId", ("folderId" IS NULL), "id" DESC)`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`DROP INDEX "IDX_drive_file_userid_null_folderid_id_desc"`);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import { MiDriveFolder } from './DriveFolder.js';
|
|||
|
||||
@Entity('drive_file')
|
||||
@Index(['userId', 'folderId', 'id'])
|
||||
@Index('IDX_drive_file_userid_null_folderid_id_desc', { synchronize: false })
|
||||
export class MiDriveFile {
|
||||
@PrimaryColumn(id())
|
||||
public id: string;
|
||||
|
|
Loading…
Reference in New Issue