From 8ee988c3167229d294121af527d8fb5ed339eac9 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Jan 2020 11:16:34 +0100 Subject: Optimize videos list SQL query --- server/models/video/video.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'server/models') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index fec3dcc20..87ad80caf 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -452,7 +452,14 @@ export type AvailableForListIDsOptions = { 'SELECT "videoShare"."videoId" AS "id" FROM "videoShare" ' + 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' + 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + - ' UNION ALL ' + + ')' + ) + } + }, + { + id: { + [ Op.in ]: Sequelize.literal( + '(' + 'SELECT "video"."id" AS "id" FROM "video" ' + 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' + 'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' + -- cgit v1.2.3