Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Don't add a LIMIT 1 to prevent seq scan

Chocobozzzdd7de7e32d09
diff --git a/server/core/models/video/video-streaming-playlist.ts b/server/core/models/video/video-streaming-playlist.ts
index e7f889031b..ef6437513d 100644
--- a/server/core/models/video/video-streaming-playlist.ts
+++ b/server/core/models/video/video-streaming-playlist.ts
@@ -139,7 +139,8 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi
})
static doesInfohashExist (infoHash: string) {
- const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE "p2pMediaLoaderInfohashes" @> $infoHash LIMIT 1'
+ // Don't add a LIMIT 1 here to prevent seq scan by PostgreSQL (not sure why id doesn't use the index when we add a LIMIT)
+ const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE "p2pMediaLoaderInfohashes" @> $infoHash'
return doesExist(this.sequelize, query, { infoHash: `{${infoHash}}` }) // Transform infoHash in a PG array
}