From 8cd72bd37724054f8942f2fefc7aa2e60eca74cf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 23 Jul 2018 20:13:30 +0200 Subject: Optimize SQL queries --- server/models/account/account-video-rate.ts | 9 +++++++++ server/models/account/account.ts | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'server/models/account') diff --git a/server/models/account/account-video-rate.ts b/server/models/account/account-video-rate.ts index 9c19ec748..c99e32012 100644 --- a/server/models/account/account-video-rate.ts +++ b/server/models/account/account-video-rate.ts @@ -17,6 +17,15 @@ import { ActorModel } from '../activitypub/actor' { fields: [ 'videoId', 'accountId' ], unique: true + }, + { + fields: [ 'videoId' ] + }, + { + fields: [ 'accountId' ] + }, + { + fields: [ 'videoId', 'type' ] } ] }) diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 3ff59887d..2eed66fc2 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -46,7 +46,19 @@ import { UserModel } from './user' ] }) @Table({ - tableName: 'account' + tableName: 'account', + indexes: [ + { + fields: [ 'actorId' ], + unique: true + }, + { + fields: [ 'applicationId' ] + }, + { + fields: [ 'userId' ] + } + ] }) export class AccountModel extends Model { -- cgit v1.2.3