Merge pull request #18276 from Shadowghost/fix/18272-extras-ownerid-index

Make the OwnerId and ExtraType/OwnerId indexes partial so extras lookups keep using them
This commit is contained in:
Cody Robibero 2026-10-04 16:59:02 -06:00 • committed by GitHub
commit 7cf12e5fb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1873 additions and 4 deletions

View file

@ -35,9 +35,11 @@ public class BaseItemConfiguration : IEntityTypeConfiguration<BaseItemEntity>
builder.HasIndex(e => e.Path);
builder.HasIndex(e => e.ParentId);
builder.HasIndex(e => e.OwnerId);
builder.HasIndex(e => e.OwnerId)
.HasFilter("\"OwnerId\" IS NOT NULL");
builder.HasIndex(e => e.Name);
builder.HasIndex(e => new { e.ExtraType, e.OwnerId });
builder.HasIndex(e => new { e.ExtraType, e.OwnerId })
.HasFilter("\"ExtraType\" IS NOT NULL");
builder.HasIndex(e => e.PresentationUniqueKey);
// covering index
builder.HasIndex(e => new { e.TopParentId, e.Id });

View file

@ -0,0 +1,56 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Jellyfin.Database.Providers.Sqlite.Migrations
{
/// <inheritdoc />
public partial class MakeOwnerIdIndexesPartial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_BaseItems_ExtraType_OwnerId",
table: "BaseItems");
migrationBuilder.DropIndex(
name: "IX_BaseItems_OwnerId",
table: "BaseItems");
migrationBuilder.CreateIndex(
name: "IX_BaseItems_ExtraType_OwnerId",
table: "BaseItems",
columns: new[] { "ExtraType", "OwnerId" },
filter: "\"ExtraType\" IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_BaseItems_OwnerId",
table: "BaseItems",
column: "OwnerId",
filter: "\"OwnerId\" IS NOT NULL");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_BaseItems_ExtraType_OwnerId",
table: "BaseItems");
migrationBuilder.DropIndex(
name: "IX_BaseItems_OwnerId",
table: "BaseItems");
migrationBuilder.CreateIndex(
name: "IX_BaseItems_ExtraType_OwnerId",
table: "BaseItems",
columns: new[] { "ExtraType", "OwnerId" });
migrationBuilder.CreateIndex(
name: "IX_BaseItems_OwnerId",
table: "BaseItems",
column: "OwnerId");
}
}
}

View file

@ -365,7 +365,8 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("Name");
b.HasIndex("OwnerId");
b.HasIndex("OwnerId")
.HasFilter("\"OwnerId\" IS NOT NULL");
b.HasIndex("ParentId");
@ -382,7 +383,8 @@ namespace Jellyfin.Server.Implementations.Migrations
b.HasIndex("SeriesName");
b.HasIndex("ExtraType", "OwnerId");
b.HasIndex("ExtraType", "OwnerId")
.HasFilter("\"ExtraType\" IS NOT NULL");
b.HasIndex("TopParentId", "Id");