Skip to content

Commit

Permalink
perf: recreate wms index to add include niscode
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD committed Sep 1, 2023
1 parent 4f0d1e6 commit 1b881f9
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 10 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace StreetNameRegistry.Projections.Wms.Migrations
{
public partial class RecreateWmsIndexRemoved : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_StreetNameHelperV2_Removed",
schema: "wms.streetname",
table: "StreetNameHelperV2");

migrationBuilder.CreateIndex(
name: "IX_StreetNameHelperV2_Removed",
schema: "wms.streetname",
table: "StreetNameHelperV2",
column: "Removed")
.Annotation("SqlServer:Include", new[] { "NisCode" });
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_StreetNameHelperV2_Removed",
schema: "wms.streetname",
table: "StreetNameHelperV2");

migrationBuilder.CreateIndex(
name: "IX_StreetNameHelperV2_Removed",
schema: "wms.streetname",
table: "StreetNameHelperV2",
column: "Removed");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using StreetNameRegistry.Projections.Wms;

#nullable disable

namespace StreetNameRegistry.Projections.Wms.Migrations
{
[DbContext(typeof(WmsContext))]
Expand All @@ -15,9 +17,10 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.6")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
.HasAnnotation("ProductVersion", "6.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);

modelBuilder.Entity("Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.ProjectionStates.ProjectionStateItem", b =>
{
Expand All @@ -36,8 +39,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<long>("Position")
.HasColumnType("bigint");

b.HasKey("Name")
.IsClustered();
b.HasKey("Name");

SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Name"));

b.ToTable("ProjectionStates", "wms.streetname");
});
Expand Down Expand Up @@ -97,8 +101,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("datetimeoffset")
.HasColumnName("VersionTimestamp");

b.HasKey("StreetNameId")
.IsClustered(false);
b.HasKey("StreetNameId");

SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("StreetNameId"), false);

b.HasIndex("MunicipalityId");

Expand Down Expand Up @@ -156,13 +161,16 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("datetimeoffset")
.HasColumnName("VersionTimestamp");

b.HasKey("PersistentLocalId")
.IsClustered();
b.HasKey("PersistentLocalId");

SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("PersistentLocalId"));

b.HasIndex("MunicipalityId");

b.HasIndex("Removed");

SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex("Removed"), new[] { "NisCode" });

b.ToTable("StreetNameHelperV2", "wms.streetname");
});
#pragma warning restore 612, 618
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public void Configure(EntityTypeBuilder<StreetNameHelperV2> builder)
builder.Property(x => x.Status);
builder.Property(x => x.Removed);

builder.HasIndex(x => x.Removed);
builder.HasIndex(x => x.Removed)
.IncludeProperties(x => x.NisCode);
builder.HasIndex(x => x.MunicipalityId);
}
}
Expand Down

0 comments on commit 1b881f9

Please sign in to comment.