Optimize Search and NextUp queries

This commit is contained in:
Shadowghost
2026-03-08 15:10:01 +01:00
parent 1d8bdcc411
commit ba722b4517
10 changed files with 1921 additions and 75 deletions

View File

@@ -65,6 +65,8 @@ public class BaseItemConfiguration : IEntityTypeConfiguration<BaseItemEntity>
builder.HasIndex(e => new { e.Type, e.TopParentId, e.SortName });
// NextUp: per-series episode ordering (index seek + range scan on season/episode)
builder.HasIndex(e => new { e.Type, e.SeriesPresentationUniqueKey, e.ParentIndexNumber, e.IndexNumber });
// ByName queries: WHERE Type = X AND CleanName IN (...)
builder.HasIndex(e => new { e.Type, e.CleanName });
// Latest TV: GROUP BY SeriesName
builder.HasIndex(e => e.SeriesName);
// Latest TV: episode count per season, season count per series

View File

@@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jellyfin.Database.Providers.Sqlite.Migrations
{
/// <inheritdoc />
public partial class AddTypeCleanNameIndex : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_BaseItems_Type_CleanName",
table: "BaseItems",
columns: new[] { "Type", "CleanName" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_BaseItems_Type_CleanName",
table: "BaseItems");
}
}
}

View File

@@ -380,6 +380,8 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("TopParentId", "Id");
b.HasIndex("Type", "CleanName");
b.HasIndex("Type", "TopParentId", "Id");
b.HasIndex("Type", "TopParentId", "PresentationUniqueKey");