Optimize videos list SQL query
authorChocobozzz <me@florianbigard.com>
Wed, 8 Jan 2020 10:16:34 +0000 (11:16 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 8 Jan 2020 10:16:34 +0000 (11:16 +0100)
server/models/video/video.ts

index fec3dcc205001d7da881693d61a36c12d4b6fcca..87ad80cafd4a9822b55bbab41f33c8b0029a50c0 100644 (file)
@@ -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" ' +