From eba6152493dd39aaa341eb84f4058407e43e1022 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 25 Apr 2024 00:40:51 +0200 Subject: [PATCH] [backend/database] Add indicies to the instance table --- .../DatabaseContextModelSnapshot.cs | 4 ++ ...20240424224008_AddInstanceTableIndicies.cs | 39 +++++++++++++++++++ .../Core/Database/Tables/Instance.cs | 2 + .../Core/Database/Tables/Notification.cs | 1 + 4 files changed, 46 insertions(+) create mode 100644 Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240424224008_AddInstanceTableIndicies.cs diff --git a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs index ce4fc087..e4177fbb 100644 --- a/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs +++ b/Iceshrimp.Backend/Core/Database/Migrations/DatabaseContextModelSnapshot.cs @@ -1527,8 +1527,12 @@ namespace Iceshrimp.Backend.Core.Database.Migrations b.HasIndex("Host") .IsUnique(); + b.HasIndex("IncomingFollows"); + b.HasIndex("IsSuspended"); + b.HasIndex("OutgoingFollows"); + b.ToTable("instance"); }); diff --git a/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240424224008_AddInstanceTableIndicies.cs b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240424224008_AddInstanceTableIndicies.cs new file mode 100644 index 00000000..f3cab501 --- /dev/null +++ b/Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta1/20240424224008_AddInstanceTableIndicies.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Infrastructure; + +#nullable disable + +namespace Iceshrimp.Backend.Core.Database.Migrations +{ + /// + [DbContext(typeof(DatabaseContext))] + [Migration("20240424224008_AddInstanceTableIndicies")] + public partial class AddInstanceTableIndicies : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_instance_incomingFollows", + table: "instance", + column: "incomingFollows"); + + migrationBuilder.CreateIndex( + name: "IX_instance_outgoingFollows", + table: "instance", + column: "outgoingFollows"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_instance_incomingFollows", + table: "instance"); + + migrationBuilder.DropIndex( + name: "IX_instance_outgoingFollows", + table: "instance"); + } + } +} diff --git a/Iceshrimp.Backend/Core/Database/Tables/Instance.cs b/Iceshrimp.Backend/Core/Database/Tables/Instance.cs index ddb9b1b7..b0673339 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Instance.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Instance.cs @@ -9,6 +9,8 @@ namespace Iceshrimp.Backend.Core.Database.Tables; [Index(nameof(CaughtAt))] [Index(nameof(IsSuspended))] [Index(nameof(Host), IsUnique = true)] +[Index(nameof(IncomingFollows))] +[Index(nameof(OutgoingFollows))] public class Instance { [Key] diff --git a/Iceshrimp.Backend/Core/Database/Tables/Notification.cs b/Iceshrimp.Backend/Core/Database/Tables/Notification.cs index fe29b04a..d60f4059 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Notification.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Notification.cs @@ -13,6 +13,7 @@ namespace Iceshrimp.Backend.Core.Database.Tables; [Index(nameof(CreatedAt))] [Index(nameof(AppAccessTokenId))] [Index(nameof(MastoId))] +[Index(nameof(NoteId))] public class Notification : IEntity { [PgName("notification_type_enum")]