Make the media stream filter index covering

This commit is contained in:
Shadowghost
2026-08-12 07:43:12 +02:00
parent 2b5625d1c4
commit 9a07d4336b
4 changed files with 13 additions and 10 deletions
@@ -13,6 +13,9 @@ public class MediaStreamInfoConfiguration : IEntityTypeConfiguration<MediaStream
public void Configure(EntityTypeBuilder<MediaStreamInfo> builder)
{
builder.HasKey(e => new { e.ItemId, e.StreamIndex });
builder.HasIndex(e => new { e.StreamType, e.ItemId });
// Covering index for the stream filters. ItemId comes second because it is what they project and
// dedupe on; Language and IsExternal follow only to keep their predicates off the table.
builder.HasIndex(e => new { e.StreamType, e.ItemId, e.Language, e.IsExternal });
}
}
@@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Jellyfin.Database.Providers.Sqlite.Migrations
{
[DbContext(typeof(JellyfinDbContext))]
[Migration("20260811145224_AddMediaStreamTypeItemIdIndex")]
partial class AddMediaStreamTypeItemIdIndex
[Migration("20260812050902_AddMediaStreamFilterIndex")]
partial class AddMediaStreamFilterIndex
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -1015,7 +1015,7 @@ namespace Jellyfin.Database.Providers.Sqlite.Migrations
b.HasKey("ItemId", "StreamIndex");
b.HasIndex("StreamType", "ItemId");
b.HasIndex("StreamType", "ItemId", "Language", "IsExternal");
b.ToTable("MediaStreamInfos");
@@ -1,26 +1,26 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jellyfin.Database.Providers.Sqlite.Migrations
{
/// <inheritdoc />
public partial class AddMediaStreamTypeItemIdIndex : Migration
public partial class AddMediaStreamFilterIndex : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_MediaStreamInfos_StreamType_ItemId",
name: "IX_MediaStreamInfos_StreamType_ItemId_Language_IsExternal",
table: "MediaStreamInfos",
columns: ["StreamType", "ItemId"]);
columns: new[] { "StreamType", "ItemId", "Language", "IsExternal" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_MediaStreamInfos_StreamType_ItemId",
name: "IX_MediaStreamInfos_StreamType_ItemId_Language_IsExternal",
table: "MediaStreamInfos");
}
}
@@ -1012,7 +1012,7 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasKey("ItemId", "StreamIndex");
b.HasIndex("StreamType", "ItemId");
b.HasIndex("StreamType", "ItemId", "Language", "IsExternal");
b.ToTable("MediaStreamInfos");