Optimize infohash SQL query

We need to use the array operator to use GIN index
pull/6026/head
Chocobozzz 2023-10-25 15:04:00 +02:00
parent 360439088d
commit 82813e9739
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 2 additions and 2 deletions

View File

@ -139,9 +139,9 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi
})
static doesInfohashExist (infoHash: string) {
const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE $infoHash = ANY("p2pMediaLoaderInfohashes") LIMIT 1'
const query = 'SELECT 1 FROM "videoStreamingPlaylist" WHERE "p2pMediaLoaderInfohashes" @> $infoHash LIMIT 1'
return doesExist(this.sequelize, query, { infoHash })
return doesExist(this.sequelize, query, { infoHash: `{${infoHash}}` }) // Transform infoHash in a PG array
}
static buildP2PMediaLoaderInfoHashes (playlistUrl: string, files: unknown[]) {