1
0
Fork 0

Don't add a LIMIT 1 to prevent seq scan

This commit is contained in:
Chocobozzz 2023-10-26 08:36:53 +02:00
parent d3dd952cc5
commit dd7de7e32d
No known key found for this signature in database
GPG key ID: 583A612D890159BE

View file

@ -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
}