Optimize invoice performance with indexes and DTO
Added indexes for `ImportedAt` and a composite key on `InvoiceNumber` and `SellerTaxId` to improve query performance. Updated `AppDbContext` and EF Core migrations to reflect these changes. Introduced `ZugferdInvoiceListDto` to optimize memory usage by excluding large fields like `RawXml`. Updated the frontend (`Index.cshtml`) and backend (`Index.cshtml.cs`) to use the new DTO for better performance.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DXApp.TemplateKitProject.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPerformanceIndexes : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "SellerTaxId",
|
||||
table: "ZugferdInvoices",
|
||||
type: "nvarchar(450)",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(max)",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "InvoiceNumber",
|
||||
table: "ZugferdInvoices",
|
||||
type: "nvarchar(450)",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(max)",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ZugferdInvoices_ImportedAt",
|
||||
table: "ZugferdInvoices",
|
||||
column: "ImportedAt");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ZugferdInvoices_InvoiceNumber_SellerTaxId",
|
||||
table: "ZugferdInvoices",
|
||||
columns: new[] { "InvoiceNumber", "SellerTaxId" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_ZugferdInvoices_ImportedAt",
|
||||
table: "ZugferdInvoices");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_ZugferdInvoices_InvoiceNumber_SellerTaxId",
|
||||
table: "ZugferdInvoices");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "SellerTaxId",
|
||||
table: "ZugferdInvoices",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "InvoiceNumber",
|
||||
table: "ZugferdInvoices",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(450)",
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user