Fix performance issues on query over orderId (fix #2114)

This commit is contained in:
nicolas.dorier 2020-12-08 14:43:39 +09:00
parent 4c62c5dc22
commit 76e46d2fa7
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
3 changed files with 29 additions and 0 deletions

View File

@ -85,6 +85,7 @@ namespace BTCPayServer.Data
.HasOne(o => o.StoreData)
.WithMany(a => a.Invoices).OnDelete(DeleteBehavior.Cascade);
builder.Entity<InvoiceData>().HasIndex(o => o.StoreDataId);
builder.Entity<InvoiceData>().HasIndex(o => o.OrderId);
builder.Entity<InvoiceData>()
.HasOne(o => o.CurrentRefund);
}

View File

@ -0,0 +1,26 @@
using BTCPayServer.Data;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
namespace BTCPayServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20201208054211_invoicesorderindex")]
public partial class invoicesorderindex : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Invoices_OrderId",
table: "Invoices",
column: "OrderId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Invoices_OrderId",
table: "Invoices");
}
}
}

View File

@ -228,6 +228,8 @@ namespace BTCPayServer.Migrations
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("StoreDataId");
b.HasIndex("Id", "CurrentRefundId");