optimize jellyfin database fields and indexes (#2746)

* optimize jellyfin database fields and indexes

* copy paste
This commit is contained in:
Jason Dove
2025-12-31 14:30:53 -06:00
committed by GitHub
parent c606319030
commit 14d2dd0c3a
13 changed files with 14259 additions and 16 deletions
+1
View File
@@ -80,6 +80,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Items may still be cut as needed
- Hardware acceleration will now be used
- Items can "work ahead" (transcode faster than realtime) when less than 3 minutes in duration
- Optimize Jellyfin database fields and indexes
## [25.9.0] - 2025-11-29
### Added
@@ -0,0 +1,358 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.MySql.Migrations
{
/// <inheritdoc />
public partial class Optimize_JellyfinItemIdEtagColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinShow",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinShow",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinSeason",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinSeason",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinMovie",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinMovie",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinLibrary",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinEpisode",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinEpisode",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinCollection",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinCollection",
type: "varchar(36)",
unicode: false,
maxLength: 36,
nullable: true,
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_JellyfinShow_ItemId",
table: "JellyfinShow",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinSeason_ItemId",
table: "JellyfinSeason",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinMovie_ItemId",
table: "JellyfinMovie",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinLibrary_ItemId",
table: "JellyfinLibrary",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinEpisode_ItemId",
table: "JellyfinEpisode",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinCollection_ItemId",
table: "JellyfinCollection",
column: "ItemId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_JellyfinShow_ItemId",
table: "JellyfinShow");
migrationBuilder.DropIndex(
name: "IX_JellyfinSeason_ItemId",
table: "JellyfinSeason");
migrationBuilder.DropIndex(
name: "IX_JellyfinMovie_ItemId",
table: "JellyfinMovie");
migrationBuilder.DropIndex(
name: "IX_JellyfinLibrary_ItemId",
table: "JellyfinLibrary");
migrationBuilder.DropIndex(
name: "IX_JellyfinEpisode_ItemId",
table: "JellyfinEpisode");
migrationBuilder.DropIndex(
name: "IX_JellyfinCollection_ItemId",
table: "JellyfinCollection");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinShow",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinShow",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinSeason",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinSeason",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinMovie",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinMovie",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinLibrary",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinEpisode",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinEpisode",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ItemId",
table: "JellyfinCollection",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "Etag",
table: "JellyfinCollection",
type: "longtext",
nullable: true,
oldClrType: typeof(string),
oldType: "varchar(36)",
oldUnicode: false,
oldMaxLength: 36,
oldNullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
}
}
@@ -1024,16 +1024,22 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Etag")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<string>("ItemId")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<string>("Name")
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("ItemId");
b.ToTable("JellyfinCollection", (string)null);
});
@@ -3781,11 +3787,15 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Library");
b.Property<string>("ItemId")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<bool>("ShouldSyncItems")
.HasColumnType("tinyint(1)");
b.HasIndex("ItemId");
b.ToTable("JellyfinLibrary", (string)null);
});
@@ -4053,10 +4063,16 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Episode");
b.Property<string>("Etag")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<string>("ItemId")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.HasIndex("ItemId");
b.ToTable("JellyfinEpisode", (string)null);
});
@@ -4092,10 +4108,16 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Movie");
b.Property<string>("Etag")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<string>("ItemId")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.HasIndex("ItemId");
b.ToTable("JellyfinMovie", (string)null);
});
@@ -4144,10 +4166,16 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Season");
b.Property<string>("Etag")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<string>("ItemId")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.HasIndex("ItemId");
b.ToTable("JellyfinSeason", (string)null);
});
@@ -4183,10 +4211,16 @@ namespace ErsatzTV.Infrastructure.MySql.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Show");
b.Property<string>("Etag")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.Property<string>("ItemId")
.HasColumnType("longtext");
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("varchar(36)");
b.HasIndex("ItemId");
b.ToTable("JellyfinShow", (string)null);
});
@@ -0,0 +1,72 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ErsatzTV.Infrastructure.Sqlite.Migrations
{
/// <inheritdoc />
public partial class Optimize_JellyfinItemIdEtagColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_JellyfinShow_ItemId",
table: "JellyfinShow",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinSeason_ItemId",
table: "JellyfinSeason",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinMovie_ItemId",
table: "JellyfinMovie",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinLibrary_ItemId",
table: "JellyfinLibrary",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinEpisode_ItemId",
table: "JellyfinEpisode",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_JellyfinCollection_ItemId",
table: "JellyfinCollection",
column: "ItemId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_JellyfinShow_ItemId",
table: "JellyfinShow");
migrationBuilder.DropIndex(
name: "IX_JellyfinSeason_ItemId",
table: "JellyfinSeason");
migrationBuilder.DropIndex(
name: "IX_JellyfinMovie_ItemId",
table: "JellyfinMovie");
migrationBuilder.DropIndex(
name: "IX_JellyfinLibrary_ItemId",
table: "JellyfinLibrary");
migrationBuilder.DropIndex(
name: "IX_JellyfinEpisode_ItemId",
table: "JellyfinEpisode");
migrationBuilder.DropIndex(
name: "IX_JellyfinCollection_ItemId",
table: "JellyfinCollection");
}
}
}
@@ -981,9 +981,13 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
.HasColumnType("INTEGER");
b.Property<string>("Etag")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.Property<string>("ItemId")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.Property<string>("Name")
@@ -991,6 +995,8 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
b.HasKey("Id");
b.HasIndex("ItemId");
b.ToTable("JellyfinCollection", (string)null);
});
@@ -3608,11 +3614,15 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Library");
b.Property<string>("ItemId")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.Property<bool>("ShouldSyncItems")
.HasColumnType("INTEGER");
b.HasIndex("ItemId");
b.ToTable("JellyfinLibrary", (string)null);
});
@@ -3880,11 +3890,17 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Episode");
b.Property<string>("Etag")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.Property<string>("ItemId")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.HasIndex("ItemId");
b.ToTable("JellyfinEpisode", (string)null);
});
@@ -3919,11 +3935,17 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Movie");
b.Property<string>("Etag")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.Property<string>("ItemId")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.HasIndex("ItemId");
b.ToTable("JellyfinMovie", (string)null);
});
@@ -3971,11 +3993,17 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Season");
b.Property<string>("Etag")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.Property<string>("ItemId")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.HasIndex("ItemId");
b.ToTable("JellyfinSeason", (string)null);
});
@@ -4010,11 +4038,17 @@ namespace ErsatzTV.Infrastructure.Sqlite.Migrations
b.HasBaseType("ErsatzTV.Core.Domain.Show");
b.Property<string>("Etag")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.Property<string>("ItemId")
.HasMaxLength(36)
.IsUnicode(false)
.HasColumnType("TEXT");
b.HasIndex("ItemId");
b.ToTable("JellyfinShow", (string)null);
});
@@ -6,5 +6,18 @@ namespace ErsatzTV.Infrastructure.Data.Configurations;
public class JellyfinCollectionConfiguration : IEntityTypeConfiguration<JellyfinCollection>
{
public void Configure(EntityTypeBuilder<JellyfinCollection> builder) => builder.ToTable("JellyfinCollection");
public void Configure(EntityTypeBuilder<JellyfinCollection> builder)
{
builder.ToTable("JellyfinCollection");
builder.Property(c => c.Etag)
.HasMaxLength(36)
.IsUnicode(false);
builder.Property(c => c.ItemId)
.HasMaxLength(36)
.IsUnicode(false);
builder.HasIndex(c => c.ItemId);
}
}
@@ -13,5 +13,11 @@ public class JellyfinLibraryConfiguration : IEntityTypeConfiguration<JellyfinLib
builder.HasMany(l => l.PathInfos)
.WithOne()
.OnDelete(DeleteBehavior.Cascade);
builder.Property(l => l.ItemId)
.HasMaxLength(36)
.IsUnicode(false);
builder.HasIndex(l => l.ItemId);
}
}
@@ -6,5 +6,18 @@ namespace ErsatzTV.Infrastructure.Data.Configurations;
public class JellyfinEpisodeConfiguration : IEntityTypeConfiguration<JellyfinEpisode>
{
public void Configure(EntityTypeBuilder<JellyfinEpisode> builder) => builder.ToTable("JellyfinEpisode");
public void Configure(EntityTypeBuilder<JellyfinEpisode> builder)
{
builder.ToTable("JellyfinEpisode");
builder.Property(e => e.Etag)
.HasMaxLength(36)
.IsUnicode(false);
builder.Property(e => e.ItemId)
.HasMaxLength(36)
.IsUnicode(false);
builder.HasIndex(e => e.ItemId);
}
}
@@ -6,5 +6,18 @@ namespace ErsatzTV.Infrastructure.Data.Configurations;
public class JellyfinMovieConfiguration : IEntityTypeConfiguration<JellyfinMovie>
{
public void Configure(EntityTypeBuilder<JellyfinMovie> builder) => builder.ToTable("JellyfinMovie");
public void Configure(EntityTypeBuilder<JellyfinMovie> builder)
{
builder.ToTable("JellyfinMovie");
builder.Property(m => m.Etag)
.HasMaxLength(36)
.IsUnicode(false);
builder.Property(m => m.ItemId)
.HasMaxLength(36)
.IsUnicode(false);
builder.HasIndex(m => m.ItemId);
}
}
@@ -6,5 +6,18 @@ namespace ErsatzTV.Infrastructure.Data.Configurations;
public class JellyfinSeasonConfiguration : IEntityTypeConfiguration<JellyfinSeason>
{
public void Configure(EntityTypeBuilder<JellyfinSeason> builder) => builder.ToTable("JellyfinSeason");
public void Configure(EntityTypeBuilder<JellyfinSeason> builder)
{
builder.ToTable("JellyfinSeason");
builder.Property(s => s.Etag)
.HasMaxLength(36)
.IsUnicode(false);
builder.Property(s => s.ItemId)
.HasMaxLength(36)
.IsUnicode(false);
builder.HasIndex(s => s.ItemId);
}
}
@@ -6,5 +6,18 @@ namespace ErsatzTV.Infrastructure.Data.Configurations;
public class JellyfinShowConfiguration : IEntityTypeConfiguration<JellyfinShow>
{
public void Configure(EntityTypeBuilder<JellyfinShow> builder) => builder.ToTable("JellyfinShow");
public void Configure(EntityTypeBuilder<JellyfinShow> builder)
{
builder.ToTable("JellyfinShow");
builder.Property(s => s.Etag)
.HasMaxLength(36)
.IsUnicode(false);
builder.Property(s => s.ItemId)
.HasMaxLength(36)
.IsUnicode(false);
builder.HasIndex(s => s.ItemId);
}
}