From 5ccd5ad56e0cd013deb5f73de26aa3d298deec77 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 15 Feb 2020 04:29:57 +0900 Subject: [PATCH] Add driveFiles index --- CHANGELOG.md | 1 + .../1581708415836-drive-user-folder-id-index.ts | 14 ++++++++++++++ src/models/entities/drive-file.ts | 1 + 3 files changed, 16 insertions(+) create mode 100644 migration/1581708415836-drive-user-folder-id-index.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index b53eaf93c..f3856b14a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ unreleased ### 🐛Fixes * v12アップデート後にトップページアクセスでOops!になっちゃうのを修正 +* drive/files APIのパフォーマンスを改善 12.9.0 (2020/02/14) ------------------- diff --git a/migration/1581708415836-drive-user-folder-id-index.ts b/migration/1581708415836-drive-user-folder-id-index.ts new file mode 100644 index 000000000..e7a7628ff --- /dev/null +++ b/migration/1581708415836-drive-user-folder-id-index.ts @@ -0,0 +1,14 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class driveUserFolderIdIndex1581708415836 implements MigrationInterface { + name = 'driveUserFolderIdIndex1581708415836' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE INDEX "IDX_55720b33a61a7c806a8215b825" ON "drive_file" ("userId", "folderId", "id") `, undefined); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX "IDX_55720b33a61a7c806a8215b825"`, undefined); + } + +} diff --git a/src/models/entities/drive-file.ts b/src/models/entities/drive-file.ts index 319bdc82c..067dc1181 100644 --- a/src/models/entities/drive-file.ts +++ b/src/models/entities/drive-file.ts @@ -4,6 +4,7 @@ import { DriveFolder } from './drive-folder'; import { id } from '../id'; @Entity() +@Index(['userId', 'folderId', 'id']) export class DriveFile { @PrimaryColumn(id()) public id: string;